KEYCLOAK-3707 Test retrieving missing client with registration access token

This commit is contained in:
Stian Thorgersen committed 2016-10-18 20:56:40 +02:00
1 parent d941e07169
commit 3250562d28
1 file changed
+26
@@ -49,6 +49,14 @@ public class RegistrationAccessTokenTest extends AbstractClientRegistrationTest
client = createClient(c);
c = new ClientRepresentation();
c.setEnabled(true);
c.setClientId("SomeOtherClient");
c.setSecret("RegistrationAccessTokenTestClientSecret");
c.setRootUrl("http://root");
createClient(c);
reg.auth(Auth.token(client.getRegistrationAccessToken()));
}
@@ -81,6 +89,24 @@ public class RegistrationAccessTokenTest extends AbstractClientRegistrationTest
assertRead(client.getClientId(), rep.getRegistrationAccessToken(), true);
}
@Test
public void getClientWrongClient() throws ClientRegistrationException {
try {
reg.get("SomeOtherClient");
} catch (ClientRegistrationException e) {
assertEquals(401, ((HttpErrorException) e.getCause()).getStatusLine().getStatusCode());
}
}
@Test
public void getClientMissingClient() throws ClientRegistrationException {
try {
reg.get("nosuch");
} catch (ClientRegistrationException e) {
assertEquals(401, ((HttpErrorException) e.getCause()).getStatusLine().getStatusCode());
}
}
@Test
public void getClientWithBadRegistrationToken() throws ClientRegistrationException {
reg.auth(Auth.token("invalid"));