Here are the examples of the java api org.springframework.http.HttpStatus.NO_CONTENT taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
613 Examples
19
View Source File : UserController.java
License : Apache License 2.0
Project Creator : zhuoqianmingyue
License : Apache License 2.0
Project Creator : zhuoqianmingyue
/**
* 删除用户
*/
@DeleteMapping("/{id}")
public ResponseEnreplacedy<Void> delete(@PathVariable("id") Long id) {
log.info("删除用户成功:" + "id:{}", id);
return ResponseEnreplacedy.status(HttpStatus.NO_CONTENT).build();
}
19
View Source File : ResponseEntityPro.java
License : Apache License 2.0
Project Creator : yujunhao8831
License : Apache License 2.0
Project Creator : yujunhao8831
public static <T> ResponseEnreplacedy<T> noContent(final T body, final String filterFields) {
if (null == filterFields || WILDCARD_ALL.equals(filterFields)) {
return noContent(body);
}
return status(HttpStatus.NO_CONTENT, body, filterFields);
}
19
View Source File : ResponseEntityPro.java
License : Apache License 2.0
Project Creator : yujunhao8831
License : Apache License 2.0
Project Creator : yujunhao8831
public static ResponseEnreplacedy<String> noContent() {
return status(HttpStatus.NO_CONTENT, HttpStatus.NO_CONTENT.getReasonPhrase());
}
19
View Source File : ResponseEntityPro.java
License : Apache License 2.0
Project Creator : yujunhao8831
License : Apache License 2.0
Project Creator : yujunhao8831
public static <T> ResponseEnreplacedy<T> noContent(final T body) {
return status(HttpStatus.NO_CONTENT, body);
}
19
View Source File : HttpTunnelServerTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
private void testHttpConnectionNonAsync(long sleepBeforeResponse) throws IOException, InterruptedException {
ServerHttpRequest request = mock(ServerHttpRequest.clreplaced);
given(request.getAsyncRequestControl(this.response)).willThrow(new IllegalArgumentException());
final HttpConnection connection = new HttpConnection(request, this.response);
final AtomicBoolean responded = new AtomicBoolean();
Thread connectionThread = new Thread(() -> {
connection.waitForResponse();
responded.set(true);
});
connectionThread.start();
replacedertThat(responded.get()).isFalse();
Thread.sleep(sleepBeforeResponse);
connection.respond(HttpStatus.NO_CONTENT);
connectionThread.join();
replacedertThat(responded.get()).isTrue();
}
19
View Source File : HttpTunnelConnectionTests.java
License : Apache License 2.0
Project Creator : yuanmabiji
License : Apache License 2.0
Project Creator : yuanmabiji
@Test
public void trafficWithLongPollTimeouts() throws Exception {
for (int i = 0; i < 10; i++) {
this.requestFactory.willRespond(HttpStatus.NO_CONTENT);
}
this.requestFactory.willRespond("hi");
TunnelChannel channel = openTunnel(true);
write(channel, "hello");
replacedertThat(this.incomingData.toString()).isEqualTo("hi");
replacedertThat(this.requestFactory.getExecutedRequests().size()).isGreaterThan(10);
}
19
View Source File : AcceptanceTest.java
License : MIT License
Project Creator : woowacourse-teams
License : MIT License
Project Creator : woowacourse-teams
protected <T> void delete(String path) {
// @formatter:off
given().auth().oauth2(bearerToken).when().delete(path).then().log().all().statusCode(HttpStatus.NO_CONTENT.value());
// @formatter:on
}
19
View Source File : AcceptanceTest.java
License : MIT License
Project Creator : woowacourse-teams
License : MIT License
Project Creator : woowacourse-teams
protected <T> void patch(String path, String inputJson) {
// @formatter:off
given().auth().oauth2(bearerToken).body(inputJson).contentType(MediaType.APPLICATION_JSON_VALUE).accept(MediaType.APPLICATION_JSON_VALUE).when().patch(path).then().log().all().statusCode(HttpStatus.NO_CONTENT.value());
// @formatter:on
}
19
View Source File : AcceptanceTest.java
License : MIT License
Project Creator : woowacourse-teams
License : MIT License
Project Creator : woowacourse-teams
protected <T> void put(String path, String inputJson) {
// @formatter:off
given().auth().oauth2(bearerToken).body(inputJson).contentType(MediaType.APPLICATION_JSON_VALUE).accept(MediaType.APPLICATION_JSON_VALUE).when().put(path).then().log().all().statusCode(HttpStatus.NO_CONTENT.value());
// @formatter:on
}
19
View Source File : RiderAcceptanceTest.java
License : MIT License
Project Creator : woowacourse-teams
License : MIT License
Project Creator : woowacourse-teams
private void fetchDeleteRider(final String resource, final JwtTokenResponse tokenResponse) {
given().header(createTokenHeader(tokenResponse)).when().delete(resource).then().log().all().statusCode(HttpStatus.NO_CONTENT.value());
}
19
View Source File : RaceAcceptanceTest.java
License : MIT License
Project Creator : woowacourse-teams
License : MIT License
Project Creator : woowacourse-teams
void deleteRace(final String resourceLocation, final JwtTokenResponse tokenResponse) {
given().header(createTokenHeader(tokenResponse)).when().delete(resourceLocation).then().log().all().statusCode(HttpStatus.NO_CONTENT.value());
}
19
View Source File : MemberAcceptanceTest.java
License : MIT License
Project Creator : woowacourse-teams
License : MIT License
Project Creator : woowacourse-teams
private void requestDelete(final Long kakaoId) {
given().when().header(createTokenHeader(kakaoId)).delete(RESOURCE_URL).then().log().all().statusCode(HttpStatus.NO_CONTENT.value());
}
19
View Source File : CertificationAcceptanceTest.java
License : MIT License
Project Creator : woowacourse-teams
License : MIT License
Project Creator : woowacourse-teams
private void fetchDeleteCertification(final JwtTokenResponse token, final String resource) {
given().header(createTokenHeader(token)).when().delete(resource).then().log().all().statusCode(HttpStatus.NO_CONTENT.value());
}
19
View Source File : HesperidesScenario.java
License : GNU General Public License v3.0
Project Creator : voyages-sncf-technologies
License : GNU General Public License v3.0
Project Creator : voyages-sncf-technologies
protected void replacedertNoContent() {
replacedertEquals(HttpStatus.NO_CONTENT, testContext.getResponseStatusCode());
}
19
View Source File : AbstractKeycloakIdentityProviderTest.java
License : Apache License 2.0
Project Creator : VonDerBeck
License : Apache License 2.0
Project Creator : VonDerBeck
/**
* replacedigns a user to a group.
* @param headers HttpHeaders including the Authorization header / acces token
* @param realm the realm name
* @param userId the user ID
* @param groupId the group ID
*/
private static void replacedignUserGroup(HttpHeaders headers, String realm, String userId, String groupId) {
ResponseEnreplacedy<String> response = restTemplate.exchange(KEYCLOAK_URL + "/admin/realms/" + realm + "/users/" + userId + "/groups/" + groupId, HttpMethod.PUT, new HttpEnreplacedy<>(headers), String.clreplaced);
replacedertThat(response.getStatusCode(), equalTo(HttpStatus.NO_CONTENT));
}
19
View Source File : AbstractKeycloakIdentityProviderTest.java
License : Apache License 2.0
Project Creator : VonDerBeck
License : Apache License 2.0
Project Creator : VonDerBeck
/**
* Deletes a Keycloak realm.
* @param headers HttpHeaders including the Authorization header / acces token
* @param realm the realm name
*/
private static void deleteRealm(HttpHeaders headers, String realm) {
ResponseEnreplacedy<String> response = restTemplate.exchange(KEYCLOAK_URL + "/admin/realms/" + realm, HttpMethod.DELETE, new HttpEnreplacedy<>(headers), String.clreplaced);
replacedertThat(response.getStatusCode(), equalTo(HttpStatus.NO_CONTENT));
LOG.info("Deleted realm " + realm);
}
19
View Source File : SockJsServiceTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
// SPR-12660
@Test
public void handleInfoOptions() {
this.servletRequest.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS, "Last-Modified");
resetResponseAndHandleRequest("OPTIONS", "/echo/info", HttpStatus.NO_CONTENT);
replacedertNull(this.service.getCorsConfiguration(this.servletRequest));
this.service.setAllowedOrigins(Collections.singletonList("https://mydomain1.com"));
resetResponseAndHandleRequest("OPTIONS", "/echo/info", HttpStatus.NO_CONTENT);
replacedertNull(this.service.getCorsConfiguration(this.servletRequest));
}
19
View Source File : SockJsServiceTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
// SPR-12226 and SPR-12660
@Test
public void handleInfoOptionsWithAllowedOrigin() {
this.servletRequest.setServerName("mydomain2.com");
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain2.com");
this.servletRequest.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET");
this.servletRequest.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS, "Last-Modified");
resetResponseAndHandleRequest("OPTIONS", "/echo/info", HttpStatus.NO_CONTENT);
replacedertNotNull(this.service.getCorsConfiguration(this.servletRequest));
this.service.setAllowedOrigins(Collections.singletonList("http://mydomain1.com"));
resetResponseAndHandleRequest("OPTIONS", "/echo/info", HttpStatus.NO_CONTENT);
replacedertNotNull(this.service.getCorsConfiguration(this.servletRequest));
this.service.setAllowedOrigins(Arrays.asList("http://mydomain1.com", "http://mydomain2.com", "http://mydomain3.com"));
resetResponseAndHandleRequest("OPTIONS", "/echo/info", HttpStatus.NO_CONTENT);
replacedertNotNull(this.service.getCorsConfiguration(this.servletRequest));
this.service.setAllowedOrigins(Collections.singletonList("*"));
resetResponseAndHandleRequest("OPTIONS", "/echo/info", HttpStatus.NO_CONTENT);
replacedertNotNull(this.service.getCorsConfiguration(this.servletRequest));
}
19
View Source File : SockJsServiceTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
// SPR-12283
@Test
public void handleInfoOptionsWithOriginAndCorsHeadersDisabled() {
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "https://mydomain2.com");
this.service.setAllowedOrigins(Collections.singletonList("*"));
this.service.setSuppressCors(true);
this.servletRequest.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS, "Last-Modified");
resetResponseAndHandleRequest("OPTIONS", "/echo/info", HttpStatus.NO_CONTENT);
replacedertNull(this.service.getCorsConfiguration(this.servletRequest));
this.service.setAllowedOrigins(Collections.singletonList("https://mydomain1.com"));
resetResponseAndHandleRequest("OPTIONS", "/echo/info", HttpStatus.FORBIDDEN);
replacedertNull(this.service.getCorsConfiguration(this.servletRequest));
this.service.setAllowedOrigins(Arrays.asList("https://mydomain1.com", "https://mydomain2.com", "http://mydomain3.com"));
resetResponseAndHandleRequest("OPTIONS", "/echo/info", HttpStatus.NO_CONTENT);
replacedertNull(this.service.getCorsConfiguration(this.servletRequest));
}
19
View Source File : XhrReceivingTransportHandler.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Override
protected HttpStatus getResponseStatus() {
return HttpStatus.NO_CONTENT;
}
19
View Source File : DefaultServerResponseBuilderTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void noContent() {
ServerResponse response = ServerResponse.noContent().build();
replacedertEquals(HttpStatus.NO_CONTENT, response.statusCode());
}
19
View Source File : ResponseEntityResultHandlerTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void responseEnreplacedyStatusCode() throws Exception {
ResponseEnreplacedy<Void> value = ResponseEnreplacedy.noContent().build();
MethodParameter returnType = on(TestController.clreplaced).resolveReturnType(enreplacedy(Void.clreplaced));
HandlerResult result = handlerResult(value, returnType);
MockServerWebExchange exchange = MockServerWebExchange.from(get("/path"));
this.resultHandler.handleResult(exchange, result).block(Duration.ofSeconds(5));
replacedertEquals(HttpStatus.NO_CONTENT, exchange.getResponse().getStatusCode());
replacedertEquals(0, exchange.getResponse().getHeaders().size());
replacedertResponseBodyIsEmpty(exchange);
}
19
View Source File : DefaultServerResponseBuilderTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void noContent() {
Mono<ServerResponse> result = ServerResponse.noContent().build();
StepVerifier.create(result).expectNextMatches(response -> HttpStatus.NO_CONTENT.equals(response.statusCode())).expectComplete().verify();
}
19
View Source File : RestTemplateIntegrationTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void getNoContent() {
String s = template.getForObject(baseUrl + "/status/nocontent", String.clreplaced);
replacedertNull("Invalid content", s);
ResponseEnreplacedy<String> enreplacedy = template.getForEnreplacedy(baseUrl + "/status/nocontent", String.clreplaced);
replacedertEquals("Invalid response code", HttpStatus.NO_CONTENT, enreplacedy.getStatusCode());
replacedertNull("Invalid content", enreplacedy.getBody());
}
19
View Source File : HttpMessageConverterExtractorTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void noContent() throws IOException {
HttpMessageConverter<?> converter = mock(HttpMessageConverter.clreplaced);
extractor = new HttpMessageConverterExtractor<>(String.clreplaced, createConverterList(converter));
given(response.getRawStatusCode()).willReturn(HttpStatus.NO_CONTENT.value());
Object result = extractor.extractData(response);
replacedertNull(result);
}
19
View Source File : AsyncRestTemplateIntegrationTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
@Test
public void getNoContent() throws Exception {
Future<ResponseEnreplacedy<String>> responseFuture = template.getForEnreplacedy(baseUrl + "/status/nocontent", String.clreplaced);
ResponseEnreplacedy<String> enreplacedy = responseFuture.get();
replacedertEquals("Invalid response code", HttpStatus.NO_CONTENT, enreplacedy.getStatusCode());
replacedertNull("Invalid content", enreplacedy.getBody());
}
19
View Source File : StatusResultMatchers.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* replacedert the response status code is {@code HttpStatus.NO_CONTENT} (204).
*/
public ResultMatcher isNoContent() {
return matcher(HttpStatus.NO_CONTENT);
}
19
View Source File : StatusAssertions.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
/**
* replacedert the response status code is {@code HttpStatus.NO_CONTENT} (204).
*/
public WebTestClient.ResponseSpec isNoContent() {
return replacedertStatusAndReturn(HttpStatus.NO_CONTENT);
}
19
View Source File : TokenUtilsTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void test_revokePowerToken_success() {
String token = "5PDrOhsy4ig8L3EpsJZSLAMg";
Response res = getMockResponse(HttpStatus.NO_CONTENT, true, "");
when(reqProcessor.process("/auth/tvault/revoke", "{}", token)).thenReturn(res);
tokenUtils.revokePowerToken(token);
}
19
View Source File : SafeUtilsTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void test_updateActivityInfo_success() {
String responseStr = "{\"data\":{" + " \"folderModifiedAt\": 1611148845423," + " \"folderModifiedBy\": \"role1 (AppRole)\"," + " \"folderPath\": \"users/123safe/fld1\"," + " \"secretVersions\": {" + " \"secret2\": [" + " {" + " \"modifiedAt\": 1611148845423," + " \"modifiedBy\": \"role1 (AppRole)\"" + " }" + " ]," + " \"secret3\": [" + " {" + " \"modifiedAt\": 1611148845423," + " \"modifiedBy\": \"role1 (AppRole)\"" + " }" + " ]" + " }" + "}}";
Response response = getMockResponse(HttpStatus.OK, true, responseStr);
String versionFolderPath = "users/123safe/$_versions_fld1";
String path = "users/123safe/fld1";
String token = "5PDrOhsy4ig8L3EpsJZSLAMg";
when(reqProcessor.process("/read", "{\"path\":\"" + versionFolderPath + "\"}", token)).thenReturn(response);
when(ControllerUtil.isPathValid(path)).thenReturn(true);
UserDetails userDetails = getMockUser(false);
when(commonUtils.getModifiedByInfo(userDetails)).thenReturn("username1");
List<String> modifiedKeys = new ArrayList<>();
modifiedKeys.add("secret2");
List<String> deletedKeys = new ArrayList<>();
deletedKeys.add("secret3");
Response expectedResponse = getMockResponse(HttpStatus.NO_CONTENT, true, "");
when(ControllerUtil.isPathValid(Mockito.any())).thenReturn(true);
when(reqProcessor.process(eq("/write"), Mockito.any(), eq(token))).thenReturn(expectedResponse);
Response actualResponse = safeUtils.updateActivityInfo(token, path, userDetails, TVaultConstants.UPDATE_ACTION, modifiedKeys, deletedKeys);
replacedertEquals(expectedResponse.getHttpstatus(), actualResponse.getHttpstatus());
}
19
View Source File : SafeUtilsTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void testCanAddOrRemoveUserFailedSafeMetadataEmpty() {
UserDetails userDetails = getMockUser(false);
SafeUser safeUser = new SafeUser("users/ert", "normaluser1", "write");
Response response = getMockResponse(HttpStatus.NO_CONTENT, true, "{}");
when(ControllerUtil.getSafeType("users/ert")).thenReturn("users");
when(ControllerUtil.getSafeName("users/ert")).thenReturn("ert");
when(ControllerUtil.getReqProcessor().process("/sdb", "{\"path\":\"metadata/users/ert\"}", "5PDrOhsy4ig8L3EpsJZSLAMg")).thenReturn(response);
boolean canAdd = safeUtils.canAddOrRemoveUser(userDetails, safeUser, "addUser");
replacedertFalse(canAdd);
}
19
View Source File : SafeUtilsTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void testGetSafeMetaDataEmpty() {
String responseJson = "{ \"keys\": [ \"mysafe01\" ]}";
Response response = getMockResponse(HttpStatus.NO_CONTENT, true, "{\"data\":{\"aws-roles\":" + "{\"erole\":\"read\",\"role1\":\"read\",\"role22\":\"read\",\"testrole3\":\"read\"}," + "\"description\":\"asd\",\"name\":\"mysafe01\",\"owner\":\"[email protected]\",\"ownerid\":\"normaluser\"," + "\"type\":\"\",\"users\":{\"normaluser\":\"sudo\",\"normaluser2\":\"read\"}}}");
SafeBasicDetails safeBasicDetails = new SafeBasicDetails("mysafe01", "[email protected]", null, "My first safe", "normaluser", "tvt");
Safe safe = new Safe("users/mysafe01", safeBasicDetails);
when(ControllerUtil.getSafeType("users/mysafe01")).thenReturn("users");
when(ControllerUtil.getSafeName("users/mysafe01")).thenReturn("mysafe01");
when(ControllerUtil.getReqProcessor().process("/sdb", "{\"path\":\"metadata/users/mysafe01\"}", "5PDrOhsy4ig8L3EpsJZSLAMg")).thenReturn(response);
Safe safeRes = safeUtils.getSafeMetaData("5PDrOhsy4ig8L3EpsJZSLAMg", "users", "mysafe01");
}
19
View Source File : SafeUtilsTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void test_updateActivityInfo_success_version_data_parse_failed() {
String responseStr = "{\"data1\":{" + " \"folderModifiedAt\": 1611148845423," + " \"folderModifiedBy\": \"role1 (AppRole)\"," + " \"folderPath\": \"users/123safe/fld1\"," + " \"secretVersions\": {" + " \"secret2\": [" + " {" + " \"modifiedAt\": 1611148845423," + " \"modifiedBy\": \"role1 (AppRole)\"" + " }" + " ]," + " \"secret3\": [" + " {" + " \"modifiedAt\": 1611148845423," + " \"modifiedBy\": \"role1 (AppRole)\"" + " }" + " ]" + " }" + "}}";
Response response = getMockResponse(HttpStatus.OK, true, responseStr);
String versionFolderPath = "users/123safe/$_versions_fld1";
String path = "users/123safe/fld1";
String token = "5PDrOhsy4ig8L3EpsJZSLAMg";
when(reqProcessor.process("/read", "{\"path\":\"" + versionFolderPath + "\"}", token)).thenReturn(response);
when(ControllerUtil.isPathValid(path)).thenReturn(true);
UserDetails userDetails = getMockUser(false);
when(commonUtils.getModifiedByInfo(userDetails)).thenReturn("username1");
List<String> modifiedKeys = new ArrayList<>();
modifiedKeys.add("secret2");
List<String> deletedKeys = new ArrayList<>();
deletedKeys.add("secret3");
Response expectedResponse = getMockResponse(HttpStatus.NO_CONTENT, true, "");
when(reqProcessor.process(eq("/write"), Mockito.any(), eq(token))).thenReturn(expectedResponse);
Response actualResponse = safeUtils.updateActivityInfo(token, path, userDetails, TVaultConstants.UPDATE_ACTION, modifiedKeys, deletedKeys);
replacedertEquals(expectedResponse.getHttpstatus(), actualResponse.getHttpstatus());
}
19
View Source File : IAMServiceAccountUtilsTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void test_updateIAMSvcAccNewAccessKeyIdInMetadata_success() {
String iamServiceAccountName = "svc_vault_test5";
String token = "123123123123";
String awsAccountId = "1234567890";
String path = "metadata/iamsvcacc/1234567890_svc_vault_test5";
String iamSecret = "abcdefgh";
String accessKeyId = "testaccesskey";
Response response = getMockResponse(HttpStatus.OK, true, "{ \"data\": {\"secret\": [{\"accessKeyId\": \"testaccesskey\", \"expiryDuration\": 1609668443000}]}}");
when(reqProcessor.process(eq("/read"), Mockito.any(), eq(token))).thenReturn(response);
Response response204 = getMockResponse(HttpStatus.NO_CONTENT, true, "");
when(reqProcessor.process(eq("/write"), Mockito.any(), eq(token))).thenReturn(response204);
IAMServiceAccountSecret iamServiceAccountSecret = new IAMServiceAccountSecret(iamServiceAccountName, accessKeyId, iamSecret, 1609754282000L, awsAccountId);
Response actualResponse = iamServiceAccountUtils.updateIAMSvcAccNewAccessKeyIdInMetadata(token, awsAccountId, iamServiceAccountName, accessKeyId, iamServiceAccountSecret);
replacedertEquals(HttpStatus.NO_CONTENT, actualResponse.getHttpstatus());
}
19
View Source File : IAMServiceAccountUtilsTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void testUpdateIAMSvcAccNewAccessKeyIdInMetadataFailed() {
String iamServiceAccountName = "svc_vault_test5";
String token = "123123123123";
String awsAccountId = "1234567890";
String path = "metadata/iamsvcacc/1234567890_svc_vault_test5";
String iamSecret = "abcdefgh";
String accessKeyId = "testaccesskey";
Response response = getMockResponse(HttpStatus.OK, true, "{ \"data\": {\"secretvals\": [{\"accessKeyId\": \"testaccesskey\", \"expiryDuration\": 1609668443000}]}}");
when(reqProcessor.process(eq("/read"), Mockito.any(), eq(token))).thenReturn(response);
Response response204 = getMockResponse(HttpStatus.NO_CONTENT, true, "");
when(reqProcessor.process(eq("/write"), Mockito.any(), eq(token))).thenReturn(response204);
IAMServiceAccountSecret iamServiceAccountSecret = new IAMServiceAccountSecret(iamServiceAccountName, accessKeyId, iamSecret, 1609754282000L, awsAccountId);
Response actualResponse = iamServiceAccountUtils.updateIAMSvcAccNewAccessKeyIdInMetadata(token, awsAccountId, iamServiceAccountName, accessKeyId, iamServiceAccountSecret);
}
19
View Source File : IAMServiceAccountUtilsTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void test_writeIAMSvcAccSecret_success() {
String iamServiceAccountName = "svc_vault_test5";
String token = "123123123123";
String awsAccountId = "1234567890";
String path = "metadata/iamsvcacc/1234567890_svc_vault_test5";
String iamSecret = "abcdefgh";
String accessKeyId = "testaccesskey";
IAMServiceAccountSecret iamServiceAccountSecret = new IAMServiceAccountSecret(iamServiceAccountName, accessKeyId, iamSecret, 1609754282000L, awsAccountId);
Response response = getMockResponse(HttpStatus.NO_CONTENT, true, "");
when(reqProcessor.process(eq("/write"), Mockito.any(), eq(token))).thenReturn(response);
boolean actualStatus = iamServiceAccountUtils.writeIAMSvcAccSecret(token, path, iamServiceAccountName, iamServiceAccountSecret);
replacedertTrue(actualStatus);
}
19
View Source File : IAMServiceAccountUtilsTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void testUpdateIAMSvcAccNewAccessKeyIdInMetadataFailedNoData() {
String iamServiceAccountName = "svc_vault_test5";
String token = "123123123123";
String awsAccountId = "1234567890";
String path = "metadata/iamsvcacc/1234567890_svc_vault_test5";
String iamSecret = "abcdefgh";
String accessKeyId = "testaccesskey";
Response response = getMockResponse(HttpStatus.OK, true, null);
when(reqProcessor.process(eq("/read"), Mockito.any(), eq(token))).thenReturn(response);
Response response204 = getMockResponse(HttpStatus.NO_CONTENT, true, "");
when(reqProcessor.process(eq("/write"), Mockito.any(), eq(token))).thenReturn(response204);
IAMServiceAccountSecret iamServiceAccountSecret = new IAMServiceAccountSecret(iamServiceAccountName, accessKeyId, iamSecret, 1609754282000L, awsAccountId);
Response actualResponse = iamServiceAccountUtils.updateIAMSvcAccNewAccessKeyIdInMetadata(token, awsAccountId, iamServiceAccountName, accessKeyId, iamServiceAccountSecret);
}
19
View Source File : IAMServiceAccountUtilsTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void testUpdateActivatedStatusInMetadataFailed() {
String iamServiceAccountName = "svc_vault_test5";
String token = "123123123123";
String awsAccountId = "1234567890";
String path = "metadata/iamsvcacc/1234567890_svc_vault_test5";
String iamSecret = "abcdefgh";
String accessKeyId = "testaccesskey";
Response response = getMockResponse(HttpStatus.OK, true, null);
when(reqProcessor.process(eq("/read"), Mockito.any(), eq(token))).thenReturn(response);
Response response204 = getMockResponse(HttpStatus.NO_CONTENT, true, "");
when(reqProcessor.process(eq("/write"), Mockito.any(), eq(token))).thenReturn(response204);
Response actualResponse = iamServiceAccountUtils.updateActivatedStatusInMetadata(token, iamServiceAccountName, awsAccountId);
}
19
View Source File : IAMServiceAccountUtilsTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void testUpdateIAMSvcAccNewAccessKeyIdInMetadataFailedInvalidSecret() {
String iamServiceAccountName = "svc_vault_test5";
String token = "123123123123";
String awsAccountId = "1234567890";
String path = "metadata/iamsvcacc/1234567890_svc_vault_test5";
String iamSecret = "abcdefgh";
String accessKeyId = "testaccesskey1";
Response response = getMockResponse(HttpStatus.OK, true, "{ \"data\": {\"secret\": [{\"accessKeyId\": \"testaccesskey\", \"expiryDuration\": 1609668443000}]}}");
when(reqProcessor.process(eq("/read"), Mockito.any(), eq(token))).thenReturn(response);
Response response204 = getMockResponse(HttpStatus.NO_CONTENT, true, "");
when(reqProcessor.process(eq("/write"), Mockito.any(), eq(token))).thenReturn(response204);
IAMServiceAccountSecret iamServiceAccountSecret = new IAMServiceAccountSecret(iamServiceAccountName, accessKeyId, iamSecret, 1609754282000L, awsAccountId);
Response actualResponse = iamServiceAccountUtils.updateIAMSvcAccNewAccessKeyIdInMetadata(token, awsAccountId, iamServiceAccountName, accessKeyId, iamServiceAccountSecret);
}
19
View Source File : IAMServiceAccountUtilsTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void testUpdateActivatedStatusInMetadataFailedActivated() {
String iamServiceAccountName = "svc_vault_test5";
String token = "123123123123";
String awsAccountId = "1234567890";
String path = "metadata/iamsvcacc/1234567890_svc_vault_test5";
String iamSecret = "abcdefgh";
String accessKeyId = "testaccesskey";
Response response = getMockResponse(HttpStatus.OK, true, "{ \"data\": { \"isActivated\": true}}");
when(reqProcessor.process(eq("/read"), Mockito.any(), eq(token))).thenReturn(response);
Response response204 = getMockResponse(HttpStatus.NO_CONTENT, true, "");
when(reqProcessor.process(eq("/write"), Mockito.any(), eq(token))).thenReturn(response204);
Response actualResponse = iamServiceAccountUtils.updateActivatedStatusInMetadata(token, iamServiceAccountName, awsAccountId);
}
19
View Source File : IAMServiceAccountUtilsTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void testUpdateIAMSvcAccNewAccessKeyIdInMetadataSuccessKeyMsmatch() {
String iamServiceAccountName = "svc_vault_test5";
String token = "123123123123";
String awsAccountId = "1234567890";
String path = "metadata/iamsvcacc/1234567890_svc_vault_test5";
String iamSecret = "abcdefgh";
String accessKeyId = "testaccesskey1";
Response response = getMockResponse(HttpStatus.OK, true, "{ \"data\": {\"secret\": [{\"accessKeyId\": \"testaccesskey\", \"expiryDuration\": 1609668443000}]}}");
when(reqProcessor.process(eq("/read"), Mockito.any(), eq(token))).thenReturn(response);
Response response204 = getMockResponse(HttpStatus.NO_CONTENT, true, "");
when(reqProcessor.process(eq("/write"), Mockito.any(), eq(token))).thenReturn(response204);
IAMServiceAccountSecret iamServiceAccountSecret = new IAMServiceAccountSecret(iamServiceAccountName, accessKeyId, iamSecret, 1609754282000L, awsAccountId);
Response actualResponse = iamServiceAccountUtils.updateIAMSvcAccNewAccessKeyIdInMetadata(token, awsAccountId, iamServiceAccountName, accessKeyId, iamServiceAccountSecret);
replacedertEquals(HttpStatus.NO_CONTENT, actualResponse.getHttpstatus());
}
19
View Source File : IAMServiceAccountUtilsTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void test_updateActivatedStatusInMetadata_success() {
String iamServiceAccountName = "svc_vault_test5";
String token = "123123123123";
String awsAccountId = "1234567890";
String path = "metadata/iamsvcacc/1234567890_svc_vault_test5";
String iamSecret = "abcdefgh";
String accessKeyId = "testaccesskey";
Response response = getMockResponse(HttpStatus.OK, true, "{ \"data\": { \"isActivated\": false}}");
when(reqProcessor.process(eq("/read"), Mockito.any(), eq(token))).thenReturn(response);
Response response204 = getMockResponse(HttpStatus.NO_CONTENT, true, "");
when(reqProcessor.process(eq("/write"), Mockito.any(), eq(token))).thenReturn(response204);
Response actualResponse = iamServiceAccountUtils.updateActivatedStatusInMetadata(token, iamServiceAccountName, awsAccountId);
replacedertEquals(HttpStatus.NO_CONTENT, actualResponse.getHttpstatus());
}
19
View Source File : AzureServiceAccountUtilsTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void testWriteAzureSPSecretSuccess() {
String token = "123123123123";
String path = "metadata/azuresvcacc/svc_vault_test5";
String azureSvcAccName = "svc_vault_test5";
String secretKeyId = "testaccesskey";
String servicePrincipalId = "testservicePrincipalId";
String tenantId = "testtenantId";
String azureSecret = "abcdefgh";
AzureServiceAccountSecret azureServiceAccountSecret = new AzureServiceAccountSecret(secretKeyId, azureSecret, 1609754282000L, "20201215", servicePrincipalId, tenantId);
Response responseData = getMockResponse(HttpStatus.NO_CONTENT, true, "");
when(reqProcessor.process(eq("/write"), Mockito.any(), eq(token))).thenReturn(responseData);
boolean actualStatus = azureServiceAccountUtils.writeAzureSPSecret(token, path, azureSvcAccName, azureServiceAccountSecret);
replacedertTrue(actualStatus);
}
19
View Source File : AzureServiceAccountUtilsTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void testUpdateAzureSPSecretKeyInfoInMetadataSuccess() {
String token = "123123123123";
String azureSvcAccName = "svc_vault_test5";
String secretKeyId = "testaccesskey";
String servicePrincipalId = "testservicePrincipalId";
String tenantId = "testtenantId";
String azureSecret = "abcdefgh";
Response responseData = getMockResponse(HttpStatus.OK, true, "{ \"data\": {\"secret\": [{\"secretKeyId\": \"testaccesskey\", \"expiryDuration\": 1609668443000}]}}");
when(reqProcessor.process(eq("/read"), Mockito.any(), eq(token))).thenReturn(responseData);
Response response204 = getMockResponse(HttpStatus.NO_CONTENT, true, "");
when(reqProcessor.process(eq("/write"), Mockito.any(), eq(token))).thenReturn(response204);
AzureServiceAccountSecret azureServiceAccountSecret = new AzureServiceAccountSecret(secretKeyId, azureSecret, 1609754282000L, "20201215", servicePrincipalId, tenantId);
Response actualResponse = azureServiceAccountUtils.updateAzureSPSecretKeyInfoInMetadata(token, azureSvcAccName, secretKeyId, azureServiceAccountSecret);
replacedertEquals(HttpStatus.NO_CONTENT, actualResponse.getHttpstatus());
}
19
View Source File : AzureServiceAccountUtilsTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void updateAzureSPSecretKeyInfoInMetadata_success() {
String iamServiceAccountName = "svc_vault_test5";
String token = "123123123123";
String awsAccountId = "1234567890";
String path = "metadata/iamsvcacc/1234567890_svc_vault_test5";
String iamSecret = "abcdefgh";
String accessKeyId = "testaccesskey";
String azureSecret = "abcdefgh";
String secretKeyId = "testaccesskey";
Long expiryDateEpoch = 604800000L;
String expiryDate = new Date(604800000L).toString();
String servicePrincipalId = "100";
String tenantId = "101";
Response response = getMockResponse(HttpStatus.OK, true, "{ \"data\": {\"secret\": [{\"secretKeyId\": \"testaccesskey\", \"expiryDuration\": 1609668443000}]}}");
when(reqProcessor.process(eq("/read"), Mockito.any(), eq(token))).thenReturn(response);
Response response204 = getMockResponse(HttpStatus.NO_CONTENT, true, "");
when(reqProcessor.process(eq("/write"), Mockito.any(), eq(token))).thenReturn(response204);
AzureServiceAccountSecret azureServiceAccountSecret = new AzureServiceAccountSecret(azureSecret, azureSecret, expiryDateEpoch, expiryDate, servicePrincipalId, tenantId);
Response actualResponse = azureServiceAccountUtils.updateAzureSPSecretKeyInfoInMetadata(token, iamServiceAccountName, secretKeyId, azureServiceAccountSecret);
replacedertEquals(HttpStatus.NO_CONTENT, actualResponse.getHttpstatus());
}
19
View Source File : AzureServiceAccountUtilsTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void test_updateActivatedStatusInMetadata_success() {
String servicePrincipalName = "svc_vault_test5";
String token = "123123123123";
String awsAccountId = "1234567890";
String path = "metadata/azuresvcacc/1234567890_svc_vault_test5";
String iamSecret = "abcdefgh";
String accessKeyId = "testaccesskey";
Response response = getMockResponse(HttpStatus.OK, true, "{ \"data\": { \"isActivated\": false}}");
when(reqProcessor.process(eq("/read"), Mockito.any(), eq(token))).thenReturn(response);
Response response204 = getMockResponse(HttpStatus.NO_CONTENT, true, "");
when(reqProcessor.process(eq("/write"), Mockito.any(), eq(token))).thenReturn(response204);
Response actualResponse = azureServiceAccountUtils.updateActivatedStatusInMetadata(token, servicePrincipalName);
replacedertEquals(HttpStatus.NO_CONTENT, actualResponse.getHttpstatus());
}
19
View Source File : AzureServiceAccountUtilsTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void test_writeAzureSvcAccSecret_success() {
String iamServiceAccountName = "svc_vault_test5";
String token = "123123123123";
String azureAccountId = "1234567890";
String path = "metadata/iamsvcacc/1234567890_svc_vault_test5";
String azureSecret = "abcdefgh";
String accessKeyId = "testaccesskey";
Long expiryDateEpoch = 604800000L;
String expiryDate = new Date(604800000L).toString();
String servicePrincipalId = "100";
String tenantId = "101";
AzureServiceAccountSecret iamServiceAccountSecret = new AzureServiceAccountSecret(azureSecret, azureSecret, expiryDateEpoch, expiryDate, servicePrincipalId, tenantId);
Response response = getMockResponse(HttpStatus.NO_CONTENT, true, "");
when(reqProcessor.process(eq("/write"), Mockito.any(), eq(token))).thenReturn(response);
boolean actualStatus = azureServiceAccountUtils.writeAzureSPSecret(token, path, iamServiceAccountName, iamServiceAccountSecret);
replacedertTrue(actualStatus);
}
19
View Source File : AzureServiceAccountUtilsTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void testUpdateActivatedStatusInMetadataSuccess() {
String token = "123123123123";
String azureSvcAccName = "svc_vault_test5";
Response responseData = getMockResponse(HttpStatus.OK, true, "{ \"data\": { \"isActivated\": false}}");
when(reqProcessor.process(eq("/read"), Mockito.any(), eq(token))).thenReturn(responseData);
Response response204 = getMockResponse(HttpStatus.NO_CONTENT, true, "");
when(reqProcessor.process(eq("/write"), Mockito.any(), eq(token))).thenReturn(response204);
Response actualResponse = azureServiceAccountUtils.updateActivatedStatusInMetadata(token, azureSvcAccName);
replacedertEquals(HttpStatus.NO_CONTENT, actualResponse.getHttpstatus());
}
19
View Source File : WorkloadDetailsServiceTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void test_udpateApplicationMetadata_success() throws Exception {
List<String> certList = new ArrayList<>();
certList.add("cert1.company.com");
TMOAppMetadataDetails tmoAppMetadataDetails = new TMOAppMetadataDetails("other", "[email protected]", "other", "[email protected]", certList, new ArrayList<>(), true);
TMOAppMetadataDetails tmoAppMetadataDetailsCLM = new TMOAppMetadataDetails("other", "[email protected]", "other", "[email protected]", certList, new ArrayList<>(), true);
Response expectedResponse = new Response();
expectedResponse.setHttpstatus(HttpStatus.NO_CONTENT);
when(reqProcessor.process(eq("/write"), Mockito.any(), eq(token))).thenReturn(expectedResponse);
Response actualResponse = workloadDetailsService.udpateApplicationMetadata(token, tmoAppMetadataDetails, tmoAppMetadataDetailsCLM);
replacedertEquals(expectedResponse.getHttpstatus(), actualResponse.getHttpstatus());
}
19
View Source File : WorkloadDetailsServiceTest.java
License : Apache License 2.0
Project Creator : tmobile
License : Apache License 2.0
Project Creator : tmobile
@Test
public void test_getAllAppMetadata_failed_toReadAppMetadata() throws Exception {
Response listResponse = new Response();
listResponse.setHttpstatus(HttpStatus.OK);
listResponse.setResponse("{ \"data\": { \"keys\": [ \"other\"] } }");
String pathStrForList = "metadata/tmo-applications?list=true";
when(reqProcessor.process("/tmo-applicaions", "{\"path\":\"" + pathStrForList + "\"}", token)).thenReturn(listResponse);
Response readResponse = new Response();
readResponse.setHttpstatus(HttpStatus.NO_CONTENT);
String pathStr = "metadata/tmo-applications/other";
when(reqProcessor.process("/tmo-applicaions", "{\"path\":\"" + pathStr + "\"}", token)).thenReturn(readResponse);
List<String> certList = new ArrayList<>();
certList.add("cert1.company.com");
List<TMOAppMetadataDetails> tmoAppMetadataDetailsList = new ArrayList<>();
List<TMOAppMetadataDetails> appMetadataList = workloadDetailsService.getAllAppMetadata(token);
replacedertEquals(tmoAppMetadataDetailsList, appMetadataList);
}
See More Examples