forked from BlueBrain/nexus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve token error handling + integration tests (BlueBrain#3709)
Co-authored-by: Simon Dumas <[email protected]>
- Loading branch information
Showing
12 changed files
with
102 additions
and
26 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
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
2 changes: 1 addition & 1 deletion
2
delta/sdk/src/test/resources/identities/invalid-access-token.json
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"@context" : "https://bluebrain.github.io/nexus/contexts/error.json", | ||
"@type" : "InvalidAccessToken", | ||
"reason" : "The provided token is invalid.", | ||
"reason" : "The provided token is invalid for user '{{subject}}/{{issuer}}' .", | ||
"details": "Expired JWT" | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"@context": "https://bluebrain.github.io/nexus/contexts/error.json", | ||
"@type": "InvalidAccessTokenFormat", | ||
"reason": "Access token is invalid; possible causes are: JWT not signed, encoded parts are not properly encoded or each part is not a valid json." | ||
} |
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,23 @@ | ||
{ | ||
"@context": [ | ||
"https://bluebrain.github.io/nexus/contexts/metadata.json", | ||
"https://bluebrain.github.io/nexus/contexts/identities.json" | ||
], | ||
"identities": [ | ||
{ | ||
"@id": "{{deltaUri}}/anonymous", | ||
"@type": "Anonymous" | ||
}, | ||
{ | ||
"@id": "{{deltaUri}}/realms/internal/authenticated", | ||
"@type": "Authenticated", | ||
"realm": "internal" | ||
}, | ||
{ | ||
"@id": "{{deltaUri}}/realms/internal/users/service-account-delta", | ||
"@type": "User", | ||
"realm": "internal", | ||
"subject": "service-account-delta" | ||
} | ||
] | ||
} |
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
30 changes: 30 additions & 0 deletions
30
tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/iam/IdentitiesSpec.scala
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,30 @@ | ||
package ch.epfl.bluebrain.nexus.tests.iam | ||
|
||
import akka.http.scaladsl.model.StatusCodes | ||
import ch.epfl.bluebrain.nexus.tests.HttpClient.tokensMap | ||
import ch.epfl.bluebrain.nexus.tests.{BaseSpec, Identity} | ||
import io.circe.Json | ||
|
||
class IdentitiesSpec extends BaseSpec { | ||
|
||
"The /identities endpoint" should { | ||
s"return identities of the user" in { | ||
deltaClient.get[Json]("/identities", Identity.ServiceAccount) { (json, response) => | ||
response.status shouldEqual StatusCodes.OK | ||
json shouldEqual jsonContentOf( | ||
"/iam/identities/response.json", | ||
"deltaUri" -> config.deltaUri.toString() | ||
) | ||
} | ||
} | ||
|
||
"return the error for an invalid token" in { | ||
tokensMap.put(Identity.InvalidTokenUser, toAuthorizationHeader("INVALID")) | ||
|
||
deltaClient.get[Json]("/identities", Identity.InvalidTokenUser) { (json, response) => | ||
response.status shouldEqual StatusCodes.Unauthorized | ||
json shouldEqual jsonContentOf("/iam/identities/errors.json") | ||
} | ||
} | ||
} | ||
} |
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