forked from quarkusio/quarkus
-
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.
Fail early if OIDC client password grant OIDC UserInfo access is misc…
…onfigured
- Loading branch information
1 parent
5f0dbbc
commit 4d591f0
Showing
2 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
.../src/test/java/io/quarkus/oidc/client/OidcClientPasswordGrantSecretIsMissingTestCase.java
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,48 @@ | ||
package io.quarkus.oidc.client; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.runtime.configuration.ConfigurationException; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class OidcClientPasswordGrantSecretIsMissingTestCase { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addAsResource(new StringAsset( | ||
"quarkus.oidc-client.token-path=http://localhost:8180/oidc/tokens\n" | ||
+ "quarkus.oidc-client.client-id=quarkus\n" | ||
+ "quarkus.oidc-client.credentials.secret=secret\n" | ||
+ "quarkus.oidc-client.grant.type=password\n" | ||
+ "quarkus.oidc-client.grant-options.password.user=alice\n"), | ||
"application.properties")) | ||
.assertException(t -> { | ||
Throwable e = t; | ||
ConfigurationException te = null; | ||
while (e != null) { | ||
if (e instanceof ConfigurationException) { | ||
te = (ConfigurationException) e; | ||
break; | ||
} | ||
e = e.getCause(); | ||
} | ||
assertNotNull(te); | ||
assertTrue( | ||
te.getMessage() | ||
.contains("Username and password must be set when a password grant is used"), | ||
te.getMessage()); | ||
}); | ||
|
||
@Test | ||
public void test() { | ||
Assertions.fail(); | ||
} | ||
|
||
} |
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