Revision 2260
Added by sgarg almost 20 years ago
AccessControlTest.java | ||
---|---|---|
58 | 58 |
private String anotherpassword = "@mcanotherpassword@"; |
59 | 59 |
private String prefix = "test"; |
60 | 60 |
private String newdocid = null; |
61 |
private String onlineDocid = null; |
|
62 | 61 |
private String testdocument = ""; |
62 |
private String onlineDocid; |
|
63 | 63 |
private String onlinetestdatafile1 = "test/onlineDataFile1"; |
64 | 64 |
private String onlinetestdatafile2 = "test/onlineDataFile2"; |
65 | 65 |
|
... | ... | |
208 | 208 |
|
209 | 209 |
testDocument += "</dataset>"; |
210 | 210 |
|
211 |
// if(inlineAccessBlock1 != null || inlineAccessBlock2 != null || |
|
212 |
// onlineAccessBlock1 != null || onlineAccessBlock2 != null){ |
|
213 |
// testDocument += "<addtionalMetadata>"; |
|
214 |
// } |
|
215 |
|
|
216 | 211 |
if (inlineAccessBlock1 != null) { |
217 | 212 |
testDocument += "<additionalMetadata>"; |
218 | 213 |
testDocument += "<describes>inlineEntity1</describes>"; |
... | ... | |
284 | 279 |
TestSuite suite = new TestSuite(); |
285 | 280 |
suite.addTest(new AccessControlTest("initialize")); |
286 | 281 |
// Test basic functions |
287 |
//suite.addTest(new AccessControlTest("login")); |
|
288 |
//suite.addTest(new AccessControlTest("insert")); |
|
289 |
//suite.addTest(new AccessControlTest("read")); |
|
290 |
//suite.addTest(new AccessControlTest("update")); |
|
291 |
//suite.addTest(new AccessControlTest("delete")); |
|
292 |
// Tests when no access is specified |
|
293 |
//suite.addTest(new AccessControlTest("documentTest")); |
|
294 |
//suite.addTest(new AccessControlTest("documentWithInlineDataTest")); |
|
295 |
//suite.addTest(new AccessControlTest("documentWithOnlineDataTest")); |
|
296 |
suite.addTest(new AccessControlTest("onlineDataCasesTest_1")); |
|
297 |
suite.addTest(new AccessControlTest("onlineDataCasesTest_2")); |
|
298 |
suite.addTest(new AccessControlTest("onlineDataCasesTest_3")); |
|
282 |
suite.addTest(new AccessControlTest("documentTest")); |
|
283 |
suite.addTest(new AccessControlTest("AccessControlTestForPublic")); |
|
299 | 284 |
|
300 |
//suite.addTest(new AccessControlTest("noAccessSpecified_Random")); |
|
301 |
//suite.addTest(new AccessControlTest("noAccessSpecified_Public")); |
|
302 |
|
|
303 | 285 |
return suite; |
304 | 286 |
} |
305 | 287 |
|
306 |
/** ********* |
|
307 |
* Test the case when no access is specified and owner is logged in |
|
308 |
* No online or inline data is involved |
|
309 |
*/ |
|
310 |
|
|
311 |
public void onlineDataCasesTest_1() { |
|
312 |
try { |
|
313 |
/////////Case 1.///////////////////// |
|
314 |
// upload an online document |
|
315 |
onlineDocid = generateDocid(); |
|
316 |
m.login(username, password); |
|
317 |
uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false); |
|
318 |
m.logout(); |
|
319 |
|
|
320 |
// write a document with no access rules from a |
|
321 |
// different userid which refers to this document |
|
322 |
m.login(anotheruser, anotherpassword); |
|
323 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
324 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
325 |
null, null, null, null, null, null); |
|
326 |
newdocid = generateDocid(); |
|
327 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
328 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, false); |
|
329 |
|
|
330 |
m.logout(); |
|
331 |
m.login(anotheruser, anotherpassword); |
|
332 |
|
|
333 |
// write a document with access rules from a |
|
334 |
// different userid which refers to this document |
|
335 |
testdocument = getTestEmlDoc("Another insert", null, null, |
|
336 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
337 |
null, getAccessBlock(anotheruser, true, |
|
338 |
false, false, false, true), |
|
339 |
null, null, null, null); |
|
340 |
newdocid = generateDocid(); |
|
341 |
insertDocid(newdocid + ".1", testdocument, FAILURE, true); |
|
342 |
|
|
343 |
m.logout(); |
|
344 |
|
|
345 |
/////////Case 2.///////////////////// |
|
346 |
// upload an online document |
|
347 |
onlineDocid = generateDocid(); |
|
348 |
m.login(username, password); |
|
349 |
uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false); |
|
350 |
|
|
351 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
352 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
353 |
null, null, |
|
354 |
null, null, null, null); |
|
355 |
newdocid = generateDocid(); |
|
356 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
357 |
|
|
358 |
m.logout(); |
|
359 |
|
|
360 |
// write a document with no access rules from a |
|
361 |
// different userid which refers to this document |
|
362 |
m.login(anotheruser, anotherpassword); |
|
363 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
364 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
365 |
null, null, null, null, null, null); |
|
366 |
newdocid = generateDocid(); |
|
367 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
368 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, false); |
|
369 |
|
|
370 |
m.logout(); |
|
371 |
m.login(anotheruser, anotherpassword); |
|
372 |
// write a document with access rules from a |
|
373 |
// different userid which refers to this document |
|
374 |
testdocument = getTestEmlDoc("Another insert", null, null, |
|
375 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
376 |
null, getAccessBlock(anotheruser, true, |
|
377 |
false, false, false, true), |
|
378 |
null, null, null, null); |
|
379 |
newdocid = generateDocid(); |
|
380 |
insertDocid(newdocid + ".1", testdocument, FAILURE, true); |
|
381 |
|
|
382 |
m.logout(); |
|
383 |
} |
|
384 |
catch (MetacatAuthException mae) { |
|
385 |
fail("Authorization failed:\n" + mae.getMessage()); |
|
386 |
} |
|
387 |
catch (MetacatInaccessibleException mie) { |
|
388 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
|
389 |
} |
|
390 |
catch (Exception e) { |
|
391 |
fail("General exception:\n" + e.getMessage()); |
|
392 |
} |
|
393 |
} |
|
394 |
|
|
395 |
public void onlineDataCasesTest_2() { |
|
396 |
try { |
|
397 |
|
|
398 |
/////////Case 3.///////////////////// |
|
399 |
// upload an online document |
|
400 |
onlineDocid = generateDocid(); |
|
401 |
m.login(username, password); |
|
402 |
uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false); |
|
403 |
|
|
404 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
405 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
406 |
null, getAccessBlock(anotheruser, true, |
|
407 |
true, false, false, false), |
|
408 |
null, null, null, null); |
|
409 |
newdocid = generateDocid(); |
|
410 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
411 |
|
|
412 |
m.logout(); |
|
413 |
|
|
414 |
// write a document with no access rules from a |
|
415 |
// different userid which refers to this document |
|
416 |
m.login(anotheruser, anotherpassword); |
|
417 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
418 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
419 |
null, null, null, null, null, null); |
|
420 |
newdocid = generateDocid(); |
|
421 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
422 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, false); |
|
423 |
|
|
424 |
m.logout(); |
|
425 |
m.login(anotheruser, anotherpassword); |
|
426 |
|
|
427 |
// write a document with access rules from a |
|
428 |
// different userid which refers to this document |
|
429 |
testdocument = getTestEmlDoc("Another insert", null, null, |
|
430 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
431 |
null, getAccessBlock(anotheruser, true, |
|
432 |
false, false, false, true), |
|
433 |
null, null, null, null); |
|
434 |
newdocid = generateDocid(); |
|
435 |
insertDocid(newdocid + ".1", testdocument, FAILURE, true); |
|
436 |
|
|
437 |
m.logout(); |
|
438 |
|
|
439 |
/////////Case 4.///////////////////// |
|
440 |
// upload an online document |
|
441 |
onlineDocid = generateDocid(); |
|
442 |
m.login(username, password); |
|
443 |
uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false); |
|
444 |
|
|
445 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
446 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
447 |
null, getAccessBlock(anotheruser, true, |
|
448 |
false, true, false, false), |
|
449 |
null, null, null, null); |
|
450 |
newdocid = generateDocid(); |
|
451 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
452 |
|
|
453 |
m.logout(); |
|
454 |
|
|
455 |
// write a document with no access rules from a |
|
456 |
// different userid which refers to this document |
|
457 |
m.login(anotheruser, anotherpassword); |
|
458 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
459 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
460 |
null, null, null, null, null, null); |
|
461 |
newdocid = generateDocid(); |
|
462 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
463 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, false); |
|
464 |
|
|
465 |
m.logout(); |
|
466 |
m.login(anotheruser, anotherpassword); |
|
467 |
|
|
468 |
// write a document with access rules from a |
|
469 |
// different userid which refers to this document |
|
470 |
testdocument = getTestEmlDoc("Another insert", null, null, |
|
471 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
472 |
null, getAccessBlock(anotheruser, true, |
|
473 |
false, false, false, true), |
|
474 |
null, null, null, null); |
|
475 |
newdocid = generateDocid(); |
|
476 |
insertDocid(newdocid + ".1", testdocument, FAILURE, true); |
|
477 |
|
|
478 |
m.logout(); |
|
479 |
|
|
480 |
/////////Case 5.///////////////////// |
|
481 |
// upload an online document |
|
482 |
onlineDocid = generateDocid(); |
|
483 |
m.login(username, password); |
|
484 |
uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false); |
|
485 |
|
|
486 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
487 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
488 |
null, getAccessBlock(anotheruser, true, |
|
489 |
false, false, false, true), |
|
490 |
null, null, null, null); |
|
491 |
newdocid = generateDocid(); |
|
492 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
493 |
|
|
494 |
m.logout(); |
|
495 |
|
|
496 |
// write a document with no access rules from a |
|
497 |
// different userid which refers to this document |
|
498 |
m.login(anotheruser, anotherpassword); |
|
499 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
500 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
501 |
null, null, null, null, null, null); |
|
502 |
newdocid = generateDocid(); |
|
503 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
504 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, false); |
|
505 |
|
|
506 |
m.logout(); |
|
507 |
m.login(anotheruser, anotherpassword); |
|
508 |
|
|
509 |
// write a document with access rules from a |
|
510 |
// different userid which refers to this document |
|
511 |
testdocument = getTestEmlDoc("Another insert", null, null, |
|
512 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
513 |
null, getAccessBlock(anotheruser, true, |
|
514 |
false, false, true, false), |
|
515 |
null, null, null, null); |
|
516 |
newdocid = generateDocid(); |
|
517 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
518 |
m.logout(); |
|
519 |
|
|
520 |
/////////Case 6.///////////////////// |
|
521 |
// upload an online document |
|
522 |
onlineDocid = generateDocid(); |
|
523 |
m.login(username, password); |
|
524 |
uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false); |
|
525 |
|
|
526 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
527 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
528 |
null, getAccessBlock(anotheruser, true, |
|
529 |
false, false, false, true), |
|
530 |
null, null, null, null); |
|
531 |
newdocid = generateDocid(); |
|
532 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
533 |
|
|
534 |
m.logout(); |
|
535 |
|
|
536 |
// write a document with no access rules from a |
|
537 |
// different userid which refers to this document |
|
538 |
m.login(anotheruser, anotherpassword); |
|
539 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
540 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
541 |
null, null, null, null, null, null); |
|
542 |
newdocid = generateDocid(); |
|
543 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
544 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, false); |
|
545 |
|
|
546 |
m.logout(); |
|
547 |
m.login(anotheruser, anotherpassword); |
|
548 |
|
|
549 |
// write a document with access rules from a |
|
550 |
// different userid which refers to this document |
|
551 |
testdocument = getTestEmlDoc("Another insert", null, null, |
|
552 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
553 |
null, getAccessBlock(anotheruser, true, |
|
554 |
true, false, false, false), |
|
555 |
null, null, null, null); |
|
556 |
newdocid = generateDocid(); |
|
557 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
558 |
|
|
559 |
m.logout(); |
|
560 |
} |
|
561 |
catch (MetacatAuthException mae) { |
|
562 |
fail("Authorization failed:\n" + mae.getMessage()); |
|
563 |
} |
|
564 |
catch (MetacatInaccessibleException mie) { |
|
565 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
|
566 |
} |
|
567 |
catch (Exception e) { |
|
568 |
fail("General exception:\n" + e.getMessage()); |
|
569 |
} |
|
570 |
} |
|
571 |
|
|
572 |
|
|
573 |
|
|
574 |
|
|
575 |
public void onlineDataCasesTest_4() { |
|
576 |
try { |
|
577 |
/////////Case 7.///////////////////// |
|
578 |
// upload an online document |
|
579 |
onlineDocid = generateDocid(); |
|
580 |
m.login(username, password); |
|
581 |
uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false); |
|
582 |
|
|
583 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
584 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
585 |
null, null, null, null, |
|
586 |
getAccessBlock(anotheruser, true, |
|
587 |
true, false, false, false), null); |
|
588 |
newdocid = generateDocid(); |
|
589 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
590 |
|
|
591 |
m.logout(); |
|
592 |
|
|
593 |
// write a document with no access rules from a |
|
594 |
// different userid which refers to this document |
|
595 |
m.login(anotheruser, anotherpassword); |
|
596 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
597 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
598 |
null, null, null, null, null, null); |
|
599 |
newdocid = generateDocid(); |
|
600 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
601 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, false); |
|
602 |
|
|
603 |
m.logout(); |
|
604 |
m.login(anotheruser, anotherpassword); |
|
605 |
|
|
606 |
// try to read the online data file |
|
607 |
readDocid(onlineDocid + ".1", SUCCESS, false); |
|
608 |
|
|
609 |
// write a document with access rules from a |
|
610 |
// different userid which refers to this document |
|
611 |
testdocument = getTestEmlDoc("Another insert", null, null, |
|
612 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
613 |
null, getAccessBlock(anotheruser, true, |
|
614 |
false, false, false, true), |
|
615 |
null, null, null, null); |
|
616 |
newdocid = generateDocid(); |
|
617 |
insertDocid(newdocid + ".1", testdocument, FAILURE, true); |
|
618 |
|
|
619 |
m.logout(); |
|
620 |
|
|
621 |
/////////Case 8.///////////////////// |
|
622 |
// upload an online document |
|
623 |
onlineDocid = generateDocid(); |
|
624 |
m.login(username, password); |
|
625 |
uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false); |
|
626 |
|
|
627 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
628 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
629 |
null, null, null, null, |
|
630 |
getAccessBlock(anotheruser, true, |
|
631 |
false, true, false, false), null); |
|
632 |
newdocid = generateDocid(); |
|
633 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
634 |
|
|
635 |
m.logout(); |
|
636 |
|
|
637 |
// write a document with no access rules from a |
|
638 |
// different userid which refers to this document |
|
639 |
m.login(anotheruser, anotherpassword); |
|
640 |
|
|
641 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
642 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
643 |
null, null, null, null, null, null); |
|
644 |
newdocid = generateDocid(); |
|
645 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
646 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, false); |
|
647 |
|
|
648 |
m.logout(); |
|
649 |
m.login(anotheruser, anotherpassword); |
|
650 |
|
|
651 |
// try to read the online data file |
|
652 |
readDocid(onlineDocid + ".1", FAILURE, true); |
|
653 |
|
|
654 |
// write a document with access rules from a |
|
655 |
// different userid which refers to this document |
|
656 |
testdocument = getTestEmlDoc("Another insert", null, null, |
|
657 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
658 |
null, getAccessBlock(anotheruser, true, |
|
659 |
false, false, false, true), |
|
660 |
null, null, null, null); |
|
661 |
newdocid = generateDocid(); |
|
662 |
insertDocid(newdocid + ".1", testdocument, FAILURE, true); |
|
663 |
|
|
664 |
m.logout(); |
|
665 |
|
|
666 |
/////////Case 9.///////////////////// |
|
667 |
// upload an online document |
|
668 |
onlineDocid = generateDocid(); |
|
669 |
m.login(username, password); |
|
670 |
uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false); |
|
671 |
|
|
672 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
673 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
674 |
null, null, null, null, |
|
675 |
getAccessBlock(anotheruser, true, |
|
676 |
false, false, true, false), null); |
|
677 |
newdocid = generateDocid(); |
|
678 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
679 |
|
|
680 |
m.logout(); |
|
681 |
|
|
682 |
// write a document with no access rules from a |
|
683 |
// different userid which refers to this document |
|
684 |
m.login(anotheruser, anotherpassword); |
|
685 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
686 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
687 |
null, null, null, null, null, null); |
|
688 |
newdocid = generateDocid(); |
|
689 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
690 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, false); |
|
691 |
|
|
692 |
m.logout(); |
|
693 |
m.login(anotheruser, anotherpassword); |
|
694 |
|
|
695 |
// try to read the online data file |
|
696 |
readDocid(onlineDocid + ".1", FAILURE, true); |
|
697 |
|
|
698 |
// write a document with access rules from a |
|
699 |
// different userid which refers to this document |
|
700 |
testdocument = getTestEmlDoc("Another insert", null, null, |
|
701 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
702 |
null, getAccessBlock(anotheruser, true, |
|
703 |
false, false, true, false), |
|
704 |
null, null, null, null); |
|
705 |
newdocid = generateDocid(); |
|
706 |
//ERRRRRRRRRRRRRRRROR |
|
707 |
//insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
708 |
|
|
709 |
/////////Case 10.///////////////////// |
|
710 |
// upload an online document |
|
711 |
onlineDocid = generateDocid(); |
|
712 |
m.login(username, password); |
|
713 |
uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false); |
|
714 |
|
|
715 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
716 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
717 |
null, null, null, null, |
|
718 |
getAccessBlock(anotheruser, true, |
|
719 |
false, false, false, true), null); |
|
720 |
newdocid = generateDocid(); |
|
721 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
722 |
|
|
723 |
m.logout(); |
|
724 |
|
|
725 |
// write a document with no access rules from a |
|
726 |
// different userid which refers to this document |
|
727 |
m.login(anotheruser, anotherpassword); |
|
728 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
729 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
730 |
null, null, null, null, null, null); |
|
731 |
newdocid = generateDocid(); |
|
732 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
733 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, false); |
|
734 |
|
|
735 |
m.logout(); |
|
736 |
m.login(anotheruser, anotherpassword); |
|
737 |
|
|
738 |
// try to read the online data file |
|
739 |
readDocid(onlineDocid + ".1", SUCCESS, false); |
|
740 |
|
|
741 |
// write a document with access rules from a |
|
742 |
// different userid which refers to this document |
|
743 |
testdocument = getTestEmlDoc("Another insert", null, null, |
|
744 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
745 |
null, getAccessBlock(anotheruser, true, |
|
746 |
true, false, false, false), |
|
747 |
null, null, null, null); |
|
748 |
newdocid = generateDocid(); |
|
749 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
750 |
|
|
751 |
m.logout(); |
|
752 |
|
|
753 |
} |
|
754 |
catch (MetacatAuthException mae) { |
|
755 |
fail("Authorization failed:\n" + mae.getMessage()); |
|
756 |
} |
|
757 |
catch (MetacatInaccessibleException mie) { |
|
758 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
|
759 |
} |
|
760 |
catch (Exception e) { |
|
761 |
fail("General exception:\n" + e.getMessage()); |
|
762 |
} |
|
763 |
} |
|
764 |
|
|
765 |
|
|
766 |
|
|
767 | 288 |
/** |
768 | 289 |
* Run an initial test that always passes to check that the test |
769 | 290 |
* harness is working. |
... | ... | |
772 | 293 |
assertTrue(1 == 1); |
773 | 294 |
} |
774 | 295 |
|
775 |
/** |
|
776 |
* Test the login() function with valid credentials |
|
777 |
*/ |
|
778 |
public void login() { |
|
779 |
// Try a valid login |
|
780 |
try { |
|
781 |
String response = m.login(username, password); |
|
782 |
System.err.println("Login response: " + response); |
|
783 |
assertTrue(response != null); |
|
784 |
assertTrue(response.indexOf("<login>") != -1); |
|
785 |
String sessionId = m.getSessionId(); |
|
786 |
System.err.println("Session ID: " + m.getSessionId()); |
|
787 |
assertTrue(sessionId != null); |
|
788 |
assertTrue(response.indexOf(m.getSessionId()) != -1); |
|
789 |
} |
|
790 |
catch (MetacatAuthException mae) { |
|
791 |
fail("Authorization failed:\n" + mae.getMessage()); |
|
792 |
} |
|
793 |
catch (MetacatInaccessibleException mie) { |
|
794 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
|
795 |
} |
|
796 |
} |
|
797 |
|
|
798 |
/** |
|
799 |
* Test the insert() function with a known document |
|
800 |
*/ |
|
801 |
public void insert() { |
|
802 |
try { |
|
803 |
testdocument = getTestEmlDoc("Testing insert", testEmlInlineBlock1, |
|
804 |
null, null, null, null, |
|
805 |
null, null, null, null); |
|
806 |
String identifier = newdocid + ".1"; |
|
807 |
m.login(username, password); |
|
808 |
String response = m.insert(identifier, |
|
809 |
new StringReader(testdocument), null); |
|
810 |
assertTrue(response.indexOf("<success>") != -1); |
|
811 |
assertTrue(response.indexOf(identifier) != -1); |
|
812 |
System.err.println(response); |
|
813 |
} |
|
814 |
catch (MetacatAuthException mae) { |
|
815 |
fail("Authorization failed:\n" + mae.getMessage()); |
|
816 |
} |
|
817 |
catch (MetacatInaccessibleException mie) { |
|
818 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
|
819 |
} |
|
820 |
catch (InsufficientKarmaException ike) { |
|
821 |
assertTrue(1 == 1); |
|
822 |
fail("Insufficient karma:\n" + ike.getMessage()); |
|
823 |
} |
|
824 |
catch (MetacatException me) { |
|
825 |
fail("Metacat Error:\n" + me.getMessage()); |
|
826 |
} |
|
827 |
catch (Exception e) { |
|
828 |
fail("General exception:\n" + e.getMessage()); |
|
829 |
} |
|
830 |
} |
|
831 |
|
|
832 |
/** |
|
833 |
* The read() function |
|
834 |
*/ |
|
835 |
public void read() { |
|
836 |
try { |
|
837 |
testdocument = getTestEmlDoc("Testing insert", testEmlInlineBlock1, null, |
|
838 |
null, null, null, null, null, null, null); |
|
839 |
|
|
840 |
m.login(username, password); |
|
841 |
Reader r = m.read(newdocid + ".1"); |
|
842 |
String doc = IOUtil.getAsString(r, true); |
|
843 |
assertTrue(doc.equals(testdocument)); |
|
844 |
} |
|
845 |
catch (MetacatAuthException mae) { |
|
846 |
fail("Authorization failed:\n" + mae.getMessage()); |
|
847 |
} |
|
848 |
catch (MetacatInaccessibleException mie) { |
|
849 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
|
850 |
} |
|
851 |
catch (Exception e) { |
|
852 |
fail("General exception:\n" + e.getMessage()); |
|
853 |
} |
|
854 |
} |
|
855 |
|
|
856 |
/** |
|
857 |
* Test the update() function with a known document |
|
858 |
*/ |
|
859 |
public void update() { |
|
860 |
try { |
|
861 |
testdocument = getTestEmlDoc("Testing update", testEmlInlineBlock1, null, |
|
862 |
null, null, null, null, null, null, null); |
|
863 |
String identifier = newdocid + ".2"; |
|
864 |
m.login(username, password); |
|
865 |
String response = m.update(identifier, |
|
866 |
new StringReader(testdocument), null); |
|
867 |
assertTrue(response.indexOf("<success>") != -1); |
|
868 |
assertTrue(response.indexOf(identifier) != -1); |
|
869 |
System.err.println(response); |
|
870 |
|
|
871 |
} |
|
872 |
catch (MetacatAuthException mae) { |
|
873 |
fail("Authorization failed:\n" + mae.getMessage()); |
|
874 |
} |
|
875 |
catch (MetacatInaccessibleException mie) { |
|
876 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
|
877 |
} |
|
878 |
catch (InsufficientKarmaException ike) { |
|
879 |
fail("Insufficient karma:\n" + ike.getMessage()); |
|
880 |
} |
|
881 |
catch (MetacatException me) { |
|
882 |
fail("Metacat Error:\n" + me.getMessage()); |
|
883 |
} |
|
884 |
catch (Exception e) { |
|
885 |
fail("General exception:\n" + e.getMessage()); |
|
886 |
} |
|
887 |
} |
|
888 |
|
|
889 |
/** |
|
890 |
* Test the delete() function with a known document |
|
891 |
*/ |
|
892 |
public void delete() { |
|
893 |
try { |
|
894 |
String identifier = newdocid + ".2"; |
|
895 |
m.login(username, password); |
|
896 |
String response = m.delete(identifier); |
|
897 |
assertTrue(response.indexOf("<success>") != -1); |
|
898 |
System.err.println(response); |
|
899 |
|
|
900 |
} |
|
901 |
catch (MetacatAuthException mae) { |
|
902 |
fail("Authorization failed:\n" + mae.getMessage()); |
|
903 |
} |
|
904 |
catch (MetacatInaccessibleException mie) { |
|
905 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
|
906 |
} |
|
907 |
catch (InsufficientKarmaException ike) { |
|
908 |
fail("Insufficient karma:\n" + ike.getMessage()); |
|
909 |
} |
|
910 |
catch (MetacatException me) { |
|
911 |
fail("Metacat Error:\n" + me.getMessage()); |
|
912 |
} |
|
913 |
catch (Exception e) { |
|
914 |
fail("General exception:\n" + e.getMessage()); |
|
915 |
} |
|
916 |
} |
|
917 |
|
|
918 | 296 |
/** ********* |
919 | 297 |
* Test the case when no access is specified and owner is logged in |
920 | 298 |
* No online or inline data is involved |
299 |
* -> an user inserts a document and is able to read it, update it, |
|
300 |
* set permissions on it and delete it |
|
301 |
* -> another user is not able to do anything with the document |
|
302 |
* when no access is specified for that user |
|
303 |
* -> test what all the other user can do when read only, write only and |
|
304 |
* change permissions only permissions are specified |
|
305 |
* |
|
921 | 306 |
*/ |
922 | 307 |
public void documentTest() { |
923 | 308 |
try { |
... | ... | |
931 | 316 |
null, null, |
932 | 317 |
null, null, null, null, null, null); |
933 | 318 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
319 |
|
|
320 |
// read the document |
|
934 | 321 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, false); |
935 | 322 |
|
936 | 323 |
// update the document |
... | ... | |
940 | 327 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, false); |
941 | 328 |
|
942 | 329 |
///////////////////////////// |
330 |
// check what the another user can do |
|
331 |
m.logout(); |
|
332 |
m.login(anotheruser, anotherpassword); |
|
333 |
|
|
334 |
// check if the user mentioned is able to read/update/delete the document |
|
335 |
readDocidWhichEqualsDoc(newdocid + ".2", testdocument, FAILURE, true); |
|
336 |
updateDocid(newdocid + ".3", testdocument, FAILURE, true); |
|
337 |
deleteDocid(newdocid + ".2", FAILURE, true); |
|
338 |
|
|
339 |
///////////////////////////// |
|
943 | 340 |
// update the document access control - read only |
341 |
m.logout(); |
|
342 |
m.login(username, password); |
|
343 |
|
|
944 | 344 |
testdocument = getTestEmlDoc("Testing update access block", |
945 | 345 |
null, null, null, |
946 | 346 |
null, getAccessBlock(anotheruser, true, |
947 |
true, false, false, false), |
|
347 |
true, false, false, false),
|
|
948 | 348 |
null, null, null, null); |
949 | 349 |
updateDocid(newdocid + ".3", testdocument, SUCCESS, false); |
950 | 350 |
readDocidWhichEqualsDoc(newdocid + ".3", testdocument, SUCCESS, false); |
... | ... | |
958 | 358 |
testdocument = getTestEmlDoc("Testing update from another user", |
959 | 359 |
null, null, null, |
960 | 360 |
null, getAccessBlock(anotheruser, true, |
961 |
true, false, false, false), |
|
361 |
true, false, false, false),
|
|
962 | 362 |
null, null, null, null); |
963 | 363 |
updateDocid(newdocid + ".4", testdocument, FAILURE, true); |
964 | 364 |
|
965 | 365 |
// or the permissions |
966 |
testdocument = getTestEmlDoc( |
|
967 |
"Testing perm update from another user", |
|
968 |
null, null, null, |
|
969 |
null, getAccessBlock(anotheruser, true, |
|
970 |
false, false, false, true), |
|
971 |
null, null, null, null); |
|
366 |
testdocument = getTestEmlDoc("Testing update access block", |
|
367 |
null, null, null, |
|
368 |
null, getAccessBlock(anotheruser, true, |
|
369 |
false, false, false, true), |
|
370 |
null, null, null, null); |
|
972 | 371 |
updateDocid(newdocid + ".4", testdocument, FAILURE, true); |
372 |
|
|
373 |
// or delete the document |
|
374 |
deleteDocid(newdocid + ".3", FAILURE, true); |
|
375 |
|
|
973 | 376 |
m.logout(); |
974 | 377 |
m.login(username, password); |
975 | 378 |
|
... | ... | |
978 | 381 |
testdocument = getTestEmlDoc("Testing update access block", |
979 | 382 |
null, null, null, |
980 | 383 |
null, getAccessBlock(anotheruser, true, |
981 |
false, true, false, false), |
|
384 |
false, true, false, false),
|
|
982 | 385 |
null, null, null, null); |
983 | 386 |
updateDocid(newdocid + ".4", testdocument, SUCCESS, false); |
984 | 387 |
readDocidWhichEqualsDoc(newdocid + ".4", testdocument, SUCCESS, false); |
... | ... | |
989 | 392 |
readDocidWhichEqualsDoc(newdocid + ".4", testdocument, FAILURE, true); |
990 | 393 |
|
991 | 394 |
// should be able to update the document |
992 |
testdocument = getTestEmlDoc("Testing update access block", |
|
993 |
null, null, null, |
|
994 |
null, getAccessBlock(anotheruser, true, |
|
995 |
false, true, false, false), |
|
996 |
null, null, null, null); |
|
395 |
|
|
997 | 396 |
//System.out.println(testdocument); |
998 | 397 |
// ERRRRRRRRRRRRROR |
999 |
//updateDocid(newdocid + ".6", testdocument, SUCCESS, false);
|
|
398 |
//updateDocid(newdocid + ".5", testdocument, SUCCESS, false);
|
|
1000 | 399 |
|
1001 | 400 |
// but not the permissions |
1002 |
testdocument = getTestEmlDoc("Testing update from another user",
|
|
401 |
testdocument = getTestEmlDoc("Testing update access block",
|
|
1003 | 402 |
null, null, null, |
1004 | 403 |
null, getAccessBlock(anotheruser, true, |
1005 |
false, true, false, true), |
|
404 |
false, true, false, true),
|
|
1006 | 405 |
null, null, null, null); |
1007 | 406 |
updateDocid(newdocid + ".5", testdocument, FAILURE, true); |
1008 | 407 |
|
408 |
// try to delete the document |
|
409 |
//deleteDocid(newdocid + ".5", FAILURE, true); |
|
410 |
deleteDocid(newdocid + ".4", FAILURE, true); |
|
411 |
|
|
1009 | 412 |
m.logout(); |
1010 | 413 |
m.login(username, password); |
1011 | 414 |
|
... | ... | |
1033 | 436 |
updateDocid(newdocid + ".6", testdocument, FAILURE, true); |
1034 | 437 |
|
1035 | 438 |
// but can chg the permissions |
1036 |
testdocument = getTestEmlDoc("Testing update from another user",
|
|
439 |
testdocument = getTestEmlDoc("Testing update access block",
|
|
1037 | 440 |
null, null, null, |
1038 | 441 |
null, getAccessBlock(anotheruser, true, |
1039 |
false, false, false, true), |
|
442 |
false, false, false, true),
|
|
1040 | 443 |
null, null, null, null); |
1041 | 444 |
// ERRRRRRRROR |
1042 | 445 |
//updateDocid(newdocid + ".6", testdocument, SUCCESS, false); |
1043 | 446 |
|
447 |
// try to delete the document |
|
448 |
//deleteDocid(newdocid + ".6", FAILURE, true); |
|
449 |
deleteDocid(newdocid + ".5", FAILURE, true); |
|
450 |
|
|
1044 | 451 |
m.logout(); |
1045 | 452 |
m.login(username, password); |
1046 | 453 |
|
454 |
|
|
1047 | 455 |
///////////////////////////////// |
1048 |
// update the document access control - all
|
|
456 |
// update the document access control - read & write
|
|
1049 | 457 |
testdocument = getTestEmlDoc("Testing update access block", |
1050 | 458 |
null, null, null, |
1051 | 459 |
null, getAccessBlock(anotheruser, true, |
1052 |
false, false, false, true),
|
|
460 |
true, true, false, false),
|
|
1053 | 461 |
null, null, null, null); |
1054 | 462 |
updateDocid(newdocid + ".7", testdocument, SUCCESS, false); |
1055 | 463 |
readDocidWhichEqualsDoc(newdocid + ".7", testdocument, SUCCESS, false); |
... | ... | |
1059 | 467 |
m.login(anotheruser, anotherpassword); |
1060 | 468 |
readDocidWhichEqualsDoc(newdocid + ".7", testdocument, SUCCESS, false); |
1061 | 469 |
|
1062 |
// should not be able to update the document |
|
1063 |
testdocument = getTestEmlDoc("Testing update from another user", |
|
1064 |
null, null, null, |
|
1065 |
null, getAccessBlock(anotheruser, true, |
|
1066 |
false, false, false, true), |
|
1067 |
null, null, null, null); |
|
1068 |
updateDocid(newdocid + ".8", testdocument, SUCCESS, false); |
|
1069 |
readDocidWhichEqualsDoc(newdocid + ".8", testdocument, SUCCESS, false); |
|
470 |
// should be able to update the document |
|
471 |
//updateDocid(newdocid + ".8", testdocument, SUCCESS, false); |
|
1070 | 472 |
|
1071 |
// but can chg the permissions |
|
1072 |
testdocument = getTestEmlDoc("Testing update from another user",
|
|
473 |
// but cant chg the permissions
|
|
474 |
testdocument = getTestEmlDoc("Testing update access block",
|
|
1073 | 475 |
null, null, null, |
1074 | 476 |
null, getAccessBlock(anotheruser, true, |
1075 |
true, false, false, false),
|
|
477 |
false, false, false, true),
|
|
1076 | 478 |
null, null, null, null); |
1077 |
updateDocid(newdocid + ".9", testdocument, SUCCESS, false); |
|
1078 |
readDocidWhichEqualsDoc(newdocid + ".9", testdocument, SUCCESS, false); |
|
479 |
updateDocid(newdocid + ".9", testdocument, FAILURE, true); |
|
1079 | 480 |
|
1080 |
m.logout(); |
|
481 |
// try to delete the document |
|
482 |
// deleteDocid(newdocid + ".8", FAILURE, true); |
|
483 |
deleteDocid(newdocid + ".7", FAILURE, true); |
|
1081 | 484 |
|
1082 |
// delete the document |
|
1083 |
m.login(username, password); |
|
1084 |
deleteDocid(newdocid + ".9", SUCCESS); |
|
1085 | 485 |
m.logout(); |
1086 |
} |
|
1087 |
catch (MetacatAuthException mae) { |
|
1088 |
fail("Authorization failed:\n" + mae.getMessage()); |
|
1089 |
} |
|
1090 |
catch (MetacatInaccessibleException mie) { |
|
1091 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
|
1092 |
} |
|
1093 |
catch (Exception e) { |
|
1094 |
fail("General exception:\n" + e.getMessage()); |
|
1095 |
} |
|
1096 |
|
|
1097 |
} |
|
1098 |
|
|
1099 |
/** ********* |
|
1100 |
* Test the case when no access is specified and owner is logged in |
|
1101 |
* Only inline data is involved |
|
1102 |
*/ |
|
1103 |
public void documentWithInlineDataTest() { |
|
1104 |
try { |
|
1105 |
newdocid = generateDocid(); |
|
1106 |
|
|
1107 |
// login |
|
1108 | 486 |
m.login(username, password); |
1109 | 487 |
|
1110 |
// insert a document |
|
1111 |
testdocument = getTestEmlDoc("Testing insert", testEmlInlineBlock1, |
|
1112 |
null, null, null, null, |
|
1113 |
null, null, null, null); |
|
1114 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
1115 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, true); |
|
1116 | 488 |
|
1117 |
// update the document |
|
1118 |
testdocument = getTestEmlDoc("Testing update", testEmlInlineBlock1, |
|
1119 |
null, null, null, null, |
|
1120 |
null, null, null, null); |
|
1121 |
updateDocid(newdocid + ".2", testdocument, SUCCESS, false); |
|
1122 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, true); |
|
1123 |
|
|
1124 |
// update by modifying inline data |
|
1125 |
testdocument = getTestEmlDoc("Testing update inline", |
|
1126 |
testEmlInlineBlock2, |
|
1127 |
null, null, null, null, |
|
1128 |
null, null, null, null); |
|
1129 |
updateDocid(newdocid + ".3", testdocument, SUCCESS, false); |
|
1130 |
readDocidWhichEqualsDoc(newdocid + ".3", testdocument, SUCCESS, true); |
|
1131 |
|
|
1132 |
// update by removing inline data |
|
1133 |
testdocument = getTestEmlDoc("Testing update inline", |
|
1134 |
null, |
|
1135 |
null, null, null, null, |
|
1136 |
null, null, null, null); |
|
1137 |
updateDocid(newdocid + ".4", testdocument, SUCCESS, false); |
|
1138 |
readDocidWhichEqualsDoc(newdocid + ".4", testdocument, SUCCESS, true); |
|
1139 |
|
|
1140 |
// update by introducing inline data |
|
1141 |
testdocument = getTestEmlDoc("Testing update inline", |
|
1142 |
testEmlInlineBlock1, |
|
1143 |
null, null, null, null, |
|
1144 |
null, null, null, null); |
|
1145 |
updateDocid(newdocid + ".5", testdocument, SUCCESS, false); |
|
1146 |
readDocidWhichEqualsDoc(newdocid + ".5", testdocument, SUCCESS, true); |
|
1147 |
|
|
1148 |
// read document and check if it is same as the document which was written |
|
1149 |
// the second time |
|
1150 |
|
|
1151 |
|
|
1152 |
///////////////////////////// |
|
1153 |
// update the document access control - read only |
|
489 |
///////////////////////////////// |
|
490 |
// update the document access control - read & change permissions |
|
1154 | 491 |
testdocument = getTestEmlDoc("Testing update access block", |
1155 |
testEmlInlineBlock2, |
|
1156 | 492 |
null, null, null, |
1157 |
getAccessBlock(anotheruser, true, |
|
1158 |
true, false, false, false),
|
|
493 |
null, getAccessBlock(anotheruser, true,
|
|
494 |
true, false, true, false),
|
|
1159 | 495 |
null, null, null, null); |
1160 |
updateDocid(newdocid + ".6", testdocument, SUCCESS, false);
|
|
1161 |
readDocidWhichEqualsDoc(newdocid + ".6", testdocument, SUCCESS, true);
|
|
496 |
updateDocid(newdocid + ".9", testdocument, SUCCESS, false);
|
|
497 |
readDocidWhichEqualsDoc(newdocid + ".9", testdocument, SUCCESS, false);
|
|
1162 | 498 |
|
1163 | 499 |
// check if the user mentioned is able to read the document |
1164 | 500 |
m.logout(); |
1165 | 501 |
m.login(anotheruser, anotherpassword); |
1166 |
readDocidWhichEqualsDoc(newdocid + ".6", testdocument, SUCCESS, true); |
|
1167 |
|
|
1168 |
// should not be able to update the document or the inline data |
|
502 |
readDocidWhichEqualsDoc(newdocid + ".9", testdocument, SUCCESS, false); |
|
503 |
// should not be able to update the document |
|
1169 | 504 |
testdocument = getTestEmlDoc("Testing update from another user", |
1170 |
testEmlInlineBlock1, null, null, null,
|
|
1171 |
getAccessBlock(anotheruser, true, |
|
1172 |
true, false, false, false),
|
|
505 |
null, null, null, |
|
506 |
null, getAccessBlock(anotheruser, true,
|
|
507 |
false, false, true, false),
|
|
1173 | 508 |
null, null, null, null); |
1174 |
updateDocid(newdocid + ".7", testdocument, FAILURE, true);
|
|
509 |
updateDocid(newdocid + ".10", testdocument, FAILURE, true);
|
|
1175 | 510 |
|
1176 |
// or the permissions
|
|
511 |
// but can chg the permissions
|
|
1177 | 512 |
testdocument = getTestEmlDoc("Testing update access block", |
1178 |
testEmlInlineBlock2, |
|
1179 |
null, null, null, null, |
|
1180 |
null, null, null, null); |
|
1181 |
updateDocid(newdocid + ".7", testdocument, FAILURE, true); |
|
1182 |
|
|
1183 |
m.logout(); |
|
1184 |
m.login(username, password); |
|
1185 |
|
|
1186 |
///////////////////////////// |
|
1187 |
// update the document access control - write only |
|
1188 |
testdocument = getTestEmlDoc("Testing update access block", |
|
1189 |
testEmlInlineBlock2, |
|
1190 | 513 |
null, null, null, |
1191 |
getAccessBlock(anotheruser, true, |
|
1192 |
false, true, false, false),
|
|
514 |
null, getAccessBlock(anotheruser, true,
|
|
515 |
false, false, false, true),
|
|
1193 | 516 |
null, null, null, null); |
1194 |
updateDocid(newdocid + ".7", testdocument, SUCCESS, false); |
|
1195 |
readDocidWhichEqualsDoc(newdocid + ".7", testdocument, SUCCESS, false); |
|
517 |
//updateDocid(newdocid + ".10", testdocument, SUCCESS, false); |
|
1196 | 518 |
|
1197 |
// check if the user mentioned is able to read the document |
|
1198 |
m.logout(); |
|
1199 |
m.login(anotheruser, anotherpassword); |
|
1200 |
readDocidWhichEqualsDoc(newdocid + ".7", testdocument, FAILURE, true); |
|
519 |
// try to delete the document |
|
520 |
// deleteDocid(newdocid + ".10", FAILURE, true); |
|
521 |
deleteDocid(newdocid + ".9", FAILURE, true); |
|
1201 | 522 |
|
1202 |
// should be able to update the document or the inline data |
|
1203 |
testdocument = getTestEmlDoc("Testing update from another user", |
|
1204 |
testEmlInlineBlock1, null, null, null, |
|
1205 |
getAccessBlock(anotheruser, true, |
|
1206 |
false, true, false, false), |
|
1207 |
null, null, null, null); |
|
1208 |
// ERRRRROR |
|
1209 |
//updateDocid(newdocid + ".8", testdocument, SUCCESS, false); |
|
1210 |
|
|
1211 |
// but not the permissions |
|
1212 |
testdocument = getTestEmlDoc("Testing update access block", |
|
1213 |
testEmlInlineBlock2, |
|
1214 |
null, null, null, null, |
|
1215 |
null, null, null, null); |
|
1216 |
updateDocid(newdocid + ".9", testdocument, FAILURE, true); |
|
1217 |
|
|
1218 | 523 |
m.logout(); |
1219 | 524 |
m.login(username, password); |
1220 | 525 |
|
1221 |
///////////////////////////// |
|
1222 |
// update the document access control - change permission only |
|
1223 |
testdocument = getTestEmlDoc("Testing update access block", |
|
1224 |
testEmlInlineBlock2, |
|
1225 |
null, null, null, |
|
1226 |
getAccessBlock(anotheruser, true, |
|
1227 |
false, false, true, false), |
|
1228 |
null, null, null, null); |
|
1229 |
updateDocid(newdocid + ".9", testdocument, SUCCESS, false); |
|
1230 |
readDocidWhichEqualsDoc(newdocid + ".9", testdocument, SUCCESS, false); |
|
1231 | 526 |
|
1232 |
// check if the user mentioned is able to read the document |
|
1233 |
m.logout(); |
|
1234 |
m.login(anotheruser, anotherpassword); |
|
1235 |
readDocidWhichEqualsDoc(newdocid + ".9", testdocument, FAILURE, true); |
|
1236 | 527 |
|
1237 |
// should be able to update the document or the inline data |
|
1238 |
testdocument = getTestEmlDoc("Testing update from another user", |
|
1239 |
testEmlInlineBlock1, null, null, null, |
|
1240 |
getAccessBlock(anotheruser, true, |
|
1241 |
false, false, true, false), |
|
1242 |
null, null, null, null); |
|
1243 |
updateDocid(newdocid + ".10", testdocument, FAILURE, true); |
|
1244 |
|
|
1245 |
// or the permissions |
|
528 |
///////////////////////////////// |
|
529 |
// update the document access control - read & change permissions |
|
1246 | 530 |
testdocument = getTestEmlDoc("Testing update access block", |
1247 |
testEmlInlineBlock2, |
|
1248 |
null, null, null, null, |
|
1249 |
null, null, null, null); |
|
1250 |
// ERRROR |
|
1251 |
//updateDocid(newdocid + ".10", testdocument, SUCCESS, false); |
|
1252 |
|
|
1253 |
m.logout(); |
|
1254 |
m.login(username, password); |
|
1255 |
|
|
1256 |
///////////////////////////// |
|
1257 |
// update the document access control - change permission only |
|
1258 |
testdocument = getTestEmlDoc("Testing update access block", |
|
1259 |
testEmlInlineBlock2, |
|
1260 | 531 |
null, null, null, |
1261 |
getAccessBlock(anotheruser, true, |
|
1262 |
false, false, false, true),
|
|
532 |
null, getAccessBlock(anotheruser, true,
|
|
533 |
true, false, true, false),
|
|
1263 | 534 |
null, null, null, null); |
1264 | 535 |
updateDocid(newdocid + ".11", testdocument, SUCCESS, false); |
1265 | 536 |
readDocidWhichEqualsDoc(newdocid + ".11", testdocument, SUCCESS, false); |
... | ... | |
1267 | 538 |
// check if the user mentioned is able to read the document |
1268 | 539 |
m.logout(); |
1269 | 540 |
m.login(anotheruser, anotherpassword); |
1270 |
readDocidWhichEqualsDoc(newdocid + ".11", testdocument, SUCCESS, false); |
|
541 |
readDocidWhichEqualsDoc(newdocid + ".11", testdocument, SUCCESS, false);
|
|
1271 | 542 |
|
1272 |
// should be able to update the document or the inline data
|
|
543 |
// should not be able to update the document
|
|
1273 | 544 |
testdocument = getTestEmlDoc("Testing update from another user", |
1274 |
testEmlInlineBlock1, null, null, null,
|
|
1275 |
getAccessBlock(anotheruser, true, |
|
1276 |
false, false, false, true),
|
|
545 |
null, null, null, |
|
546 |
null, getAccessBlock(anotheruser, true,
|
|
547 |
false, false, true, false),
|
|
1277 | 548 |
null, null, null, null); |
1278 |
updateDocid(newdocid + ".12", testdocument, SUCCESS, false);
|
|
1279 |
|
|
1280 |
// or the permissions
|
|
1281 |
testdocument = getTestEmlDoc("Testing update access block",
|
|
1282 |
testEmlInlineBlock2,
|
|
1283 |
null, null, null, null,
|
|
549 |
updateDocid(newdocid + ".12", testdocument, FAILURE, true);
|
|
550 |
// but can chg the permissions |
|
551 |
testdocument = getTestEmlDoc("Testing update from another user",
|
|
552 |
null, null, null,
|
|
553 |
null, getAccessBlock(anotheruser, true,
|
|
554 |
false, false, false, true),
|
|
1284 | 555 |
null, null, null, null); |
1285 |
updateDocid(newdocid + ".13", testdocument, SUCCESS, false); |
|
556 |
// ERRRRRRRRRRRRRRRR |
|
557 |
// updateDocid(newdocid + ".12", testdocument, SUCCESS, false); |
|
1286 | 558 |
|
1287 |
m.logout(); |
|
1288 |
m.login(username, password); |
|
559 |
// try to delete the document |
|
560 |
//deleteDocid(newdocid + ".12", FAILURE, true); |
|
561 |
deleteDocid(newdocid + ".11", FAILURE, true); |
|
1289 | 562 |
|
1290 |
// delete the document |
|
1291 |
deleteDocid(newdocid + ".13", SUCCESS); |
|
1292 | 563 |
m.logout(); |
1293 |
} |
|
1294 |
catch (MetacatAuthException mae) { |
|
1295 |
fail("Authorization failed:\n" + mae.getMessage()); |
|
1296 |
} |
|
1297 |
catch (MetacatInaccessibleException mie) { |
|
1298 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
|
1299 |
} |
|
1300 |
catch (Exception e) { |
|
1301 |
fail("General exception:\n" + e.getMessage()); |
|
1302 |
} |
|
1303 |
|
|
1304 |
} |
|
1305 |
|
|
1306 |
/** ********* |
|
1307 |
* Test the case when no access is specified and owner is logged in |
|
1308 |
* Only online data is involved |
|
1309 |
*/ |
|
1310 |
public void documentWithOnlineDataTest() { |
|
1311 |
try { |
|
1312 |
newdocid = generateDocid(); |
|
1313 |
|
|
1314 |
// login |
|
1315 | 564 |
m.login(username, password); |
1316 | 565 |
|
1317 |
// upload online document |
|
1318 |
onlineDocid = generateDocid(); |
|
1319 |
uploadDocid(onlineDocid + ".1", onlinetestdatafile2, SUCCESS, false); |
|
1320 | 566 |
|
1321 |
// try to access the online document from other userid |
|
1322 |
m.logout(); |
|
1323 |
m.login(anotheruser, anotherpassword); |
|
1324 |
readDocid(onlineDocid + ".1", FAILURE, true); |
|
1325 |
// **************** ERRRRRRRRRROR |
|
1326 |
//uploadDocid(onlineDocid + ".2", onlinetestdatafile2, FAILURE, true); |
|
1327 |
|
|
1328 |
m.logout(); |
|
1329 |
m.login(username, password); |
|
1330 |
|
|
1331 |
// insert a document |
|
1332 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
1333 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
1334 |
null, null, null, null, null, null); |
|
1335 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
1336 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, false); |
|
1337 |
|
|
1338 |
// update the document |
|
1339 |
testdocument = getTestEmlDoc("Testing update", null, null, |
|
1340 |
"ecogrid://knb/" + onlineDocid + ".1", |
|
1341 |
null, null, null, null, null, null); |
|
1342 |
updateDocid(newdocid + ".2", testdocument, SUCCESS, false); |
|
1343 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, true); |
|
1344 |
|
|
1345 |
// update the online data |
|
1346 |
uploadDocid(onlineDocid + ".2", onlinetestdatafile2, SUCCESS, false); |
|
1347 |
|
|
1348 |
// read document and check if it is same as the document which was written |
|
1349 |
// the second time |
|
1350 |
|
|
1351 |
///////////////////////////// |
|
1352 |
// update the document access control - read only |
|
1353 |
testdocument = getTestEmlDoc("Testing update access block", null, null, |
|
1354 |
"ecogrid://knb/" + onlineDocid + ".2", |
|
567 |
///////////////////////////////// |
|
568 |
// update the document access control - R, W, CP |
|
569 |
testdocument = getTestEmlDoc("Testing update access block", |
|
570 |
null, null, null, |
|
1355 | 571 |
null, getAccessBlock(anotheruser, true, |
1356 |
true, false, false, false),
|
|
572 |
true, true, true, false),
|
|
1357 | 573 |
null, null, null, null); |
1358 |
updateDocid(newdocid + ".3", testdocument, SUCCESS, false); |
|
1359 |
readDocidWhichEqualsDoc(newdocid + ".3", testdocument, SUCCESS, false); |
|
574 |
updateDocid(newdocid + ".13", testdocument, SUCCESS, false);
|
|
575 |
readDocidWhichEqualsDoc(newdocid + ".13", testdocument, SUCCESS, false);
|
|
1360 | 576 |
|
1361 | 577 |
// check if the user mentioned is able to read the document |
1362 |
// and online data |
|
1363 | 578 |
m.logout(); |
1364 | 579 |
m.login(anotheruser, anotherpassword); |
1365 |
readDocidWhichEqualsDoc(newdocid + ".3", testdocument, SUCCESS, false); |
|
1366 |
// should be able to read both versions of data |
|
1367 |
readDocid(onlineDocid + ".1", SUCCESS, false); |
|
1368 |
readDocid(onlineDocid + ".2", SUCCESS, false); |
|
580 |
readDocidWhichEqualsDoc(newdocid + ".13", testdocument, SUCCESS, false); |
|
1369 | 581 |
|
1370 | 582 |
// should not be able to update the document |
1371 | 583 |
testdocument = getTestEmlDoc("Testing update from another user", |
1372 |
null, null, |
|
1373 |
"ecogrid://knb/" + onlineDocid + ".22", |
|
584 |
null, null, null, |
|
1374 | 585 |
null, getAccessBlock(anotheruser, true, |
1375 |
true, false, false, false),
|
|
586 |
false, false, false, true),
|
|
1376 | 587 |
null, null, null, null); |
1377 |
updateDocid(newdocid + ".4", testdocument, FAILURE, true); |
|
1378 |
// or the permissions |
|
588 |
updateDocid(newdocid + ".14", testdocument, SUCCESS, false); |
|
589 |
readDocidWhichEqualsDoc(newdocid + ".14", testdocument, SUCCESS, false); |
|
590 |
|
|
591 |
// but can chg the permissions |
|
1379 | 592 |
testdocument = getTestEmlDoc("Testing update from another user", |
1380 |
null, null, |
|
1381 |
"ecogrid://knb/" + onlineDocid + ".2", |
|
1382 |
null, null, |
|
1383 |
null, null, null, null); |
|
1384 |
updateDocid(newdocid + ".4", testdocument, FAILURE, true); |
|
1385 |
// another test - but this is not access related |
|
1386 |
// hence i am commenting this out. |
|
1387 |
// uploadDocid(onlineDocid + ".2", onlinetestdatafile2, FAILURE, true); |
|
1388 |
|
|
1389 |
m.logout(); |
|
1390 |
m.login(username, password); |
|
1391 |
|
|
1392 |
///////////////////////////// |
|
1393 |
// update the document access control - write only |
|
1394 |
testdocument = getTestEmlDoc("Testing update access block", null, null, |
|
1395 |
"ecogrid://knb/" + onlineDocid + ".2", |
|
593 |
null, null, null, |
|
1396 | 594 |
null, getAccessBlock(anotheruser, true, |
1397 |
false, true, false, false),
|
|
595 |
true, false, false, false),
|
|
1398 | 596 |
null, null, null, null); |
1399 |
updateDocid(newdocid + ".4", testdocument, SUCCESS, false);
|
|
1400 |
readDocidWhichEqualsDoc(newdocid + ".4", testdocument, SUCCESS, false);
|
|
597 |
updateDocid(newdocid + ".15", testdocument, SUCCESS, false);
|
|
598 |
readDocidWhichEqualsDoc(newdocid + ".15", testdocument, SUCCESS, false);
|
|
1401 | 599 |
|
1402 |
// check if the user mentioned is able to read the document |
|
1403 |
// and online data |
|
1404 |
m.logout(); |
|
1405 |
m.login(anotheruser, anotherpassword); |
|
1406 |
readDocidWhichEqualsDoc(newdocid + ".4", testdocument, SUCCESS, true); |
|
1407 |
// should be able to read both versions of data |
|
1408 |
readDocid(onlineDocid + ".1", FAILURE, true); |
|
1409 |
readDocid(onlineDocid + ".2", FAILURE, true); |
|
600 |
// try to delete the document |
|
601 |
deleteDocid(newdocid + ".15", FAILURE, true); |
|
1410 | 602 |
|
1411 |
// should be able to update the document |
|
1412 |
testdocument = getTestEmlDoc("Testing update from another user", |
|
1413 |
null, null, |
|
1414 |
"ecogrid://knb/" + onlineDocid + ".22", |
|
1415 |
null, getAccessBlock(anotheruser, true, |
|
1416 |
false, true, false, false), |
|
1417 |
null, null, null, null); |
|
1418 |
//Errrrrrrror |
|
1419 |
//updateDocid(newdocid + ".5", testdocument, SUCCESS, false); |
|
1420 |
// but not the permissions |
|
1421 |
testdocument = getTestEmlDoc("Testing update from another user", |
|
1422 |
null, null, |
|
1423 |
"ecogrid://knb/" + onlineDocid + ".2", |
|
1424 |
null, null, |
|
1425 |
null, null, null, null); |
|
1426 |
updateDocid(newdocid + ".6", testdocument, FAILURE, true); |
|
1427 |
// another test - but this is not access related |
|
1428 |
// hence i am commenting this out. |
|
1429 |
// uploadDocid(onlineDocid + ".2", onlinetestdatafile2, FAILURE, true); |
|
1430 |
|
|
1431 | 603 |
m.logout(); |
1432 | 604 |
m.login(username, password); |
1433 | 605 |
|
1434 |
///////////////////////////// |
|
1435 |
// update the document access control - change permission only
|
|
1436 |
testdocument = getTestEmlDoc("Testing update access block", null, null,
|
|
1437 |
"ecogrid://knb/" + onlineDocid + ".2",
|
|
606 |
/////////////////////////////////
|
|
607 |
// update the document access control - all
|
|
608 |
testdocument = getTestEmlDoc("Testing update access block", |
|
609 |
null, null, null,
|
|
1438 | 610 |
null, getAccessBlock(anotheruser, true, |
1439 |
false, false, true, false),
|
|
611 |
false, false, false, true),
|
|
1440 | 612 |
null, null, null, null); |
1441 |
updateDocid(newdocid + ".6", testdocument, SUCCESS, false);
|
|
1442 |
readDocidWhichEqualsDoc(newdocid + ".6", testdocument, SUCCESS, false);
|
|
613 |
updateDocid(newdocid + ".17", testdocument, SUCCESS, false);
|
|
614 |
readDocidWhichEqualsDoc(newdocid + ".17", testdocument, SUCCESS, false);
|
|
1443 | 615 |
|
1444 | 616 |
// check if the user mentioned is able to read the document |
1445 |
// and online data |
|
1446 | 617 |
m.logout(); |
1447 | 618 |
m.login(anotheruser, anotherpassword); |
1448 |
readDocidWhichEqualsDoc(newdocid + ".6", testdocument, SUCCESS, true); |
|
1449 |
// should be able to read both versions of data |
|
1450 |
readDocid(onlineDocid + ".1", FAILURE, true); |
|
1451 |
readDocid(onlineDocid + ".2", FAILURE, true); |
|
619 |
readDocidWhichEqualsDoc(newdocid + ".17", testdocument, SUCCESS, false); |
|
1452 | 620 |
|
1453 | 621 |
// should not be able to update the document |
1454 | 622 |
testdocument = getTestEmlDoc("Testing update from another user", |
1455 |
null, null, |
|
1456 |
"ecogrid://knb/" + onlineDocid + ".22", |
|
623 |
null, null, null, |
|
1457 | 624 |
null, getAccessBlock(anotheruser, true, |
1458 |
false, false, true, false),
|
|
625 |
false, false, false, true),
|
|
1459 | 626 |
null, null, null, null); |
1460 |
updateDocid(newdocid + ".7", testdocument, FAILURE, true); |
|
1461 |
// but the permissions |
|
627 |
updateDocid(newdocid + ".18", testdocument, SUCCESS, false); |
|
628 |
readDocidWhichEqualsDoc(newdocid + ".18", testdocument, SUCCESS, false); |
|
629 |
|
|
630 |
// but can chg the permissions |
|
1462 | 631 |
testdocument = getTestEmlDoc("Testing update from another user", |
1463 |
null, null, |
|
1464 |
"ecogrid://knb/" + onlineDocid + ".2", |
|
1465 |
null, null, |
|
1466 |
null, null, null, null); |
|
1467 |
// Errrrrrrror |
|
1468 |
//updateDocid(newdocid + ".7", testdocument, SUCCESS, false); |
|
1469 |
|
|
1470 |
m.logout(); |
|
1471 |
m.login(username, password); |
|
1472 |
|
|
1473 |
///////////////////////////// |
|
1474 |
// update the document access control - all |
|
1475 |
testdocument = getTestEmlDoc("Testing update access block", null, null, |
|
1476 |
"ecogrid://knb/" + onlineDocid + ".2", |
|
632 |
null, null, null, |
|
1477 | 633 |
null, getAccessBlock(anotheruser, true, |
1478 |
false, false, false, true),
|
|
634 |
true, false, false, false),
|
|
1479 | 635 |
null, null, null, null); |
1480 |
updateDocid(newdocid + ".8", testdocument, SUCCESS, false);
|
|
1481 |
readDocidWhichEqualsDoc(newdocid + ".8", testdocument, SUCCESS, false);
|
|
636 |
updateDocid(newdocid + ".19", testdocument, SUCCESS, false);
|
|
637 |
readDocidWhichEqualsDoc(newdocid + ".19", testdocument, SUCCESS, false);
|
|
1482 | 638 |
|
1483 |
// check if the user mentioned is able to read the document |
|
1484 |
// and online data |
|
1485 |
m.logout(); |
|
1486 |
m.login(anotheruser, anotherpassword); |
|
1487 |
readDocidWhichEqualsDoc(newdocid + ".8", testdocument, SUCCESS, false); |
|
1488 |
// should be able to read both versions of data |
|
1489 |
readDocid(onlineDocid + ".1", SUCCESS, false); |
|
1490 |
readDocid(onlineDocid + ".2", SUCCESS, false); |
|
639 |
// try to delete the document |
|
640 |
deleteDocid(newdocid + ".19", FAILURE, true); |
|
1491 | 641 |
|
1492 |
// should be able to update the document |
|
1493 |
testdocument = getTestEmlDoc("Testing update from another user", |
|
1494 |
null, null, |
|
1495 |
"ecogrid://knb/" + onlineDocid + ".22", |
|
1496 |
null, getAccessBlock(anotheruser, true, |
|
1497 |
false, false, false, true), |
|
1498 |
null, null, null, null); |
|
1499 |
updateDocid(newdocid + ".9", testdocument, SUCCESS, false); |
|
1500 |
// and the permissions |
|
1501 |
testdocument = getTestEmlDoc("Testing update from another user", |
|
1502 |
null, null, |
|
1503 |
"ecogrid://knb/" + onlineDocid + ".2", |
|
1504 |
null, null, |
|
1505 |
null, null, null, null); |
|
1506 |
updateDocid(newdocid + ".10", testdocument, SUCCESS, false); |
|
1507 |
|
|
1508 | 642 |
m.logout(); |
1509 |
m.login(username, password); |
|
1510 | 643 |
|
1511 | 644 |
// delete the document |
1512 |
deleteDocid(newdocid + ".10", SUCCESS); |
|
645 |
m.login(username, password); |
|
646 |
deleteDocid(newdocid + ".19", SUCCESS, false); |
|
1513 | 647 |
m.logout(); |
1514 | 648 |
} |
1515 | 649 |
catch (MetacatAuthException mae) { |
... | ... | |
1524 | 658 |
|
1525 | 659 |
} |
1526 | 660 |
|
1527 |
/** ********* |
|
1528 |
* Test the case when no access is specified and another user is logged in |
|
661 |
|
|
662 |
/** ********* |
|
663 |
* Test the case when no access is specified and public is logged in |
|
1529 | 664 |
* Cases being checked: |
1530 |
* 1. the user tries to read the document - Failure.
|
|
1531 |
* 2. the user tries to update the document - Failure.
|
|
1532 |
* 3. the user tries to update the inline data - Failure.
|
|
1533 |
* 4. the user tries to update the online data file - Failure.
|
|
1534 |
* 5. the user tries to update the access rules for the document - Failure.
|
|
1535 |
* 6. the user tries to update the access rules for the inline data - Failure.
|
|
1536 |
* 7. the user tries to update the access rules for the online data - Failure.
|
|
1537 |
* 8. the user tries to delete the document - Failure.
|
|
665 |
* 1. public tries to read the document - Failure.
|
|
666 |
* 2. public tries to update the document - Failure.
|
|
667 |
* 3. public tries to update the inline data - Failure.
|
|
668 |
* 4. public tries to update the online data file - Failure.
|
|
669 |
* 5. public tries to update the access rules for the document - Failure.
|
|
670 |
* 6. public tries to update the access rules for the inline data - Failure.
|
|
671 |
* 7. public tries to update the access rules for the online data - Failure.
|
|
672 |
* 8. public tries to delete the document - Failure.
|
|
1538 | 673 |
*/ |
1539 |
public void noAccessSpecified_Random() {
|
|
674 |
public void AccessControlTestForPublic() {
|
|
1540 | 675 |
try { |
676 |
|
|
677 |
String accessBlock = getAccessBlock(anotheruser, true, |
|
678 |
true, false, false, false); |
|
1541 | 679 |
newdocid = generateDocid(); |
1542 |
String identifier = newdocid + ".1"; |
|
680 |
|
|
1543 | 681 |
// login |
1544 | 682 |
m.login(username, password); |
1545 | 683 |
|
1546 |
// insert a document - get the docid |
|
1547 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
1548 |
readDocidWhichEqualsDoc(newdocid + ".1", testdocument, SUCCESS, |
|
1549 |
true); |
|
684 |
onlineDocid = generateDocid(); |
|
685 |
uploadDocid(onlineDocid + ".1",onlinetestdatafile1, SUCCESS, false); |
|
1550 | 686 |
|
1551 |
// logoutand login as other user
|
|
1552 |
m.logout();
|
|
1553 |
m.login(anotheruser, anotherpassword);
|
|
687 |
testdocument = getTestEmlDoc("Testing insert", testEmlInlineBlock1,
|
|
688 |
null,"ecogrid://knb/" + onlineDocid + ".1",
|
|
689 |
null, null, null, null, null, null);
|
|
1554 | 690 |
|
1555 |
// read the document |
|
1556 |
readDocidWhichEqualsDoc(newdocid + ".1", null, FAILURE, false); |
|
1557 | 691 |
|
1558 |
// update the document |
|
1559 |
updateDocid(newdocid + ".2", testdocument, FAILURE, false); |
|
1560 |
|
|
1561 |
// update the inline data |
|
1562 |
updateDocid(newdocid + ".2", testdocument, FAILURE, false); |
|
1563 |
|
|
1564 |
// update the online data |
|
1565 |
updateDocid(newdocid + ".2", testdocument, FAILURE, false); |
|
1566 |
|
|
1567 |
// update the document access control |
|
1568 |
updateDocid(newdocid + ".2", testdocument, FAILURE, false); |
|
1569 |
|
|
1570 |
// update the document access control for inline data |
|
1571 |
updateDocid(newdocid + ".2", testdocument, FAILURE, false); |
|
1572 |
|
|
1573 |
// update the document access control for online data |
|
1574 |
updateDocid(newdocid + ".2", testdocument, FAILURE, false); |
|
1575 |
|
|
1576 |
// delete the document |
|
1577 |
deleteDocid(newdocid + ".2", SUCCESS); |
|
1578 |
m.logout(); |
|
1579 |
} |
|
1580 |
catch (MetacatAuthException mae) { |
|
1581 |
fail("Authorization failed:\n" + mae.getMessage()); |
|
1582 |
} |
|
1583 |
catch (MetacatInaccessibleException mie) { |
|
1584 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
|
1585 |
} |
|
1586 |
catch (MetacatException me) { |
|
1587 |
fail("Metacat Error:\n" + me.getMessage()); |
|
1588 |
} |
|
1589 |
catch (Exception e) { |
|
1590 |
fail("General exception:\n" + e.getMessage()); |
|
1591 |
} |
|
1592 |
|
|
1593 |
} |
|
1594 |
|
|
1595 |
/** ********* |
|
1596 |
* Test the case when no access is specified and public is logged in |
|
1597 |
* Cases being checked: |
|
1598 |
* 1. the owner tries to read the document - Failure. |
|
1599 |
* 2. the owner tries to update the document - Failure. |
|
1600 |
* 3. the owner tries to update the inline data - Failure. |
|
1601 |
* 4. the owner tries to update the online data file - Failure. |
|
1602 |
* 5. the owner tries to update the access rules for the document - Failure. |
|
1603 |
* 6. the owner tries to update the access rules for the inline data - Failure. |
|
1604 |
* 7. the owner tries to update the access rules for the online data - Failure. |
|
1605 |
* 8. the owner tries to delete the document - Failure. |
|
1606 |
*/ |
|
1607 |
public void noAccessSpecified_Public() { |
|
1608 |
try { |
|
1609 |
newdocid = generateDocid(); |
|
1610 |
String identifier = newdocid + ".1"; |
|
1611 |
// login |
|
1612 |
m.login(username, password); |
|
1613 |
|
|
1614 | 692 |
// insert a document - get the docid |
1615 | 693 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
1616 | 694 |
readDocidWhichEqualsDoc(newdocid + ".1", testdocument, SUCCESS, |
... | ... | |
1626 | 704 |
updateDocid(newdocid + ".2", testdocument, FAILURE, false); |
1627 | 705 |
|
1628 | 706 |
// update the inline data |
707 |
testdocument = getTestEmlDoc("Testing insert", testEmlInlineBlock2, |
|
708 |
null,"ecogrid://knb/" + onlineDocid + ".1", |
|
709 |
null, null, null, null, null, null); |
|
1629 | 710 |
updateDocid(newdocid + ".2", testdocument, FAILURE, false); |
1630 | 711 |
|
1631 | 712 |
// update the online data |
1632 |
updateDocid(newdocid + ".2", testdocument, FAILURE, false);
|
|
713 |
uploadDocid(onlineDocid + ".2", onlinetestdatafile1, FAILURE, false);
|
|
1633 | 714 |
|
1634 | 715 |
// update the document access control |
716 |
testdocument = getTestEmlDoc("Testing insert", testEmlInlineBlock1, |
|
717 |
null,"ecogrid://knb/" + onlineDocid + ".1", |
|
718 |
null, accessBlock, null, null, null, null); |
|
1635 | 719 |
updateDocid(newdocid + ".2", testdocument, FAILURE, false); |
1636 | 720 |
|
1637 | 721 |
// update the document access control for inline data |
722 |
testdocument = getTestEmlDoc("Testing insert", testEmlInlineBlock1, |
|
723 |
null,"ecogrid://knb/" + onlineDocid + ".1", |
|
724 |
null, null, accessBlock, null, null, null); |
|
1638 | 725 |
updateDocid(newdocid + ".2", testdocument, FAILURE, false); |
1639 | 726 |
|
Also available in: Unified diff
Made changes in AccessControl and Online Data Access tests.