org.sonatype.nexus.repository.rest.api.model.AbstractRepositoryApiRequest Java Examples

The following examples show how to use org.sonatype.nexus.repository.rest.api.model.AbstractRepositoryApiRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: P2RepositoriesApiResourceIT.java    From nexus-repository-p2 with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void updateProxy() throws Exception {
  repos.createP2Proxy(PROXY_NAME, REMOTE_URL);

  AbstractRepositoryApiRequest request = createProxyRequest(false);

  Response response = put(getUpdateRepositoryPathUrl(ProxyType.NAME, PROXY_NAME), request);
  assertEquals(response.getStatus(), Status.NO_CONTENT.getStatusCode());

  Repository repository = repositoryManager.get(request.getName());
  assertNotNull(repository);

  assertThat(repository.getConfiguration().attributes(StorageFacetConstants.STORAGE)
          .get(StorageFacetConstants.STRICT_CONTENT_TYPE_VALIDATION),
      is(false));
  repositoryManager.delete(PROXY_NAME);
}
 
Example #2
Source File: ConanResourceIT.java    From nexus-repository-conan with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void updateProxy() throws Exception {
  repos.createConanProxy(PROXY_NAME, REMOTE_URL);

  AbstractRepositoryApiRequest request = createProxyRequest(false);

  Response response = put(getUpdateRepositoryPathUrl(ProxyType.NAME, PROXY_NAME), request);
  assertEquals(Status.NO_CONTENT.getStatusCode(), response.getStatus());

  Repository repository = repositoryManager.get(request.getName());
  assertNotNull(repository);

  assertThat(repository.getConfiguration().attributes("storage")
          .get("strictContentTypeValidation"),
      is(false));
  repositoryManager.delete(PROXY_NAME);
}
 
Example #3
Source File: HelmResourceIT.java    From nexus-repository-helm with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void updateHosted() throws Exception {
  repos.createHelmHosted(HOSTED_NAME);

  AbstractRepositoryApiRequest request = createHostedRequest(false);

  Response response = put(getUpdateRepositoryPathUrl(HostedType.NAME, HOSTED_NAME), request);
  assertEquals(Status.NO_CONTENT.getStatusCode(), response.getStatus());

  Repository repository = repositoryManager.get(request.getName());
  assertNotNull(repository);

  assertThat(repository.getConfiguration().attributes("storage")
          .get("strictContentTypeValidation"),
      is(false));

  repositoryManager.delete(HOSTED_NAME);
}
 
Example #4
Source File: RResourceIT.java    From nexus-repository-r with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void updateHosted() throws Exception {
  repos.createRHosted(HOSTED_NAME);

  AbstractRepositoryApiRequest request = createHostedRequest(false);

  Response response = put(getUpdateRepositoryPathUrl(HostedType.NAME, HOSTED_NAME), request);
  assertEquals(Status.NO_CONTENT.getStatusCode(), response.getStatus());

  Repository repository = repositoryManager.get(request.getName());
  assertNotNull(repository);

  assertThat(repository.getConfiguration().attributes("storage")
          .get("strictContentTypeValidation"),
      is(false));

  repositoryManager.delete(HOSTED_NAME);
}
 
Example #5
Source File: RResourceIT.java    From nexus-repository-r with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void updateProxy() throws Exception {
  repos.createRProxy(PROXY_NAME, REMOTE_URL);

  AbstractRepositoryApiRequest request = createProxyRequest(false);

  Response response = put(getUpdateRepositoryPathUrl(ProxyType.NAME, PROXY_NAME), request);
  assertEquals(Status.NO_CONTENT.getStatusCode(), response.getStatus());

  Repository repository = repositoryManager.get(request.getName());
  assertNotNull(repository);

  assertThat(repository.getConfiguration().attributes("storage")
          .get("strictContentTypeValidation"),
      is(false));
  repositoryManager.delete(PROXY_NAME);
}
 
