-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
76 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { ServiceParser } from './decorator-parser'; | ||
import {ServiceDescription, ISecurityContext} from './descriptions'; | ||
import {PermitAll, Path, GET, RolesAllowed, SecurityContext} from "./decorators"; | ||
|
||
|
||
@PermitAll() | ||
@Path('/') | ||
class TestServiceA { | ||
|
||
@GET() | ||
x(){} | ||
} | ||
|
||
@Path('/') | ||
class TestServiceB { | ||
@GET() | ||
x(){} | ||
} | ||
|
||
class TestServiceC { | ||
|
||
@GET() | ||
@RolesAllowed(['user']) | ||
x(){} | ||
} | ||
|
||
class TestServiceD { | ||
|
||
@GET() | ||
x(@SecurityContext() conext:ISecurityContext){} | ||
} | ||
|
||
describe('ServiceDescription', () => { | ||
|
||
|
||
it('should need a security context - permitAll at class level', () => { | ||
let serviceDescription = ServiceParser.parse(new TestServiceA()); | ||
expect(serviceDescription.isSecurityContextUsed()).toBe(true); | ||
}) | ||
|
||
it('should not need a security context', () => { | ||
let serviceDescription = ServiceParser.parse(new TestServiceB()); | ||
expect(serviceDescription.isSecurityContextUsed()).toBe(false); | ||
}) | ||
|
||
it('should need a security context - RolesAllowed at method level', () => { | ||
let serviceDescription = ServiceParser.parse(new TestServiceC()); | ||
expect(serviceDescription.isSecurityContextUsed()).toBe(true); | ||
}) | ||
|
||
it('should need a security context - SecurityContextParam', () => { | ||
let serviceDescription = ServiceParser.parse(new TestServiceD()); | ||
expect(serviceDescription.isSecurityContextUsed()).toBe(true); | ||
}) | ||
}) |
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
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