use of com.hw.helper.Client in project mt-auth by publicdevop2019.
the class ClientUtility method getClientAsResource.
public static Client getClientAsResource(String... resourceIds) {
Client client = getClientRaw(resourceIds);
client.setResourceIndicator(true);
Set<ClientType> strings = new HashSet<>();
strings.add(ClientType.BACKEND_APP);
strings.add(ClientType.FIRST_PARTY);
client.setTypes(strings);
return client;
}
use of com.hw.helper.Client in project mt-auth by publicdevop2019.
the class ClientUtility method createClient.
public static ResponseEntity<String> createClient(Client client, String changeId) {
ResponseEntity<DefaultOAuth2AccessToken> jwtPasswordAdmin = UserUtility.getJwtPasswordAdmin();
String bearer = jwtPasswordAdmin.getBody().getValue();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.setBearerAuth(bearer);
headers.set("changeId", changeId);
headers.set("X-XSRF-TOKEN", "123");
headers.add(HttpHeaders.COOKIE, "XSRF-TOKEN=123");
HttpEntity<Client> request = new HttpEntity<>(client, headers);
return TestContext.getRestTemplate().exchange(CLIENT_MNGMT_URL, HttpMethod.POST, request, String.class);
}
use of com.hw.helper.Client in project mt-auth by publicdevop2019.
the class ClientUtility method createClient.
public static ResponseEntity<String> createClient(Client client) {
ResponseEntity<DefaultOAuth2AccessToken> jwtPasswordAdmin = UserUtility.getJwtPasswordAdmin();
String bearer = jwtPasswordAdmin.getBody().getValue();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.setBearerAuth(bearer);
HttpEntity<Client> request = new HttpEntity<>(client, headers);
return TestContext.getRestTemplate().exchange(CLIENT_MNGMT_URL, HttpMethod.POST, request, String.class);
}
use of com.hw.helper.Client in project mt-auth by publicdevop2019.
the class ClientUtility method getClientAsNonResource.
/**
* get client as non resource.
*
* @return different GRANT_TYPE_PASSWORD client obj
*/
public static Client getClientAsNonResource(String... resourceIds) {
Client client = getClientRaw(resourceIds);
client.setResourceIndicator(false);
Set<ClientType> types = new HashSet<>();
types.add(ClientType.BACKEND_APP);
types.add(ClientType.FIRST_PARTY);
client.setTypes(types);
return client;
}
use of com.hw.helper.Client in project mt-auth by publicdevop2019.
the class BizClientIdempotentTest method create_client_w_same_changeId_two_times.
@Test
public void create_client_w_same_changeId_two_times() {
Client oldClient = action.getClientAsResource(CLIENT_ID_RESOURCE_ID);
String s = UUID.randomUUID().toString();
ResponseEntity<String> client1 = action.createClient(oldClient, s);
Assert.assertEquals(HttpStatus.OK, client1.getStatusCode());
ResponseEntity<String> client2 = action.createClient(oldClient, s);
Assert.assertEquals(HttpStatus.OK, client2.getStatusCode());
}
Aggregations