Example #6
Source File: HelmResourceIT.java    From nexus-repository-helm with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void updateProxy() throws Exception {
  repos.createHelmProxy(PROXY_NAME, "http://example.com");

  AbstractRepositoryApiRequest request = createProxyRequest(false);

  Response response = put(getUpdateRepositoryPathUrl(ProxyType.NAME, PROXY_NAME), request);
  assertEquals(Status.NO_CONTENT.getStatusCode(), response.getStatus());

  Repository repository = repositoryManager.get(request.getName());
  assertNotNull(repository);

  assertThat(repository.getConfiguration().attributes("storage")
          .get("strictContentTypeValidation"),
      is(false));
  repositoryManager.delete(PROXY_NAME);
}
 
Example #7
Source File: RResourceIT.java    From nexus-repository-r with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void updateProxy_noAuthz() throws Exception {
  repos.createRProxy(PROXY_NAME, REMOTE_URL);

  setUnauthorizedUser();
  AbstractRepositoryApiRequest request = createProxyRequest(false);

  Response response = put(getUpdateRepositoryPathUrl(ProxyType.NAME, PROXY_NAME), request);
  assertEquals(Status.FORBIDDEN.getStatusCode(), response.getStatus());
}
 
Example #8
Source File: RResourceIT.java    From nexus-repository-r with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void createProxy_noAuthz() throws Exception {
  setUnauthorizedUser();
  AbstractRepositoryApiRequest request = createProxyRequest(true);
  Response response = post(getCreateRepositoryPathUrl(ProxyType.NAME), request);
  assertEquals(Status.FORBIDDEN.getStatusCode(), response.getStatus());
}
 
Example #9
Source File: RResourceIT.java    From nexus-repository-r with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void createHosted() throws Exception {
  AbstractRepositoryApiRequest request = createHostedRequest(true);
  Response response = post(getCreateRepositoryPathUrl(HostedType.NAME), request);
  assertEquals(Status.CREATED.getStatusCode(), response.getStatus());

  Repository repository = repositoryManager.get(request.getName());
  assertNotNull(repository);
  assertEquals(RFormat.NAME, repository.getFormat().getValue());
  assertEquals(HostedType.NAME, repository.getType().getValue());

  repositoryManager.delete(request.getName());
}
 
Example #10
Source File: RResourceIT.java    From nexus-repository-r with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void createHosted_noAuthc() throws Exception {
  setBadCredentials();
  AbstractRepositoryApiRequest request = createHostedRequest(true);
  Response response = post(getCreateRepositoryPathUrl(HostedType.NAME), request);
  assertEquals(Status.UNAUTHORIZED.getStatusCode(), response.getStatus());
}
 
Example #11
Source File: RResourceIT.java    From nexus-repository-r with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void createHosted_noAuthz() throws Exception {
  setUnauthorizedUser();
  AbstractRepositoryApiRequest request = createHostedRequest(true);
  Response response = post(getCreateRepositoryPathUrl(HostedType.NAME), request);
  assertEquals(Status.FORBIDDEN.getStatusCode(), response.getStatus());
}
 
Example #12
Source File: RResourceIT.java    From nexus-repository-r with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void createGroup() throws Exception {
  AbstractRepositoryApiRequest request = createGroupRequest(true);

  Response response = post(getCreateRepositoryPathUrl(GroupType.NAME), request);
  assertEquals(Status.CREATED.getStatusCode(), response.getStatus());

  repositoryManager.delete(request.getName());
}
 
Example #13
Source File: RResourceIT.java    From nexus-repository-r with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void createGroup_noAuthc() throws Exception {
  setBadCredentials();
  AbstractRepositoryApiRequest request = createGroupRequest(true);

  Response response = post(getCreateRepositoryPathUrl(GroupType.NAME), request);
  assertEquals(Status.UNAUTHORIZED.getStatusCode(), response.getStatus());
}
 
Example #14
Source File: RResourceIT.java    From nexus-repository-r with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void createGroup_noAuthz() throws Exception {
  setUnauthorizedUser();
  AbstractRepositoryApiRequest request = createGroupRequest(true);

  Response response = post(getCreateRepositoryPathUrl(GroupType.NAME), request);
  assertEquals(Status.FORBIDDEN.getStatusCode(), response.getStatus());
}
 
Example #15
Source File: RResourceIT.java    From nexus-repository-r with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void updateProxy_noAuthc() throws Exception {
  setBadCredentials();
  AbstractRepositoryApiRequest request = createProxyRequest(false);

  Response response = put(getUpdateRepositoryPathUrl(ProxyType.NAME, PROXY_NAME), request);
  assertEquals(Status.UNAUTHORIZED.getStatusCode(), response.getStatus());
}
 
