Skip to content

Commit

Permalink
Sync documentation of main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed May 5, 2024
1 parent 60e07f2 commit 9e048b9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions _versions/main/guides/security-testing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,24 @@ identity to be present.

See xref:security-oidc-bearer-token-authentication.adoc#integration-testing-security-annotation[OpenID Connect Bearer Token Integration testing], xref:security-oidc-code-flow-authentication.adoc#integration-testing-security-annotation[OpenID Connect Authorization Code Flow Integration testing] and xref:security-jwt.adoc#integration-testing-security-annotation[SmallRye JWT Integration testing] for more details about testing the endpoint code which depends on the injected `JsonWebToken`.

Additionally, you can specify attributes for the identity, perhaps custom items that were added with identity augmentation:

[source,java]
----
@Inject
SecurityIdentity identity;
@Test
@TestSecurity(user = "testUser", "roles = {"admin, "user"}, attributes = {
@SecurityAttribute(key = "answer", value = "42", type = AttributeType.LONG) }
void someTestMethod() {
Long answer = identity.<Long>getAttribute("answer");
...
}
----

This will run the test with an identity with an attribute of type `Long` named `answer`.

[WARNING]
====
The feature is only available for `@QuarkusTest` and will **not** work on a `@QuarkusIntegrationTest`.
Expand Down

0 comments on commit 9e048b9

Please sign in to comment.