Skip to content

Commit 73e6dbe

Browse files
committed
Additional API support for #685
1 parent b530e41 commit 73e6dbe

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

server/src/main/java/invite/crm/CRMController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public ResponseEntity<ProfileResponse> query(@RequestParam(value = "uid", requir
221221
.map(userRoles -> userRoles.stream().map(userRole -> userRole.getUser()).toList())
222222
.orElse(Collections.emptyList());
223223
} else {
224-
users = Collections.emptyList();
224+
users = userRepository.findByOrganisationNotNull();
225225
}
226226
if (users.isEmpty()) {
227227
LOG.debug("Returning empty results query for profiles");

server/src/main/java/invite/repository/UserRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public interface UserRepository extends JpaRepository<User, Long>, QueryRewriter
2424

2525
List<User> findByUid(String uid);
2626

27+
List<User> findByOrganisationNotNull();
28+
2729
Optional<User> findByCrmContactIdAndOrganisation(String crmContactId, Organisation organisation);
2830

2931
List<User> findByOrganisation(Organisation organisation);

server/src/test/java/invite/crm/CRMControllerTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,30 @@ void profileWithUid() {
613613
assertEquals(SUPER_ADMIN_NAME, authorisation.role());
614614
}
615615

616+
@Test
617+
void profileWithNoParameters() {
618+
this.seedCRMData();
619+
ProfileResponse profileResponse = given()
620+
.when()
621+
.header(API_KEY_HEADER, "secret")
622+
.accept(ContentType.JSON)
623+
.contentType(ContentType.JSON)
624+
.get("/api/profile")
625+
.as(new TypeRef<>() {
626+
});
627+
assertEquals(0, profileResponse.code());
628+
assertEquals("OK", profileResponse.message());
629+
assertEquals(1, profileResponse.profiles().size());
630+
631+
Profile profile = profileResponse.profiles().getFirst();
632+
assertEquals(CRM_ORGANIZATION_ID, profile.organisation().get("guid"));
633+
assertEquals(1, profile.authorisations().size());
634+
635+
Authorisation authorisation = profile.authorisations().getFirst();
636+
assertEquals("SUPER_ADMIN", authorisation.abbbrevation());
637+
assertEquals(SUPER_ADMIN_NAME, authorisation.role());
638+
}
639+
616640
@Test
617641
void profileWithRoleName() {
618642
this.seedCRMData();
@@ -728,6 +752,7 @@ void emptyProfile() {
728752
.auth().preemptive().basic("pdp", "secret")
729753
.accept(ContentType.JSON)
730754
.contentType(ContentType.JSON)
755+
.queryParam("uid", "nope")
731756
.get("/api/external/v1/invite/crm/profile")
732757
.as(new TypeRef<>() {
733758
});

0 commit comments

Comments
 (0)