Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jans auth server client registration language metadata #1237

Merged
merged 20 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5e592f8
feat(jans-auth-server): auth server should support client registratio…
qbert2k Apr 6, 2022
ebd1c5f
feat(jans-auth-server): auth server should support client registratio…
qbert2k Apr 6, 2022
055e4df
Merge remote-tracking branch 'origin/main' into jans-auth-server-clie…
qbert2k Apr 7, 2022
0af9229
feat(jans-auth-server): auth server should support client registratio…
qbert2k Apr 7, 2022
1699225
feat(jans-auth-server): auth server should support client registratio…
qbert2k Apr 18, 2022
c3bca57
Merge remote-tracking branch 'origin/main' into jans-auth-server-clie…
qbert2k Apr 18, 2022
7313f96
Merge remote-tracking branch 'origin/main' into jans-auth-server-clie…
qbert2k Apr 19, 2022
6612b1f
feat(jans-auth-server): auth server should support client registratio…
qbert2k Apr 25, 2022
7d603ba
feat(jans-auth-server): auth server should support client registratio…
qbert2k Apr 25, 2022
acf6bb3
feat(jans-auth-server): auth server should support client registratio…
qbert2k Apr 26, 2022
82cdfd3
Merge remote-tracking branch 'origin/main' into jans-auth-server-clie…
qbert2k Apr 26, 2022
8dab44e
feat(jans-auth-server): auth server should support client registratio…
qbert2k Apr 27, 2022
17e5f78
feat(jans-auth-server): auth server should support client registratio…
qbert2k Apr 27, 2022
5a5ab46
feat(jans-auth-server): auth server should support client registratio…
qbert2k Apr 27, 2022
9af2ff1
feat(jans-auth-server): auth server should support client registratio…
qbert2k Apr 27, 2022
afb10f5
feat(jans-auth-server): auth server should support client registratio…
qbert2k Apr 27, 2022
e15f106
Merge remote-tracking branch 'origin/main' into jans-auth-server-clie…
qbert2k May 5, 2022
6e2cd7b
fix sonar: duplicated lines
qbert2k May 10, 2022
0052275
Merge remote-tracking branch 'origin/main' into jans-auth-server-clie…
qbert2k May 11, 2022
a01691d
Merge remote-tracking branch 'origin/main' into jans-auth-server-clie…
qbert2k May 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text.
*
* Copyright (c) 2020, Janssen Project
*/

package io.jans.as.client.client;

import io.jans.as.client.*;
Expand Down Expand Up @@ -25,6 +31,10 @@ public static UserInfoResponseAssertBuilder userInfoResponse(UserInfoResponse re
return new UserInfoResponseAssertBuilder(response);
}

public static ClientInfoResponseAssertBuilder clientInfoResponse(ClientInfoResponse response) {
return new ClientInfoResponseAssertBuilder(response);
}

