private void deployPrivWithWagon(Gav gav, String repoUrl)
throws Exception
{
this.resetTestUserPrivs();
Verifier verifier = null;
this.deleteFromRepository(getTestRepositoryId(), this.getTestId());
// file to deploy
File fileToDeploy = this.getTestFile(gav.getArtifactId() + "." + gav.getExtension());
// we need to delete the files...
this.deleteFromRepository(getTestRepositoryId(), this.getTestId() + "/");
// deploy
TestContainer.getInstance().getTestContext().setUsername(TEST_USER_NAME);
TestContainer.getInstance().getTestContext().setPassword(TEST_USER_PASSWORD);
// with pom should fail
try {
verifier =
MavenDeployer.deployAndGetVerifier(gav, repoUrl, fileToDeploy,
this.getOverridableFile("settings.xml"));
failTest(verifier);
}
catch (VerificationException e) {
// expected 403
}
// give deployment role
TestContainer.getInstance().getTestContext().useAdminForRequests();
// try again
TestContainer.getInstance().getTestContext().setUsername(TEST_USER_NAME);
TestContainer.getInstance().getTestContext().setPassword(TEST_USER_PASSWORD);
// if this fails it will throw an error
try {
verifier =
MavenDeployer.deployAndGetVerifier(gav, repoUrl, fileToDeploy,
this.getOverridableFile("settings.xml"));
failTest(verifier);
}
catch (VerificationException e) {
// expected 403
}
// try again
TestContainer.getInstance().getTestContext().setUsername(TEST_USER_NAME);
TestContainer.getInstance().getTestContext().setPassword(TEST_USER_PASSWORD);
TestContainer.getInstance().getTestContext().useAdminForRequests();
this.giveUserPrivilege("test-user", "T5");
// if this fails it will throw an error
verifier =
MavenDeployer.deployAndGetVerifier(gav, repoUrl, fileToDeploy, this.getOverridableFile("settings.xml"));
verifier.verifyErrorFreeLog();
// do it again as an update, this should fail
// if this fails it will throw an error
try {
verifier =
MavenDeployer.deployAndGetVerifier(gav, repoUrl, fileToDeploy,
this.getOverridableFile("settings.xml"));
failTest(verifier);
}
catch (VerificationException e) {
// expected 403
}
// now the user should be able to redeploy
TestContainer.getInstance().getTestContext().useAdminForRequests();
this.giveUserPrivilege("test-user", "T3");
TestContainer.getInstance().getTestContext().setUsername(TEST_USER_NAME);
TestContainer.getInstance().getTestContext().setPassword(TEST_USER_PASSWORD);
// if this fails it will throw an error
verifier =
MavenDeployer.deployAndGetVerifier(gav, repoUrl, fileToDeploy, this.getOverridableFile("settings.xml"));
verifier.verifyErrorFreeLog();
// check the services url too, ( just the GET for now )
// just check the parent dir, incase this is a SNAPSHOT repo
Response response =
RequestFacade.sendMessage(new URL(