Exemple #1
0
  @Test(
      groups = {"wso2.as"},
      description = "DELETE request by super admin",
      dependsOnMethods = "testUpdateStudent")
  public void testDeleteStudent()
      throws IOException, EndpointAdminEndpointAdminException,
          LoginAuthenticationExceptionException, XMLStreamException {

    String securedRestURL = getSecuredServiceEndpoint(SERVICE_NAME) + "/student/" + studentName;
    HttpsResponse response =
        HttpsURLConnectionClient.deleteWithBasicAuth(
            securedRestURL, null, userInfo.getPassword(), userInfo.getPassword());
    assertTrue(
        !response.getData().contains(studentName), "response doesn't contain the expected output");
  }
  @Test(
      groups = {"wso2.as"},
      description = "DELETE request  by invalid user",
      dependsOnMethods = "testUpdateStudent",
      enabled = false)
  public void testDeleteStudent()
      throws IOException, EndpointAdminEndpointAdminException,
          LoginAuthenticationExceptionException, XMLStreamException {
    boolean status = false;
    HttpsResponse response = null;

    String securedRestURL = getSecuredServiceEndpoint(SERVICE_NAME) + "/student/" + studentName;
    try {
      response =
          HttpsURLConnectionClient.deleteWithBasicAuth(
              securedRestURL, null, "InvalidUser", "InvalidPassword");
    } catch (IOException ignored) {
      status = true; // invalid users cannot get the resource
    }
    assertTrue(status, "Invalid user was able to get the resource");
    assertNull(response, "Response should be null");
  }