Example #16
Source File: RResourceITSupport.java    From nexus-repository-r with Eclipse Public License 1.0 5 votes vote down vote up
protected AbstractRepositoryApiRequest createHostedRequest(boolean strictContentTypeValidation) {
  HostedStorageAttributes storage =
      new HostedStorageAttributes("default", strictContentTypeValidation, WritePolicy.ALLOW.name());
  CleanupPolicyAttributes cleanup = new CleanupPolicyAttributes(Collections.emptyList());

  return new RHostedRepositoryApiRequest(HOSTED_NAME, true, storage,
      cleanup);
}
 
Example #17
Source File: RResourceIT.java    From nexus-repository-r with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void updateHosted_noAuthc() throws Exception {
  setBadCredentials();
  AbstractRepositoryApiRequest request = createHostedRequest(false);

  Response response = put(getUpdateRepositoryPathUrl(HostedType.NAME, HOSTED_NAME), request);
  assertEquals(Status.UNAUTHORIZED.getStatusCode(), response.getStatus());
}
 
Example #18
Source File: RResourceIT.java    From nexus-repository-r with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void updateHosted_noAuthz() throws Exception {
  repos.createRHosted(HOSTED_NAME);

  setUnauthorizedUser();
  AbstractRepositoryApiRequest request = createHostedRequest(false);

  Response response = put(getUpdateRepositoryPathUrl(HostedType.NAME, HOSTED_NAME), request);
  assertEquals(Status.FORBIDDEN.getStatusCode(), response.getStatus());
}
 
Example #19
Source File: ConanResourceIT.java    From nexus-repository-conan with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void createProxy() throws Exception {
  AbstractRepositoryApiRequest request = createProxyRequest(true);
  Response response = post(getCreateRepositoryPathUrl(ProxyType.NAME), request);
  assertEquals(Status.CREATED.getStatusCode(), response.getStatus());

  Repository repository = repositoryManager.get(request.getName());
  assertNotNull(repository);
  assertEquals(ConanFormat.NAME, repository.getFormat().getValue());
  assertEquals(ProxyType.NAME, repository.getType().getValue());

  repositoryManager.delete(request.getName());
}
 
Example #20
Source File: ConanResourceIT.java    From nexus-repository-conan with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void createProxy_noAuthc() throws Exception {
  setBadCredentials();
  AbstractRepositoryApiRequest request = createProxyRequest(true);
  Response response = post(getCreateRepositoryPathUrl(ProxyType.NAME), request);
  assertEquals(Status.UNAUTHORIZED.getStatusCode(), response.getStatus());
}
 
Example #21
Source File: ConanResourceIT.java    From nexus-repository-conan with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void createProxy_noAuthz() throws Exception {
  setUnauthorizedUser();
  AbstractRepositoryApiRequest request = createProxyRequest(true);
  Response response = post(getCreateRepositoryPathUrl(ProxyType.NAME), request);
  assertEquals(Status.FORBIDDEN.getStatusCode(), response.getStatus());
}
 
Example #22
Source File: ConanResourceIT.java    From nexus-repository-conan with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void updateProxy_noAuthc() throws Exception {
  setBadCredentials();
  AbstractRepositoryApiRequest request = createProxyRequest(false);

  Response response = put(getUpdateRepositoryPathUrl(ProxyType.NAME, PROXY_NAME), request);
  assertEquals(Status.UNAUTHORIZED.getStatusCode(), response.getStatus());
}
 
Example #23
Source File: ConanResourceIT.java    From nexus-repository-conan with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void updateProxy_noAuthz() throws Exception {
  repos.createConanProxy(PROXY_NAME, REMOTE_URL);

  setUnauthorizedUser();
  AbstractRepositoryApiRequest request = createProxyRequest(false);

  Response response = put(getUpdateRepositoryPathUrl(ProxyType.NAME, PROXY_NAME), request);
  assertEquals(Status.FORBIDDEN.getStatusCode(), response.getStatus());
}
 
