use of software.amazon.awssdk.services.cognitoidentityprovider.model.GetUserResponse in project formkiq-core by formkiq.
the class CognitoService method getUser.
/**
* Get User.
*
* @param token {@link AuthenticationResultType}.
* @return {@link GetUserResponse}
*/
public GetUserResponse getUser(final AuthenticationResultType token) {
GetUserRequest req = GetUserRequest.builder().accessToken(token.accessToken()).build();
GetUserResponse resp = this.cognitoProvider.getUser(req);
return resp;
}
use of software.amazon.awssdk.services.cognitoidentityprovider.model.GetUserResponse in project formkiq-core by formkiq.
the class AwsResourceTest method testAdminAddUserToGroup.
/**
* Test Having Admin add new user to group.
*/
@Test(timeout = TEST_TIMEOUT)
public void testAdminAddUserToGroup() {
// given
String email = UUID.randomUUID() + "@formkiq.com";
String group = getParameterStoreValue("/formkiq/" + getAppenvironment() + "/cognito/AdminGroup");
Credentials cred = getAdminCognitoService().getCredentials(getAdminToken());
AwsCredentials basic = AwsSessionCredentials.create(cred.accessKeyId(), cred.secretKey(), cred.sessionToken());
CognitoConnectionBuilder userBuilder = createCognitoConnectionBuilder().setCredentials(StaticCredentialsProvider.create(basic));
CognitoService userCognitoService = new CognitoService(userBuilder);
// when
GetUserResponse user = userCognitoService.getUser(getAdminToken());
userCognitoService.addUser(email, USER_TEMP_PASSWORD);
userCognitoService.addUserToGroup(email, group);
// then
assertNotNull(user.username());
assertEquals("testadminuser@formkiq.com", user.userAttributes().stream().filter(f -> f.name().equals("email")).findFirst().get().value());
}
Aggregations