Changeset 5566 for ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/SanboxTest.java
- Timestamp:
- 08/18/14 17:33:47 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/SanboxTest.java
r5565 r5566 230 230 231 231 232 @Test 233 public void testDeleteProfileAndComponentFromGroup() throws Exception { 234 235 System.out.println("test deleteProfileAndComponentFromGroup"); 236 232 233 234 @Test 235 public void testDeleteCommentFromGroupComponentAndProfile() throws Exception { 236 237 System.out.println("test deleteCommentFromGroupComponent"); 238 239 237 240 fillUpGroupA(); 238 241 fillUpGroupB(); 239 242 fillUpGroupC(); 240 243 244 RegistryTestHelper.addComment(baseRegistry, "COMMENTc1", ComponentDescription.COMPONENT_PREFIX + "component-1", 245 "JUnit@test.com"); 246 RegistryTestHelper.addComment(baseRegistry, "COMMENTp1", ProfileDescription.PROFILE_PREFIX + "profile-1", 247 "JUnit@test.com"); 248 RegistryTestHelper.addComment(baseRegistry, "COMMENTBc1", ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1", 249 "anotherPrincipal"); 250 RegistryTestHelper.addComment(baseRegistry, "COMMENTBp1", ProfileDescription.PROFILE_PREFIX + "Bprofile-1", 251 "anotherPrincipal"); 252 (new RegistryTestHelper()).addCommentBypassAuthorisation(commentsDao, "COMMENTCc1", ComponentDescription.COMPONENT_PREFIX + "Ccomponent-1", 253 "anotherPrincipal"); 254 (new RegistryTestHelper()).addCommentBypassAuthorisation(commentsDao, "COMMENTCp1", ProfileDescription.PROFILE_PREFIX + "Cprofile-1","anotherPrincipal"); 255 241 256 ClientResponse response = getAuthenticatedResource( 242 "/registry/components/" + ComponentDescription.COMPONENT_PREFIX 243 + "component-1").delete(ClientResponse.class);257 "/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "component-1/comments/1").delete( 258 ClientResponse.class); 244 259 assertEquals(200, response.getStatus()); 260 response = getAuthenticatedResource( 261 "/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "component-1/comments/1").get( 262 ClientResponse.class); 263 assertEquals(404, response.getStatus()); 264 265 response = getAuthenticatedResource( 266 "/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "Bcomponent-1/comments/3").delete( 267 ClientResponse.class); 268 assertEquals(403, response.getStatus()); 269 270 271 response = getAuthenticatedResource( 272 "/registry/components/" + ComponentDescription.COMPONENT_PREFIX + "Ccomponent-1/comments/5").delete( 273 ClientResponse.class); 274 assertEquals(403, response.getStatus()); 275 245 276 246 response = getAuthenticatedResource( 247 "/registry/components/" + ComponentDescription.COMPONENT_PREFIX 248 + "component-1").get(ClientResponse.class); 277 response = getAuthenticatedResource( 278 "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX + "profile-1/comments/2").delete( 279 ClientResponse.class); 280 assertEquals(200, response.getStatus()); 281 response = getAuthenticatedResource( 282 "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX + "profile-1/comments/2").get( 283 ClientResponse.class); 249 284 assertEquals(404, response.getStatus()); 250 285 251 // my group, not my component 252 253 response = getAuthenticatedResource( 254 "/registry/components/" + ComponentDescription.COMPONENT_PREFIX 255 + "Bcomponent-1").delete(ClientResponse.class); 256 assertEquals(200, response.getStatus()); 257 258 response = getAuthenticatedResource( 259 "/registry/components/" + ComponentDescription.COMPONENT_PREFIX 260 + "Bcomponent-1").get(ClientResponse.class); 261 assertEquals(404, response.getStatus()); 262 263 // not my group 264 response = getAuthenticatedResource( 265 "/registry/components/" + ComponentDescription.COMPONENT_PREFIX 266 + "Ccomponent-1").delete(ClientResponse.class); 267 assertEquals(403, response.getStatus()); 268 269 baseRegistry.setRegistrySpace(RegistrySpace.GROUP); 270 baseRegistry.setGroupId(1); 271 assertEquals(1, baseRegistry.getComponentDescriptions().size()); 272 baseRegistry.setGroupId(2); 273 assertEquals(1, baseRegistry.getComponentDescriptions().size()); 274 // baseRegistry.setGroupId(3); 275 // assertEquals(2, baseRegistry.getComponentDescriptions().size()); 276 277 baseRegistry.setRegistrySpace(null); 278 baseRegistry.setGroupId(null); 279 280 // profiles 281 282 response = getAuthenticatedResource( 283 "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX 284 + "profile-1").delete(ClientResponse.class); 285 assertEquals(200, response.getStatus()); 286 287 response = getAuthenticatedResource( 288 "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX 289 + "profile-1").get(ClientResponse.class); 290 assertEquals(404, response.getStatus()); 291 292 // my group, not my component 293 294 response = getAuthenticatedResource( 295 "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX 296 + "Bprofile-1").delete(ClientResponse.class); 297 assertEquals(200, response.getStatus()); 298 299 response = getAuthenticatedResource( 300 "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX 301 + "Bprofile-1").get(ClientResponse.class); 302 assertEquals(404, response.getStatus()); 303 304 // not my group 305 response = getAuthenticatedResource( 306 "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX 307 + "Cprofile-1").delete(ClientResponse.class); 308 assertEquals(403, response.getStatus()); 309 310 baseRegistry.setRegistrySpace(RegistrySpace.GROUP); 311 baseRegistry.setGroupId(1); 312 assertEquals(0, baseRegistry.getProfileDescriptions().size()); 313 baseRegistry.setGroupId(2); 314 assertEquals(0, baseRegistry.getProfileDescriptions().size()); 286 response = getAuthenticatedResource( 287 "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX + "Bprofile-1/comments/4").delete( 288 ClientResponse.class); 289 assertEquals(403, response.getStatus()); 290 291 292 response = getAuthenticatedResource( 293 "/registry/profiles/" + ProfileDescription.PROFILE_PREFIX + "Cprofile-1/comments/6").delete( 294 ClientResponse.class); 295 assertEquals(403, response.getStatus()); 296 315 297 } 316 298
Note: See TracChangeset
for help on using the changeset viewer.