diff --git a/server/src/main/java/access/model/User.java b/server/src/main/java/access/model/User.java index 49694c31..dc1e9557 100644 --- a/server/src/main/java/access/model/User.java +++ b/server/src/main/java/access/model/User.java @@ -21,6 +21,7 @@ @NoArgsConstructor @Getter @Setter +@SuppressWarnings("unchecked") public class User implements Serializable, Provisionable { @Id @@ -89,7 +90,7 @@ public User(boolean superUser, Map attributes) { this.email = (String) attributes.get("email"); this.givenName = (String) attributes.get("given_name"); this.familyName = (String) attributes.get("family_name"); - this.institutionAdmin = (boolean) attributes.get(INSTITUTION_ADMIN); + this.institutionAdmin = (boolean) attributes.getOrDefault(INSTITUTION_ADMIN, false); this.organizationGUID = (String) attributes.get(ORGANIZATION_GUID); this.applications = (List>) attributes.getOrDefault(APPLICATIONS, Collections.emptyList()); this.createdAt = Instant.now(); @@ -175,7 +176,7 @@ public void updateAttributes(Map attributes) { this.givenName = (String) attributes.get("given_name"); this.familyName = (String) attributes.get("family_name"); this.email = (String) attributes.get("email"); - this.institutionAdmin = (boolean) attributes.get(INSTITUTION_ADMIN); + this.institutionAdmin = (boolean) attributes.getOrDefault(INSTITUTION_ADMIN, false); this.organizationGUID = (String) attributes.get(ORGANIZATION_GUID); this.applications = (List>) attributes.getOrDefault(APPLICATIONS, Collections.emptyList()); this.lastActivity = Instant.now(); diff --git a/server/src/test/java/access/api/UserControllerTest.java b/server/src/test/java/access/api/UserControllerTest.java index 0b2ed13a..471b018c 100644 --- a/server/src/test/java/access/api/UserControllerTest.java +++ b/server/src/test/java/access/api/UserControllerTest.java @@ -92,6 +92,8 @@ void meWithOauth2Login() throws Exception { @Test void institutionAdminProvision() throws Exception { + super.stubForManageProviderByOrganisationGUID(ORGANISATION_GUID); + AccessCookieFilter accessCookieFilter = openIDConnectFlow("/api/v1/users/me", "new_institution_admin", s -> { }, m -> { @@ -102,7 +104,6 @@ void institutionAdminProvision() throws Exception { )); return m; }); - super.stubForManageProviderByOrganisationGUID(ORGANISATION_GUID); User user = given() .when()