// disable anonymous access
GlobalConfigurationResource settings = SettingsMessageUtil.getCurrentSettings();
settings.setSecurityAnonymousAccessEnabled(false);
SettingsMessageUtil.save(settings);
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 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));
// 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 401
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(401));
// 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));
}