@Test public void testGetIntercomSettings() throws Exception { String name = "test_user"; String email = "test@staffjoy.xyz"; Instant memberSince = Instant.now().minus(100, ChronoUnit.DAYS); AccountDto accountDto = AccountDto.builder() .id(TestConfig.TEST_USER_ID) .name(name) .email(email) .memberSince(memberSince) .phoneNumber("18001112222") .confirmedAndActive(true) .photoUrl("http: .build(); when(accountClient.getAccount(AuthConstant.AUTHORIZATION_WHOAMI_SERVICE, TestConfig.TEST_USER_ID)) .thenReturn(new GenericAccountResponse(accountDto)); GetIntercomSettingResponse getIntercomSettingResponse = whoAmIClient.getIntercomSettings(AuthConstant.AUTHORIZATION_AUTHENTICATED_USER); log.info(getIntercomSettingResponse.toString()); assertThat(getIntercomSettingResponse.isSuccess()).isTrue(); IntercomSettingsDto intercomSettingsDto = getIntercomSettingResponse.getIntercomSettings(); assertThat(intercomSettingsDto.getAppId()).isEqualTo(appProps.getIntercomAppId()); assertThat(intercomSettingsDto.getName()).isEqualTo(name); assertThat(intercomSettingsDto.getEmail()).isEqualTo(email); assertThat(intercomSettingsDto.getUserId()).isEqualTo(TestConfig.TEST_USER_ID); assertThat(intercomSettingsDto.getCreatedAt()).isEqualTo(memberSince); assertThat(intercomSettingsDto.getUserHash()) .isEqualTo(Hash.encode(appProps.getIntercomSigningSecret(), TestConfig.TEST_USER_ID)); }
@Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) @GetMapping(value = "/intercom") public GetIntercomSettingResponse getIntercomSettings() { String userId = AuthContext.getUserId(); IntercomSettingsDto intercomSettingsDto = whoAmIService.findIntercomSettings(userId); return new GetIntercomSettingResponse(intercomSettingsDto); }
WhoAmIController { @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) @GetMapping(value = "/intercom") public GetIntercomSettingResponse getIntercomSettings() { String userId = AuthContext.getUserId(); IntercomSettingsDto intercomSettingsDto = whoAmIService.findIntercomSettings(userId); return new GetIntercomSettingResponse(intercomSettingsDto); } }
WhoAmIController { @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) @GetMapping(value = "/intercom") public GetIntercomSettingResponse getIntercomSettings() { String userId = AuthContext.getUserId(); IntercomSettingsDto intercomSettingsDto = whoAmIService.findIntercomSettings(userId); return new GetIntercomSettingResponse(intercomSettingsDto); }  }
WhoAmIController { @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) @GetMapping(value = "/intercom") public GetIntercomSettingResponse getIntercomSettings() { String userId = AuthContext.getUserId(); IntercomSettingsDto intercomSettingsDto = whoAmIService.findIntercomSettings(userId); return new GetIntercomSettingResponse(intercomSettingsDto); }  @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) @GetMapping FindWhoAmIResponse findWhoAmI(); @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) @GetMapping(value = "/intercom") GetIntercomSettingResponse getIntercomSettings(); }
WhoAmIController { @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) @GetMapping(value = "/intercom") public GetIntercomSettingResponse getIntercomSettings() { String userId = AuthContext.getUserId(); IntercomSettingsDto intercomSettingsDto = whoAmIService.findIntercomSettings(userId); return new GetIntercomSettingResponse(intercomSettingsDto); }  @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) @GetMapping FindWhoAmIResponse findWhoAmI(); @Authorize(value = { AuthConstant.AUTHORIZATION_AUTHENTICATED_USER, AuthConstant.AUTHORIZATION_SUPPORT_USER }) @GetMapping(value = "/intercom") GetIntercomSettingResponse getIntercomSettings();  }