@Test public void test_createSTSRole_successfully() { String token = "5PDrOhsy4ig8L3EpsJZSLAMg"; AWSStsRole awsStsRole = new AWSStsRole(); awsStsRole.setAccount_id("account_id1"); awsStsRole.setSts_role("sts_role1"); String jsonStr = "{ \"account_id\": \"account_id1\", \"sts_role\": \"sts_role1\"}"; Response response = getMockResponse(HttpStatus.NO_CONTENT, true, ""); ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body("{\"messages\":[\"STS Role created successfully \"]}"); when(reqProcessor.process("/auth/aws/config/sts/create",jsonStr, token)).thenReturn(response); when(JSONUtil.getJSON(awsStsRole)).thenReturn(jsonStr); ResponseEntity<String> responseEntity = awsAuthService.createSTSRole(awsStsRole, token); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); assertEquals(responseEntityExpected, responseEntity); }
public ResponseEntity<String> createSTSRole(AWSStsRole awsStsRole, String token){ String jsonStr = JSONUtil.getJSON(awsStsRole); Response response = reqProcessor.process("/auth/aws/config/sts/create",jsonStr, token); if(response.getHttpstatus().equals(HttpStatus.NO_CONTENT)){ return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":[\"STS Role created successfully \"]}"); }else{ return ResponseEntity.status(response.getHttpstatus()).body(response.getResponse()); } }
AWSAuthService { public ResponseEntity<String> createSTSRole(AWSStsRole awsStsRole, String token){ String jsonStr = JSONUtil.getJSON(awsStsRole); Response response = reqProcessor.process("/auth/aws/config/sts/create",jsonStr, token); if(response.getHttpstatus().equals(HttpStatus.NO_CONTENT)){ return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":[\"STS Role created successfully \"]}"); }else{ return ResponseEntity.status(response.getHttpstatus()).body(response.getResponse()); } } }
AWSAuthService { public ResponseEntity<String> createSTSRole(AWSStsRole awsStsRole, String token){ String jsonStr = JSONUtil.getJSON(awsStsRole); Response response = reqProcessor.process("/auth/aws/config/sts/create",jsonStr, token); if(response.getHttpstatus().equals(HttpStatus.NO_CONTENT)){ return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":[\"STS Role created successfully \"]}"); }else{ return ResponseEntity.status(response.getHttpstatus()).body(response.getResponse()); } }  }
AWSAuthService { public ResponseEntity<String> createSTSRole(AWSStsRole awsStsRole, String token){ String jsonStr = JSONUtil.getJSON(awsStsRole); Response response = reqProcessor.process("/auth/aws/config/sts/create",jsonStr, token); if(response.getHttpstatus().equals(HttpStatus.NO_CONTENT)){ return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":[\"STS Role created successfully \"]}"); }else{ return ResponseEntity.status(response.getHttpstatus()).body(response.getResponse()); } }  ResponseEntity<String> authenticateEC2(AWSLogin login); ResponseEntity<String> createRole(String token, AWSLoginRole awsLoginRole, UserDetails userDetails); ResponseEntity<String> updateRole(String token, AWSLoginRole awsLoginRole); ResponseEntity<String> deleteRole(String token, String role, UserDetails userDetails); ResponseEntity<String> fetchRole(String token, String role); ResponseEntity<String> listRoles(String token); ResponseEntity<String> configureClient(AWSClientConfiguration awsClientConfiguration, String token); ResponseEntity<String> readClientConfiguration(String token); ResponseEntity<String> createSTSRole(AWSStsRole awsStsRole, String token); ResponseEntity<String> authenticateIAM(AWSIAMLogin awsiamLogin); ResponseEntity<String> authenticate(AWSAuthType authType, AWSAuthLogin awsAuthLogin); Response configureAWSRole(String roleName,String policies,String token ); }
AWSAuthService { public ResponseEntity<String> createSTSRole(AWSStsRole awsStsRole, String token){ String jsonStr = JSONUtil.getJSON(awsStsRole); Response response = reqProcessor.process("/auth/aws/config/sts/create",jsonStr, token); if(response.getHttpstatus().equals(HttpStatus.NO_CONTENT)){ return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":[\"STS Role created successfully \"]}"); }else{ return ResponseEntity.status(response.getHttpstatus()).body(response.getResponse()); } }  ResponseEntity<String> authenticateEC2(AWSLogin login); ResponseEntity<String> createRole(String token, AWSLoginRole awsLoginRole, UserDetails userDetails); ResponseEntity<String> updateRole(String token, AWSLoginRole awsLoginRole); ResponseEntity<String> deleteRole(String token, String role, UserDetails userDetails); ResponseEntity<String> fetchRole(String token, String role); ResponseEntity<String> listRoles(String token); ResponseEntity<String> configureClient(AWSClientConfiguration awsClientConfiguration, String token); ResponseEntity<String> readClientConfiguration(String token); ResponseEntity<String> createSTSRole(AWSStsRole awsStsRole, String token); ResponseEntity<String> authenticateIAM(AWSIAMLogin awsiamLogin); ResponseEntity<String> authenticate(AWSAuthType authType, AWSAuthLogin awsAuthLogin); Response configureAWSRole(String roleName,String policies,String token );  }