use of com.salesmanager.shop.store.security.AuthenticationRequest in project shopizer by shopizer-ecommerce.
the class ServicesTestSupport method getHeader.
protected HttpHeaders getHeader(final String userName, final String password) {
final ResponseEntity<AuthenticationResponse> response = testRestTemplate.postForEntity("/api/v1/private/login", new HttpEntity<>(new AuthenticationRequest(userName, password)), AuthenticationResponse.class);
final HttpHeaders headers = new HttpHeaders();
headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8")));
headers.add("Authorization", "Bearer " + response.getBody().getToken());
return headers;
}
use of com.salesmanager.shop.store.security.AuthenticationRequest in project shopizer by shopizer-ecommerce.
the class CustomerRegistrationIntegrationTest method registerCustomer.
@Test
public void registerCustomer() {
final PersistableCustomer testCustomer = new PersistableCustomer();
testCustomer.setEmailAddress("customer1@test.com");
testCustomer.setPassword("clear123");
testCustomer.setGender(CustomerGender.M.name());
testCustomer.setLanguage("en");
final Address billing = new Address();
billing.setFirstName("customer1");
billing.setLastName("ccstomer1");
billing.setCountry("BE");
testCustomer.setBilling(billing);
testCustomer.setStoreCode(Constants.DEFAULT_STORE);
final HttpEntity<PersistableCustomer> entity = new HttpEntity<>(testCustomer, getHeader());
final ResponseEntity<PersistableCustomer> response = testRestTemplate.postForEntity("/api/v1/customer/register", entity, PersistableCustomer.class);
assertThat(response.getStatusCode(), is(OK));
// created customer can login
final ResponseEntity<AuthenticationResponse> loginResponse = testRestTemplate.postForEntity("/api/v1/customer/login", new HttpEntity<>(new AuthenticationRequest("customer1@test.com", "clear123")), AuthenticationResponse.class);
assertThat(loginResponse.getStatusCode(), is(OK));
assertNotNull(loginResponse.getBody().getToken());
}
Aggregations