// get resource as stream by id////////////////////////////////// public virtual void testGetResourceAsStreamByIdWithoutAuthorization() { // given string deploymentId = createDeployment(null); disableAuthorization(); IList <Resource> resources = repositoryService.getDeploymentResources(deploymentId); enableAuthorization(); string resourceId = resources[0].Id; try { // when repositoryService.getResourceAsStreamById(deploymentId, resourceId); fail("Exception expected: it should not be possible to retrieve a resource as stream"); } catch (AuthorizationException e) { // then string message = e.Message; assertTextPresent(userId, message); assertTextPresent(READ.Name, message); assertTextPresent(DEPLOYMENT.resourceName(), message); } deleteDeployment(deploymentId); }
// create deployment /////////////////////////////////////////////// public virtual void testCreateDeploymentWithoutAuthoriatzion() { // given try { // when repositoryService.createDeployment().addClasspathResource(FIRST_RESOURCE).deploy(); fail("Exception expected: It should not be possible to create a new deployment"); } catch (AuthorizationException e) { // then string message = e.Message; assertTextPresent(userId, message); assertTextPresent(CREATE.Name, message); assertTextPresent(DEPLOYMENT.resourceName(), message); } }
// get resource as stream ////////////////////////////////// public virtual void testGetResourceAsStreamWithoutAuthorization() { // given string deploymentId = createDeployment(null); try { // when repositoryService.getResourceAsStream(deploymentId, FIRST_RESOURCE); fail("Exception expected: it should not be possible to retrieve a resource as stream"); } catch (AuthorizationException e) { // then string message = e.Message; assertTextPresent(userId, message); assertTextPresent(READ.Name, message); assertTextPresent(DEPLOYMENT.resourceName(), message); } deleteDeployment(deploymentId); }
// delete deployment ////////////////////////////////////////////// public virtual void testDeleteDeploymentWithoutAuthorization() { // given string deploymentId = createDeployment(null); try { // when repositoryService.deleteDeployment(deploymentId); fail("Exception expected: it should not be possible to delete a deployment"); } catch (AuthorizationException e) { // then string message = e.Message; assertTextPresent(userId, message); assertTextPresent(DELETE.Name, message); assertTextPresent(DEPLOYMENT.resourceName(), message); } deleteDeployment(deploymentId); }