@Test public void test_readRole_successfully() { String roleName = "mytestawsrole"; String token = "5PDrOhsy4ig8L3EpsJZSLAMg"; String responseBody = "{ \"bound_account_id\": [ \"1234567890123\"],\"bound_ami_id\": [\"ami-fce3c696\" ], \"bound_iam_instance_profile_arn\": [\n" + " \"arn:aws:iam::877677878:instance-profile/exampleinstanceprofile\" ], \"bound_iam_role_arn\": [\"arn:aws:iam::8987887:role/test-role\" ], " + "\"bound_vpc_id\": [ \"vpc-2f09a348\"], \"bound_subnet_id\": [ \"subnet-1122aabb\"],\"bound_region\": [\"us-east-2\"],\"policies\": [ \"\\\"[prod\",\"dev\\\"]\" ]}"; Response readResponse = getMockResponse(HttpStatus.OK, true, responseBody); String jsoninput = "{\"role\":\"" + roleName + "\"}"; ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body(responseBody); when(reqProcessor.process("/auth/aws/roles", jsoninput, token)).thenReturn(readResponse); ResponseEntity<String> responseEntity = awsAuthService.fetchRole(token, "mytestawsrole"); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); assertEquals(responseEntityExpected, responseEntity); }
public ResponseEntity<String> fetchRole(String token, String role){ String jsoninput= "{\"role\":\""+role+"\"}"; Response response = reqProcessor.process("/auth/aws/roles",jsoninput,token); return ResponseEntity.status(response.getHttpstatus()).body(response.getResponse()); }
AWSAuthService { public ResponseEntity<String> fetchRole(String token, String role){ String jsoninput= "{\"role\":\""+role+"\"}"; Response response = reqProcessor.process("/auth/aws/roles",jsoninput,token); return ResponseEntity.status(response.getHttpstatus()).body(response.getResponse()); } }
AWSAuthService { public ResponseEntity<String> fetchRole(String token, String role){ String jsoninput= "{\"role\":\""+role+"\"}"; Response response = reqProcessor.process("/auth/aws/roles",jsoninput,token); return ResponseEntity.status(response.getHttpstatus()).body(response.getResponse()); }  }
AWSAuthService { public ResponseEntity<String> fetchRole(String token, String role){ String jsoninput= "{\"role\":\""+role+"\"}"; Response response = reqProcessor.process("/auth/aws/roles",jsoninput,token); 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> fetchRole(String token, String role){ String jsoninput= "{\"role\":\""+role+"\"}"; Response response = reqProcessor.process("/auth/aws/roles",jsoninput,token); 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 );  }