Package org.restlet.data

Examples of org.restlet.data.Status


  {
    // make the testing repository "private"
    enablePrivateRepository(TestContainer.getInstance().getTestContext().getAdminUsername(),
        REPO_TEST_HARNESS_RELEASE_REPO);

    Status responseStatus;

    // verify assumptions, we have the stuff deployed and present
    // try and verify authenticate /content GET access gives 200
    responseStatus =
        sendMessage(
            true,
            RequestFacade.toNexusURL("content/repositories/" + REPO_TEST_HARNESS_RELEASE_REPO
                + "/nxcm3600/artifact/1.0.0/artifact-1.0.0.jar"), Method.GET);
    MatcherAssert.assertThat(responseStatus.getCode(), equalTo(200));
    // try and verify authenticated /service/local GET access gives 200
    responseStatus =
        sendMessage(
            true,
            RequestFacade.toNexusURL("service/local/repositories/" + REPO_TEST_HARNESS_RELEASE_REPO
                + "/content/nxcm3600/artifact/1.0.0/artifact-1.0.0.jar"), Method.GET);
    MatcherAssert.assertThat(responseStatus.getCode(), equalTo(200));
    // try and verify anon /content GET access gives 401
    responseStatus =
        sendMessage(
            false,
            RequestFacade.toNexusURL("content/repositories/" + REPO_TEST_HARNESS_RELEASE_REPO
                + "/nxcm3600/artifact/1.0.0/artifact-1.0.0.jar"), Method.GET);
    MatcherAssert.assertThat(responseStatus.getCode(), equalTo(401));
    // try and verify anon /service/local GET access gives 401
    responseStatus =
        sendMessage(
            false,
            RequestFacade.toNexusURL("service/local/repositories/" + REPO_TEST_HARNESS_RELEASE_REPO
                + "/content/nxcm3600/artifact/1.0.0/artifact-1.0.0.jar"), Method.GET);
    MatcherAssert.assertThat(responseStatus.getCode(), equalTo(401));

    // now put repository into exposed=false mode
    setExposed(false);

    // READ access
    // try and verify authenticated /content GET access gives 404
    responseStatus =
        sendMessage(
            true,
            RequestFacade.toNexusURL("content/repositories/" + REPO_TEST_HARNESS_RELEASE_REPO
                + "/nxcm3600/artifact/1.0.0/artifact-1.0.0.jar"), Method.GET);
    MatcherAssert.assertThat(responseStatus.getCode(), equalTo(404));
    // try and verify authenticated /service/local GET access gives 200
    responseStatus =
        sendMessage(
            true,
            RequestFacade.toNexusURL("service/local/repositories/" + REPO_TEST_HARNESS_RELEASE_REPO
                + "/content/nxcm3600/artifact/1.0.0/artifact-1.0.0.jar"), Method.GET);
    MatcherAssert.assertThat(responseStatus.getCode(), equalTo(200));
    // try and verify anon /content GET access gives 404
    responseStatus =
        sendMessage(
            false,
            RequestFacade.toNexusURL("content/repositories/" + REPO_TEST_HARNESS_RELEASE_REPO
                + "/nxcm3600/artifact/1.0.0/artifact-1.0.0.jar"), Method.GET);
    MatcherAssert.assertThat(responseStatus.getCode(), equalTo(404));
    // try and verify anon /service/local GET access gives 401
    responseStatus =
        sendMessage(
            false,
            RequestFacade.toNexusURL("service/local/repositories/" + REPO_TEST_HARNESS_RELEASE_REPO
                + "/content/nxcm3600/artifact/1.0.0/artifact-1.0.0.jar"), Method.GET);
    MatcherAssert.assertThat(responseStatus.getCode(), equalTo(401));

    // DELETE access
    // try and verify authenticated /content DELETE access gives 404
    responseStatus =
        sendMessage(
            true,
            RequestFacade.toNexusURL("content/repositories/" + REPO_TEST_HARNESS_RELEASE_REPO
                + "/nxcm3600/artifact/1.0.0/artifact-1.0.0.jar"), Method.DELETE);
    MatcherAssert.assertThat(responseStatus.getCode(), equalTo(404));
    // try and verify anon /content DELETE access gives 404
    responseStatus =
        sendMessage(
            false,
            RequestFacade.toNexusURL("content/repositories/" + REPO_TEST_HARNESS_RELEASE_REPO
                + "/nxcm3600/artifact/1.0.0/artifact-1.0.0.jar"), Method.DELETE);
    MatcherAssert.assertThat(responseStatus.getCode(), equalTo(404));
    // try and verify anon /service/local DELETE access gives 401
    responseStatus =
        sendMessage(
            false,
            RequestFacade.toNexusURL("service/local/repositories/" + REPO_TEST_HARNESS_RELEASE_REPO
                + "/content/nxcm3600/artifact/1.0.0/artifact-1.0.0.jar"), Method.DELETE);
    MatcherAssert.assertThat(responseStatus.getCode(), equalTo(401));
    // try and verify authenticated /service/local DELETE access gives 204
    responseStatus =
        sendMessage(
            true,
            RequestFacade.toNexusURL("service/local/repositories/" + REPO_TEST_HARNESS_RELEASE_REPO
                + "/content/nxcm3600/artifact/1.0.0/artifact-1.0.0.jar"), Method.DELETE);
    MatcherAssert.assertThat(responseStatus.getCode(), equalTo(204));
  }
