use of com.hw.helper.PendingResourceOwner in project mt-auth by publicdevop2019.
the class UserUtility method enterActivationCode.
public static ResponseEntity<DefaultOAuth2AccessToken> enterActivationCode(User user, String registerToken, PendingResourceOwner pendingResourceOwner) {
HttpHeaders headers1 = new HttpHeaders();
headers1.setContentType(MediaType.APPLICATION_JSON);
headers1.setBearerAuth(registerToken);
headers1.set("changeId", UUID.randomUUID().toString());
pendingResourceOwner.setPassword(user.getPassword());
pendingResourceOwner.setActivationCode("123456");
HttpEntity<PendingResourceOwner> request1 = new HttpEntity<>(pendingResourceOwner, headers1);
return TestContext.getRestTemplate().exchange(UrlUtility.getAccessUrl("/users"), HttpMethod.POST, request1, DefaultOAuth2AccessToken.class);
}
use of com.hw.helper.PendingResourceOwner in project mt-auth by publicdevop2019.
the class UserUtility method createPendingUser.
public static ResponseEntity<Void> createPendingUser(User user, String registerToken, PendingResourceOwner pendingResourceOwner) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.setBearerAuth(registerToken);
headers.set("changeId", UUID.randomUUID().toString());
pendingResourceOwner.setEmail(user.getEmail());
pendingResourceOwner.setMobileNumber(user.getMobileNumber());
pendingResourceOwner.setCountryCode(user.getCountryCode());
HttpEntity<PendingResourceOwner> request = new HttpEntity<>(pendingResourceOwner, headers);
return TestContext.getRestTemplate().exchange(UrlUtility.getAccessUrl("/pending-users"), HttpMethod.POST, request, Void.class);
}
use of com.hw.helper.PendingResourceOwner in project mt-auth by publicdevop2019.
the class UserApiSecurityTest method should_not_able_to_create_user_w_client_missing_right_role.
@Test
public void should_not_able_to_create_user_w_client_missing_right_role() {
User user = UserUtility.createUser();
ResponseEntity<DefaultOAuth2AccessToken> registerTokenResponse = OAuth2Utility.getOAuth2ClientCredentialToken(CLIENT_ID_RIGHT_ROLE_NOT_SUFFICIENT_RESOURCE_ID, EMPTY_CLIENT_SECRET);
String value = registerTokenResponse.getBody().getValue();
ResponseEntity<Void> pendingUser = UserUtility.createPendingUser(user, value, new PendingResourceOwner());
Assert.assertEquals(HttpStatus.FORBIDDEN, pendingUser.getStatusCode());
}
use of com.hw.helper.PendingResourceOwner in project mt-auth by publicdevop2019.
the class UserUtility method register.
public static ResponseEntity<DefaultOAuth2AccessToken> register(User user) {
ResponseEntity<DefaultOAuth2AccessToken> registerTokenResponse = OAuth2Utility.getOAuth2ClientCredentialToken(CLIENT_ID_REGISTER_ID, EMPTY_CLIENT_SECRET);
PendingResourceOwner pendingResourceOwner = new PendingResourceOwner();
createPendingUser(user, registerTokenResponse.getBody().getValue(), pendingResourceOwner);
return enterActivationCode(user, registerTokenResponse.getBody().getValue(), pendingResourceOwner);
}
use of com.hw.helper.PendingResourceOwner in project mt-auth by publicdevop2019.
the class BizUserApiSecurityTest method should_not_able_to_create_user_w_client_missing_right_role.
@Test
public void should_not_able_to_create_user_w_client_missing_right_role() throws JsonProcessingException {
ResourceOwner user = action.randomCreateUserDraft();
ResponseEntity<DefaultOAuth2AccessToken> registerTokenResponse = action.getJwtClientCredential(CLIENT_ID_RIGHT_ROLE_NOT_SUFFICIENT_RESOURCE_ID, EMPTY_CLIENT_SECRET);
String value = registerTokenResponse.getBody().getValue();
ResponseEntity<Void> pendingUser = action.createPendingUser(user, value, new PendingResourceOwner());
Assert.assertEquals(HttpStatus.FORBIDDEN, pendingUser.getStatusCode());
}
Aggregations