public static BackchannelAuthenticationResponseAssertBuilder backchannelAuthenticationResponse(BackchannelAuthenticationResponse response) {
return new BackchannelAuthenticationResponseAssertBuilder(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,44 @@
import io.jans.as.client.RegisterResponse;
import io.jans.as.model.register.RegisterRequestParam;

import java.util.Arrays;

import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;

/**
* @author Yuriy Zabrovarnyy
* @author Javier Rojas Blum
* @version February 11, 2022
* @version April 6, 2022
*/

public class Asserter {

private Asserter() {

}

public static void assertRegisterResponseClaimsNotNull(RegisterResponse response, RegisterRequestParam... claimsToVerify) {
if (response == null || claimsToVerify == null) {
return;
}
for (RegisterRequestParam claim : claimsToVerify) {
assertNotNull(response.getClaims().get(claim.toString()), "Claim " + claim.toString() + " is null in response claims - code" + response.getEntity());
assertNotNull(response.getClaims().get(claim.toString()), "Claim " + claim + " is null in response claims - code" + response.getEntity());
}
}

public static void assertRegisterResponseClaimsNotNull(RegisterResponse response, String... claimsToVerify) {
if (response == null || claimsToVerify == null) {
return;
}
Arrays.stream(claimsToVerify).forEach(
claim -> assertNotNull(response.getClaims().get(claim), "Claim " + claim + " is null in response claims - code" + response.getEntity()));
}

public static void assertRegisterResponseClaimsAreContained(RegisterResponse response, RegisterRequestParam... claimsToVerify) {
if (response == null || claimsToVerify == null) {
return;
}
for (RegisterRequestParam claim : claimsToVerify) {
assertTrue(response.getClaims().containsKey(claim.toString()), "Claim " + claim.toString() + " is not contained in response claims - code" + response.getEntity());
assertTrue(response.getClaims().containsKey(claim.toString()), "Claim " + claim + " is not contained in response claims - code" + response.getEntity());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text.
*
* Copyright (c) 2020, Janssen Project
*/

package io.jans.as.client.client.assertbuilders;

import io.jans.as.client.ClientInfoResponse;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;

/**
* @author Javier Rojas Blum
* @version April 6, 2022
*/
public class ClientInfoResponseAssertBuilder extends BaseAssertBuilder {

private final ClientInfoResponse response;
private int status;
private boolean notNullClientInfoClaims;
private String[] claimsPresence;

public ClientInfoResponseAssertBuilder(ClientInfoResponse response) {
this.response = response;
this.status = 200;
this.notNullClientInfoClaims = false;
}

public ClientInfoResponseAssertBuilder status(int status) {
this.status = status;
return this;
}

public ClientInfoResponseAssertBuilder notNullClientInfoClaims() {
this.notNullClientInfoClaims = true;
return this;
}

public ClientInfoResponseAssertBuilder claimsPresence(String... claimsPresence) {
if (this.claimsPresence != null) {
List<String> listClaims = new ArrayList<>();
listClaims.addAll(Arrays.asList(this.claimsPresence));
listClaims.addAll(Arrays.asList(claimsPresence));
this.claimsPresence = listClaims.toArray(new String[0]);
} else {
this.claimsPresence = claimsPresence;
}
return this;
}

@Override
public void check() {
assertNotNull(response, "ClientInfoResponse is null");

if (status == 200) {
assertEquals(response.getStatus(), status, "Unexpected response code: " + response.getEntity());

if (notNullClientInfoClaims) {
assertNotNull(response.getClaim("name"), "Unexpected result: displayName not found");
assertNotNull(response.getClaim("inum"), "Unexpected result: inum not found");
assertNotNull(response.getClaim("jansAppType"), "Unexpected result: jansAppTyp not found");
assertNotNull(response.getClaim("jansIdTknSignedRespAlg"), "Unexpected result: jansIdTknSignedRespAlg not found");
assertNotNull(response.getClaim("jansRedirectURI"), "Unexpected result: jansRedirectURI not found");
assertNotNull(response.getClaim("jansScope"), "Unexpected result: jansScope not found");
}
}

if (claimsPresence != null) {
for (String claim : claimsPresence) {
assertNotNull(claim, "Claim name is null");
assertNotNull(response.getClaim(claim), "ClientInfo Claim " + claim + " is not found");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ public void acrAliasTest(

@Parameters({"userId", "userSecret", "redirectUris", "redirectUri", "sectorIdentifierUri"})
@Test
public void acrAliasAuthorizedAcsValuesTest(
public void acrAliasAuthorizedAcrValuesTest(
final String userId, final String userSecret, final String redirectUris, final String redirectUri,
final String sectorIdentifierUri) {
showTitle("acrAliasAuthorizedAcsValuesTest");
showTitle("acrAliasAuthorizedAcrValuesTest");

List<ResponseType> responseTypes = Arrays.asList(ResponseType.CODE, ResponseType.ID_TOKEN);

Expand Down
Loading