View Full Code Here


    TestContainer.getInstance().getTestContext().setUsername(TEST_USER_NAME);
    TestContainer.getInstance().getTestContext().setPassword(TEST_USER_PASSWORD);

    // Should be able to change my own password
    Status status = ChangePasswordUtils.changePassword("test-user", "admin123", "123admin");
    Assert.assertTrue(status.isSuccess());

    // password changed ! should fail
    status = ChangePasswordUtils.changePassword("test-user", "admin123", "123admin");
    Assert.assertEquals(401, status.getCode());
    status = ChangePasswordUtils.changePassword("test-user", "123admin", "admin123");
    Assert.assertEquals(401, status.getCode());

    TestContainer.getInstance().getTestContext().setUsername(TEST_USER_NAME);
    TestContainer.getInstance().getTestContext().setPassword("123admin");

    // should pass
    status = ChangePasswordUtils.changePassword("test-user", "123admin", "admin123");
    Assert.assertTrue(status.isSuccess());

    // should NOT be able to change another users password
  }
View Full Code Here

    TestContainer.getInstance().getTestContext().setUsername(TEST_USER_NAME);
    TestContainer.getInstance().getTestContext().setPassword(TEST_USER_PASSWORD);

    // NOT Should be able to forgot my own username
    Status status = ChangePasswordUtils.changePassword("test-user", "admin123", "123admin");
    Assert.assertEquals(403, status.getCode());
  }
View Full Code Here

  @Test
  public void changeUserPassword()
      throws Exception
  {
    Status status = ChangePasswordUtils.changePassword("test-user", "admin123", "123admin");
    Assert.assertEquals(Status.SUCCESS_ACCEPTED.getCode(), status.getCode());
  }
View Full Code Here

    scheduledTask.setId(null);
    scheduledTask.setName(taskName);
    scheduledTask.setTypeId(UpdateIndexTaskDescriptor.ID);
    scheduledTask.setSchedule("manual");
    scheduledTask.addProperty(prop);
    Status status = TaskScheduleUtil.create(scheduledTask);

    Assert.assertTrue(status.isSuccess());

    return TaskScheduleUtil.getTask(taskName).getId();
  }
View Full Code Here

    String uri = "service/local/taskhelper?attempts=" + maxAttempts;
    if (taskType != null) {
      uri += "&taskType=" + taskType;
    }

    final Status status = nexusRestClient.doGetForStatus(uri);

    if (!status.isSuccess()) {
      throw new IOException("The taskhelper REST resource reported an error (" + status.toString()
          + "), bailing out!");
    }
  }
View Full Code Here

    if (name != null) {
      uri += "&name=" + name;
    }

    final Status status = nexusRestClient.doGetForStatus(uri);

    if (failIfNotFinished) {
      if (Status.SUCCESS_NO_CONTENT.equals(status)) {
        throw new IOException("The taskhelper REST resource reported that task named '" + name
            + "' still running after '" + maxAttempts + "' cycles! This may indicate a performance issue.");
      }
    }
    else {
      if (!status.isSuccess()) {
        throw new IOException("The taskhelper REST resource reported an error (" + status.toString()
            + "), bailing out!");
      }
    }
  }
View Full Code Here

    for (ScheduledServicePropertyResource property : properties) {
      scheduledTask.addProperty(property);
    }

    Status status = create(scheduledTask);
    assertThat("Unable to create task:" + scheduledTask.getTypeId(), status.isSuccess(), is(true));

    String taskId = getTask(scheduledTask.getName()).getId();
    status = run(taskId);
    assertThat("Unable to run task:" + scheduledTask.getTypeId(), status.isSuccess(), is(true));

    waitForTask(taskName, maxAttempts, failIfNotFinished);
  }
View Full Code Here

    scheduledTask.addProperty(repositoryProp);
    scheduledTask.addProperty(keepSnapshotsProp);
    scheduledTask.addProperty(ageProp);
    scheduledTask.addProperty(removeReleasedProp);

    Status status = TaskScheduleUtil.create(scheduledTask);

    Assert.assertTrue(status.isSuccess());
  }
View Full Code Here

    changed.setTypeId(resource.getTypeId());
    changed.setSchedule(resource.getSchedule());
    changed.addProperty(TaskScheduleUtil.newProperty("repositoryId", getTestRepositoryId()));
    changed.addProperty(TaskScheduleUtil.newProperty("time", String.valueOf(10)));

    Status status = TaskScheduleUtil.update(changed);

    assertThat("Should not have been able to update task with state " + resource.getStatus() + ", "
        + status.getDescription(), status, isClientError());
  }
View Full Code Here

TOP

Related Classes of org.restlet.data.Status

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.