private String getArkaneAccessTokenWithoutCheck(KeycloakAuthenticationToken principal) { KeycloakAuthenticationToken authToken = principal; return keycloakRepository.getAccessToken(authToken, Provider.ARKANE); }
@Override public String getArkaneAccessToken(KeycloakAuthenticationToken principal) { if (getUserProfile(principal).getArkane() == null) { return null; } return keycloakRepository.getAccessToken(principal, Provider.ARKANE); }
@Test void getProfileWithWallets() { KeycloakAuthenticationToken principal = new KeycloakAuthenticationToken(new KeycloakAccount() { @Override public Principal getPrincipal() { return () -> "davy"; } @Override public Set<String> getRoles() { return null; } }, true); UserRepresentation userRepresentation = new UserRepresentation(); when(keycloakRepository.getUser("davy")).thenReturn(userRepresentation); when(keycloakRepository.getAccessToken(principal, Provider.ARKANE)).thenReturn("token"); Wallet expectedWallet = WalletMother.aWallet(); when(keycloakRepository.getUserIdentities("davy")).thenReturn(Stream.of(UserIdentity.builder().provider(Provider.ARKANE).build())); WalletsResult walletsResult = new WalletsResult(); walletsResult.setResult(Collections.singletonList(expectedWallet)); when(arkaneRepository.getWallets("Bearer token")).thenReturn(walletsResult); UserProfile profile = profileService.getUserProfile(principal); assertThat(profile.getWallets()).containsExactly(expectedWallet); } }