AWSAuthService { public ResponseEntity<String> authenticateIAM(AWSIAMLogin awsiamLogin){ String jsonStr = JSONUtil.getJSON(awsiamLogin); Response response = reqProcessor.process("/auth/aws/iam/login",jsonStr,""); 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 );  }
@Test public void test_authenticateIAM_failure_500() { String jsonStr = "{\n" + " \"iam_http_request_method\": \"POST\",\n" + " \"iam_request_body\": \"{}\",\n" + " \"iam_request_headers\": \"{\"token\":\"4qJC0tWjMDIKjRDDmtcUAZBt\"}\",\n" + " \"iam_request_url\": \"http: " \"role\": \"testawsrole\",\n" + " \"pkcs7\": \"MIIBjwYJKoZIhvcNAQcDoIIBgDCCAXwCAQAxggE4MIIBNAIBADCBnDCBlDELMAkGA1UEBhMCWkEx====\"\n" + "}"; AWSIAMLogin awsiamLogin = new AWSIAMLogin(); awsiamLogin.setIam_http_request_method("POST"); awsiamLogin.setIam_request_body("{}"); awsiamLogin.setIam_request_headers("{\"token\":\"4qJC0tWjMDIKjRDDmtcUAZBt\"}"); awsiamLogin.setIam_request_url("http: awsiamLogin.setRole("testawsrole"); awsiamLogin.setPkcs7("MIIBjwYJKoZIhvcNAQcDoIIBgDCCAXwCAQAxggE4MIIBNAIBADCBnDCBlDELMAkGA1UEBhMCWkEx"); String responseBody = "{ \"errors\": [ \"failed to base64 decode iam_request_url\" ]}"; Response response = getMockResponse(HttpStatus.BAD_REQUEST, false, responseBody); ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.BAD_REQUEST).body(responseBody); when(JSONUtil.getJSON(awsiamLogin)).thenReturn(jsonStr); when(reqProcessor.process("/auth/aws/iam/login",jsonStr,"")).thenReturn(response); ResponseEntity<String> responseEntity = awsAuthService.authenticateIAM(awsiamLogin); assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode()); assertEquals(responseEntityExpected, responseEntity); }