Skip to content

Commit

Permalink
Merge pull request #105 from ba-st/permissions
Browse files Browse the repository at this point in the history
Change permissions implementation for JWT claims
  • Loading branch information
gcotelli authored Jun 30, 2020
2 parents 05e5d34 + a1d8dcd commit f93269c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,15 @@ PetOrdersRESTfulControllerTest >> testGetCanceledOrder [
self
assertUrl: json pet equals: self petUrl;
assert: json status equals: 'registered';
assertUrl: json links self equals: 'https://petstore.example.com/orders/1';
assertUrl: json selfLocation equals: 'https://petstore.example.com/orders/1';
assertUrl: json links cancel equals: 'https://petstore.example.com/orders/1/cancel';
assertUrl: json links complete equals: 'https://petstore.example.com/orders/1/complete';
assert: (resourceController cancelOrderBasedOn: (self requestToPOST: json links cancel identifiedBy: 1) within: self newHttpRequestContext) isSuccess ];
getFirstOrderAndWithJsonDo: [ :json |
self
assertUrl: json pet equals: self petUrl;
assert: json status equals: 'canceled';
assertUrl: json links self equals: 'https://petstore.example.com/orders/1' ]
assertUrl: json selfLocation equals: 'https://petstore.example.com/orders/1' ]
]

{ #category : #'tests - comments' }
Expand Down Expand Up @@ -396,7 +396,7 @@ PetOrdersRESTfulControllerTest >> testGetOrderJustCreated [
self
assertUrl: json pet equals: self petUrl;
assert: json status equals: 'registered';
assertUrl: json links self equals: 'https://petstore.example.com/orders/1';
assertUrl: json selfLocation equals: 'https://petstore.example.com/orders/1';
assertUrl: json links cancel equals: 'https://petstore.example.com/orders/1/cancel';
assertUrl: json links complete equals: 'https://petstore.example.com/orders/1/complete' ]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ PetsRESTfulControllerTest >> testGetPetJustCreated [
assert: json name equals: 'Firulais';
assert: json type equals: 'dog';
assert: json status equals: 'new';
assertUrl: json links self equals: 'https://pets.example.com/pets/1'
assertUrl: json selfLocation equals: 'https://pets.example.com/pets/1'
]
]

Expand Down Expand Up @@ -333,7 +333,7 @@ PetsRESTfulControllerTest >> testGetPetJustCreatedWhenNoAcceptHeaderPresentInReq
do: [ :json |
self
assert: json name equals: 'Firulais';
assertUrl: json links self equals: 'https://pets.example.com/pets/1'
assertUrl: json selfLocation equals: 'https://pets.example.com/pets/1'
]
]

Expand Down Expand Up @@ -382,7 +382,7 @@ PetsRESTfulControllerTest >> testGetPetSummaryJustCreated [
do: [ :json |
self
assert: json name equals: 'Firulais';
assertUrl: json links self equals: 'https://pets.example.com/pets/1';
assertUrl: json selfLocation equals: 'https://pets.example.com/pets/1';
assert: json type isNil;
assert: json status isNil
]
Expand Down Expand Up @@ -586,7 +586,7 @@ PetsRESTfulControllerTest >> testUpdatePetName [
assert: json name equals: 'Mendieta';
assert: json type equals: 'dog';
assert: json status equals: 'new';
assertUrl: json links self equals: 'https://pets.example.com/pets/1' ]
assertUrl: json selfLocation equals: 'https://pets.example.com/pets/1' ]
]

{ #category : #'tests - update' }
Expand All @@ -613,5 +613,5 @@ PetsRESTfulControllerTest >> testUpdatePetStatus [
assert: json name equals: 'Firulais';
assert: json type equals: 'dog';
assert: json status equals: 'gone';
assertUrl: json links self equals: 'https://pets.example.com/pets/1' ]
assertUrl: json selfLocation equals: 'https://pets.example.com/pets/1' ]
]
10 changes: 3 additions & 7 deletions source/Stargate-Model/JWTClaimsSet.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@ Extension { #name : #JWTClaimsSet }
{ #category : #'*Stargate-Model' }
JWTClaimsSet >> permissions [

^ self scope splitOn: Character space
^ claims at: 'permissions' ifAbsent: [ ^ #() ]
]

{ #category : #'*Stargate-Model' }
JWTClaimsSet >> permissions: aStringCollection [
JWTClaimsSet >> permissions: aCollection [

self
scope:
( String
streamContents:
[ :stream | aStringCollection do: [ :string | stream nextPutAll: string ] separatedBy: [ stream space ] ] )
self at: 'permissions' put: aCollection asArray
]

{ #category : #'*Stargate-Model' }
Expand Down

0 comments on commit f93269c

Please sign in to comment.