-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mgr/dashboard: Add decorator to skip parameter encoding
By enconding all parameters of api services we were also encoding parameters that were being sent in the body of the request. Those parameters don't need to be enconded and the server never decodes them. With this new decorator you can specify if you don't want a parameter to be enconded. This is a regression introduced in f21d0da. Fixes: http://tracker.ceph.com/issues/26856 Signed-off-by: Tiago Melo <tmelo@suse.com> (cherry picked from commit 45e645b) Conflicts: src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd.service.spec.ts src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd.service.ts
- Loading branch information
Showing
3 changed files
with
91 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/pybind/mgr/dashboard/frontend/src/app/shared/decorators/cd-encode.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { cdEncode, cdEncodeNot } from './cd-encode'; | ||
|
||
describe('cdEncode', () => { | ||
@cdEncode | ||
class ClassA { | ||
x2: string; | ||
y2: string; | ||
|
||
methodA(x1: string, @cdEncodeNot y1: string) { | ||
this.x2 = x1; | ||
this.y2 = y1; | ||
} | ||
} | ||
|
||
class ClassB { | ||
x2: string; | ||
y2: string; | ||
|
||
@cdEncode | ||
methodB(x1: string, @cdEncodeNot y1: string) { | ||
this.x2 = x1; | ||
this.y2 = y1; | ||
} | ||
} | ||
|
||
const word = 'a+b/c-d'; | ||
|
||
it('should encode all params of ClassA, with exception of y1', () => { | ||
const a = new ClassA(); | ||
a.methodA(word, word); | ||
expect(a.x2).toBe('a%2Bb%2Fc-d'); | ||
expect(a.y2).toBe(word); | ||
}); | ||
|
||
it('should encode all params of methodB, with exception of y1', () => { | ||
const b = new ClassB(); | ||
b.methodB(word, word); | ||
expect(b.x2).toBe('a%2Bb%2Fc-d'); | ||
expect(b.y2).toBe(word); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters