Ejemplo n.º 1
0
  @Test
  @Category(com.absolute.util.helper.FastTest.class)
  public void test_cant_add_missing_media_to_policy() throws Exception {

    String[] policyIds =
        Helpers.getPolicyIdsForPolicyNames(logonCookie, Policies.STANDARD_POLICY_NAMES[0]);

    StringBuilder sb = new StringBuilder();
    sb.append("{");
    sb.append("\"contentIds\":[");
    sb.append("0],");
    sb.append("\"policyAssignments\":[{");
    sb.append("\"policyId\":\"" + policyIds[0] + "\",");
    sb.append("\"assignmentType\": 1,");
    sb.append("\"availabilitySelector\": 2,");
    sb.append("\"startTime\":\"2012-10-18T19:01:00Z\",");
    sb.append("\"endTime\":\"2012-10-19T20:12:00Z\"");
    sb.append("}]");
    sb.append("}");
    System.out.println("Request body=" + sb.toString());

    Helpers.postJsonRequestGetResultCheckStatus(
        logonCookie,
        Helpers.WEBAPI_BASE_URL + POLICY_CONTENT_API,
        sb.toString(),
        HttpStatus.SC_BAD_REQUEST);
  }
Ejemplo n.º 2
0
  @Test
  @Category(com.absolute.util.helper.FastTest.class)
  public void test_cant_add_media_to_missing_policy() throws Exception {
    // ***************************************
    // Upload the files first
    // ***************************************
    MessageDigest digest = MessageDigest.getInstance("MD5");

    String[] displayFilenames =
        new String[] {"WebAPIUnitTestPDF_policy_content_missing_policy.pdf"};
    Helpers.deleteFilesFromSystem(logonCookie, displayFilenames);

    // Upload all of the files.
    String[] remoteFileNames = new String[] {"WebAPIUnitTestPDF.pdf"};
    String fileUrlLocation =
        ContentUpload.class.getProtectionDomain().getCodeSource().getLocation().getFile();

    for (String remoteFileName : remoteFileNames) {
      String localFilePath =
          "\\" + fileUrlLocation + "\\..\\..\\src\\test\\resources\\files\\" + remoteFileName;
      uploadFile(
          Helpers.createHttpClientWithoutCertificateChecking(),
          remoteFileName,
          localFilePath.substring(1),
          digest);
    }

    String[] policyIds = new String[] {};
    Helpers.addFilesToSystem(logonCookie, remoteFileNames, displayFilenames, policyIds);

    Helpers.waitForAdminConsoleToCatchUp();

    // Check the media file exists
    String viewResultFile =
        Helpers.doGETCheckStatusReturnBody(
            logonCookie,
            Helpers.WEBAPI_BASE_URL + "api/views/allmobilecontent?$search=" + displayFilenames[0],
            200,
            200);
    String mediaIdFile1 = Helpers.getRowId(viewResultFile);
    assertNotNull("Cant find id for filename: " + displayFilenames[0], mediaIdFile1);

    StringBuilder sb = new StringBuilder();
    sb.append("{");
    sb.append("\"contentIds\":[");
    sb.append(mediaIdFile1 + "],");
    sb.append("\"policyAssignments\":[{");
    sb.append("\"policyId\": 0,"); // non existent policy policy
    sb.append("\"assignmentType\": 1,");
    sb.append("\"availabilitySelector\": 2,");
    sb.append("\"startTime\":\"2012-10-18T19:01:00Z\",");
    sb.append("\"endTime\":\"2012-10-19T20:12:00Z\"");
    sb.append("}]");
    sb.append("}");
    System.out.println("Request body=" + sb.toString());

    Helpers.postJsonRequestGetResultCheckStatus(
        logonCookie,
        Helpers.WEBAPI_BASE_URL + POLICY_CONTENT_API,
        sb.toString(),
        HttpStatus.SC_BAD_REQUEST);
  }