Skip to content

Commit

Permalink
Create new migrations and add coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
enricovianello committed Jul 1, 2022
1 parent 1a5802d commit 64fdc3f
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ public JsonObject toJson() {
json.remove("groups");
json.remove("organisation_name");

json.add(EDUPERSON_SCOPED_AFFILIATION_CLAIM, new JsonPrimitive(scopedAffiliation));
json.add(EDUPERSON_SCOPED_AFFILIATION_CLAIM, new JsonPrimitive(getScopedAffiliation()));

JsonArray values = new JsonArray();
assurance.forEach(value -> values.add(new JsonPrimitive(value)));
getAssurance().forEach(value -> values.add(new JsonPrimitive(value)));
json.add(EDUPERSON_ASSURANCE_CLAIM, values);

JsonArray urns = new JsonArray();
entitlements.forEach(urn -> urns.add(new JsonPrimitive(urn)));
getEntitlements().forEach(urn -> urns.add(new JsonPrimitive(urn)));
json.add(EDUPERSON_ENTITLEMENT_CLAIM, urns);

return json;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,29 @@ public void testAarcProfileIntrospect() throws Exception {

}

@Test
public void testAarcProfileIntrospectWithoutScopes() throws Exception {

Set<String> scopes = Sets.newHashSet("openid", "profile", "email");
JWT token = JWTParser.parse(getAccessTokenForUser(scopes));

// @formatter:off
mvc.perform(post("/introspect")
.with(httpBasic(CLIENT_ID, CLIENT_SECRET))
.param("token", token.getParsedString()))
.andExpect(status().isOk())
.andExpect(jsonPath("$.active", equalTo(true)))
.andExpect(jsonPath("$." + EDUPERSON_SCOPED_AFFILIATION_CLAIM).doesNotExist())
.andExpect(jsonPath("$." + EDUPERSON_ENTITLEMENT_CLAIM).doesNotExist())
.andExpect(jsonPath("$." + EDUPERSON_ASSURANCE_CLAIM).doesNotExist())
.andExpect(jsonPath("$.name", equalTo("Test User")))
.andExpect(jsonPath("$.given_name", equalTo("Test")))
.andExpect(jsonPath("$.family_name", equalTo("User")))
.andExpect(jsonPath("$.email", equalTo("[email protected]")));
// @formatter:on

}

@Test
@WithMockOAuthUser(clientId = CLIENT_ID, user = USERNAME, authorities = {"ROLE_USER"},
scopes = {"openid profile eduperson_scoped_affiliation eduperson_entitlement eduperson_assurance"})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
INSERT INTO system_scope(scope, description, icon, restricted, default_scope, structured, structured_param_description)
VALUES
('eduperson_scoped_affiliation', 'Access to EduPerson scoped affiliation information', null, false, false, false, null),
('eduperson_entitlement', 'Access to EduPerson entitlements information', null, false, false, false, null),
('eduperson_assurance', 'Access to EduPerson assurance information', null, false, false, false, null);
('eduperson_entitlement', 'Access to EduPerson entitlements information', null, false, false, false, null);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
INSERT INTO system_scope(scope, description, icon, restricted, default_scope, structured, structured_param_description)
VALUES
('eduperson_assurance', 'Access to EduPerson assurance information', null, false, false, false, null);
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
INSERT INTO system_scope(scope, description, icon, restricted, default_scope, structured, structured_param_description)
VALUES
('eduperson_scoped_affiliation', 'Access to EduPerson scoped affiliation information', null, false, false, false, null),
('eduperson_entitlement', 'Access to EduPerson entitlements information', null, false, false, false, null),
('eduperson_assurance', 'Access to EduPerson assurance information', null, false, false, false, null);
('eduperson_entitlement', 'Access to EduPerson entitlements information', null, false, false, false, null);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
INSERT INTO system_scope(scope, description, icon, restricted, default_scope, structured, structured_param_description)
VALUES
('eduperson_assurance', 'Access to EduPerson assurance information', null, false, false, false, null);

0 comments on commit 64fdc3f

Please sign in to comment.