/**
  * Sets the exposed flag of repository.
  *
  * @param exposed
  * @throws IOException
  */
 protected void setExposed(final boolean exposed) throws IOException {
   TestContainer.getInstance().getTestContext().useAdminForRequests();
   TestContainer.getInstance().getTestContext().setSecureTest(true);
   final RepositoryBaseResource releasesRepository =
       getRepositoryMessageUtil().getRepository(REPO_TEST_HARNESS_RELEASE_REPO);
   releasesRepository.setExposed(exposed);
   getRepositoryMessageUtil().updateRepo(releasesRepository);
 }
  @Test
  public void updateRepositoryNoAccessTest() throws Exception {

    RepositoryBaseResource repo = repoUtil.getRepository(getTestRepositoryId());
    repo.setName("new name");

    // use test user
    TestContainer.getInstance().getTestContext().setUsername(TEST_USER_NAME);
    TestContainer.getInstance().getTestContext().setPassword(TEST_USER_PASSWORD);

    Response response = this.repoUtil.sendMessage(Method.PUT, repo);
    Assert.assertEquals("Status: " + response.getStatus(), response.getStatus().getCode(), 403);
  }
  @Test
  public void createRepositoryNoAccessTest() throws Exception {

    String repoId = "test-repo";

    RepositoryBaseResource repo = this.repoUtil.getRepository(this.getTestRepositoryId());
    repo.setId(repoId);

    // use test user
    TestContainer.getInstance().getTestContext().setUsername(TEST_USER_NAME);
    TestContainer.getInstance().getTestContext().setPassword(TEST_USER_PASSWORD);

    Response response = this.repoUtil.sendMessage(Method.POST, repo, repoId);
    Assert.assertEquals("Status: " + response.getStatus(), response.getStatus().getCode(), 403);
  }
 @Override
 public int canAdapt(final RepositoryBaseResource resource) {
   int score = super.canAdapt(resource);
   if (score > 0) {
     if (JerseyMavenProxyRepository.PROVIDER.equals(resource.getProvider())) {
       score++;
     }
   }
   return score;
 }
  @Test
  public void updateRepoTest() throws Exception {
    // change the name of the test repo
    RepositoryMessageUtil repoUtil =
        new RepositoryMessageUtil(
            this.getXMLXStream(), MediaType.APPLICATION_XML, getRepositoryTypeRegistry());

    RepositoryBaseResource repo = repoUtil.getRepository(this.getTestRepositoryId());
    String oldName = repo.getName();
    String newName = repo.getName() + "-new";
    repo.setName(newName);
    repoUtil.updateRepo(repo);

    TaskScheduleUtil.waitForAllTasksToStop();

    final SyndFeed feed = FeedUtil.getFeed("systemChanges");
    this.validateLinksInFeeds(feed);
    Assert.assertTrue(
        "Update repo feed not found\r\n\r\n" + feed,
        findFeedEntry(feed, "Configuration change", new String[] {newName, oldName}));
  }