Example #24
Source File: ConanResourceITSupport.java    From nexus-repository-conan with Eclipse Public License 1.0 5 votes vote down vote up
protected AbstractRepositoryApiRequest createProxyRequest(boolean strictContentTypeValidation) {
  StorageAttributes storage =
      new StorageAttributes("default", strictContentTypeValidation);
  CleanupPolicyAttributes cleanup = new CleanupPolicyAttributes(Collections.emptyList());
  ProxyAttributes proxy = new ProxyAttributes(REMOTE_URL, 1, 2);
  NegativeCacheAttributes negativeCache = new NegativeCacheAttributes(false, 1440);
  HttpClientConnectionAttributes connection =
      new HttpClientConnectionAttributes(1, null, 5, false, false);
  HttpClientAttributes httpClient = new HttpClientAttributes(false, true, connection, null);

  // SET YOUR FORMAT DATA
  return new ConanProxyRepositoryApiRequest(PROXY_NAME, true, storage, cleanup,
      proxy, negativeCache,
      httpClient, null);
}
 
Example #25
Source File: HelmResourceIT.java    From nexus-repository-helm with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void createHosted_noAuthz() throws Exception {
  setUnauthorizedUser();
  AbstractRepositoryApiRequest request = createHostedRequest(true);
  Response response = post(getCreateRepositoryPathUrl(HostedType.NAME), request);
  assertEquals(Status.FORBIDDEN.getStatusCode(), response.getStatus());
}
 
Example #26
Source File: P2RepositoriesApiResourceIT.java    From nexus-repository-p2 with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void createProxyBadCredentials() throws Exception {
  setBadCredentials();
  AbstractRepositoryApiRequest request = createProxyRequest(true);
  Response response = post(getCreateRepositoryPathUrl(ProxyType.NAME), request);
  assertEquals(response.getStatus(), Status.UNAUTHORIZED.getStatusCode());
}
 
Example #27
Source File: P2RepositoriesApiResourceIT.java    From nexus-repository-p2 with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void createProxyUnauthorized() throws Exception {
  setUnauthorizedUser();
  AbstractRepositoryApiRequest request = createProxyRequest(true);
  Response response = post(getCreateRepositoryPathUrl(ProxyType.NAME), request);
  assertEquals(response.getStatus(), Status.FORBIDDEN.getStatusCode());
}
 
Example #28
Source File: P2RepositoriesApiResourceIT.java    From nexus-repository-p2 with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void updateProxyBadCredentials() throws Exception {
  setBadCredentials();
  AbstractRepositoryApiRequest request = createProxyRequest(false);

  Response response = put(getUpdateRepositoryPathUrl(ProxyType.NAME, PROXY_NAME), request);
  assertEquals(response.getStatus(), Status.UNAUTHORIZED.getStatusCode());
}
 
Example #29
Source File: P2RepositoriesApiResourceIT.java    From nexus-repository-p2 with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void updateProxyUnauthorized() throws Exception {
  repos.createP2Proxy(PROXY_NAME, REMOTE_URL);

  setUnauthorizedUser();
  AbstractRepositoryApiRequest request = createProxyRequest(false);

  Response response = put(getUpdateRepositoryPathUrl(ProxyType.NAME, PROXY_NAME), request);
  assertEquals(response.getStatus(), Status.FORBIDDEN.getStatusCode());
}
 
Example #30
Source File: P2ResourceITSupport.java    From nexus-repository-p2 with Eclipse Public License 1.0 5 votes vote down vote up
protected AbstractRepositoryApiRequest createProxyRequest(boolean strictContentTypeValidation) {
  StorageAttributes storage =
      new StorageAttributes("default", strictContentTypeValidation);
  CleanupPolicyAttributes cleanup = new CleanupPolicyAttributes(Collections.emptyList());
  ProxyAttributes proxy = new ProxyAttributes(REMOTE_URL, 1, 2);
  NegativeCacheAttributes negativeCache = new NegativeCacheAttributes(false, 1440);
  HttpClientConnectionAttributes connection =
      new HttpClientConnectionAttributes(1, null, 5, false, false);
  HttpClientAttributes httpClient = new HttpClientAttributes(false, true, connection, null);

  // SET YOUR FORMAT DATA
  return new P2ProxyRepositoryApiRequest(PROXY_NAME, true, storage, cleanup,
      proxy, negativeCache,
      httpClient, null);
}