Revision 2260
Added by sgarg almost 20 years ago
OnlineDataAccessTest.java | ||
---|---|---|
46 | 46 |
import java.io.File; |
47 | 47 |
|
48 | 48 |
/** |
49 |
* A JUnit test for testing Access Control in Metacat |
|
49 |
* A JUnit test for testing Access Control for online data in Metacat
|
|
50 | 50 |
*/ |
51 | 51 |
public class OnlineDataAccessTest |
52 | 52 |
extends TestCase { |
... | ... | |
332 | 332 |
|
333 | 333 |
// try to set the permissions for the uploaded document |
334 | 334 |
// the docid given is for the online document |
335 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
335 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", |
|
336 |
null, null, |
|
336 | 337 |
"ecogrid://knb/" + onlineDocid + ".1", |
337 | 338 |
null, getAccessBlock(anotheruser, true, |
338 | 339 |
true, false, false, false), |
... | ... | |
406 | 407 |
onlinetestdatafile2, FAILURE, false); |
407 | 408 |
|
408 | 409 |
// try to upload another document with updated id |
409 |
// ERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR |
|
410 |
//uploadDocid(onlineDocid + ".3", |
|
411 |
// onlinetestdatafile2, FAILURE, false); |
|
410 |
uploadDocid(onlineDocid + ".3", |
|
411 |
onlinetestdatafile2, FAILURE, true); |
|
412 | 412 |
|
413 | 413 |
|
414 | 414 |
// try to set the permissions for the uploaded document |
415 | 415 |
// the docid given is for the online document |
416 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
416 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", |
|
417 |
null, null, |
|
417 | 418 |
"ecogrid://knb/" + onlineDocid + ".1", |
418 | 419 |
"ecogrid://knb/" + onlineDocid + ".2", |
419 | 420 |
getAccessBlock(anotheruser, true, |
420 |
true, false, false, false), |
|
421 |
true, false, false, false),
|
|
421 | 422 |
null, null, null, null); |
422 | 423 |
newdocid = generateDocid(); |
423 | 424 |
insertDocid(newdocid + ".1", testdocument, FAILURE, true); |
... | ... | |
425 | 426 |
// delete the document - should not be able to delete .1 |
426 | 427 |
// but should be able to delete .2 |
427 | 428 |
deleteDocid(onlineDocid + ".1", FAILURE, false); |
428 |
deleteDocid(onlineDocid + ".2", FAILURE, false);
|
|
429 |
deleteDocid(onlineDocid + ".2", FAILURE, true);
|
|
429 | 430 |
|
430 | 431 |
m.logout(); |
431 | 432 |
|
... | ... | |
466 | 467 |
uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false); |
467 | 468 |
|
468 | 469 |
// upload a document which gives read access to the online document |
469 |
testdocument = getTestEmlDoc("Another insert", null, null, |
|
470 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", |
|
471 |
null, null, |
|
470 | 472 |
"ecogrid://knb/" + onlineDocid + ".1", |
471 | 473 |
null, getAccessBlock(anotheruser, true, |
472 | 474 |
true, false, false, false), |
... | ... | |
482 | 484 |
readDocid(onlineDocid + ".1", SUCCESS, false); |
483 | 485 |
|
484 | 486 |
// try to upload another data with updated id |
485 |
// ERRRRRRRRRRRRRRRRRRRRRR |
|
486 |
//uploadDocid(onlineDocid + ".2", |
|
487 |
// onlinetestdatafile2, FAILURE, true); |
|
487 |
uploadDocid(onlineDocid + ".2", |
|
488 |
onlinetestdatafile2, FAILURE, true); |
|
488 | 489 |
|
489 | 490 |
// try to set the permissions for the uploaded document |
490 | 491 |
// the docid given is for the online document |
491 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
492 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", |
|
493 |
null, null, |
|
492 | 494 |
"ecogrid://knb/" + onlineDocid + ".1", |
493 | 495 |
null, getAccessBlock(anotheruser, true, |
494 | 496 |
false, false, false, true), |
... | ... | |
507 | 509 |
uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false); |
508 | 510 |
|
509 | 511 |
// upload a document which gives read access to the online document |
510 |
testdocument = getTestEmlDoc("Another insert", null, null, |
|
512 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Another insert", |
|
513 |
null, null, |
|
511 | 514 |
"ecogrid://knb/" + onlineDocid + ".1", |
512 | 515 |
null, getAccessBlock(anotheruser, true, |
513 | 516 |
false, true, false, false), |
... | ... | |
528 | 531 |
|
529 | 532 |
// try to set the permissions for the uploaded document |
530 | 533 |
// the docid given is for the online document |
531 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
534 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Another insert", |
|
535 |
null, null, |
|
532 | 536 |
"ecogrid://knb/" + onlineDocid + ".1", |
533 | 537 |
null, getAccessBlock(anotheruser, true, |
534 |
false, false, false, true), |
|
538 |
false, false, false, true),
|
|
535 | 539 |
null, null, null, null); |
536 | 540 |
newdocid = generateDocid(); |
537 | 541 |
insertDocid(newdocid + ".1", testdocument, FAILURE, true); |
... | ... | |
547 | 551 |
uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false); |
548 | 552 |
|
549 | 553 |
// upload a document which gives read access to the online document |
550 |
testdocument = getTestEmlDoc("Another insert", null, null, |
|
554 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Another insert", |
|
555 |
null, null, |
|
551 | 556 |
"ecogrid://knb/" + onlineDocid + ".1", |
552 | 557 |
null, getAccessBlock(anotheruser, true, |
553 | 558 |
false, false, true, false), |
... | ... | |
563 | 568 |
readDocid(onlineDocid + ".1", FAILURE, true); |
564 | 569 |
|
565 | 570 |
// try to upload another data with updated id |
566 |
// ERRRRRRRRRRRRRRRRRRRRR |
|
567 |
// uploadDocid(onlineDocid + ".2", |
|
568 |
// onlinetestdatafile2, FAILURE, true); |
|
571 |
uploadDocid(onlineDocid + ".2", |
|
572 |
onlinetestdatafile2, FAILURE, true); |
|
569 | 573 |
|
570 | 574 |
// try to set the permissions for the uploaded document |
571 | 575 |
// the docid given is for the online document |
572 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
576 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", |
|
577 |
null, null, |
|
573 | 578 |
"ecogrid://knb/" + onlineDocid + ".1", |
574 | 579 |
null, getAccessBlock(anotheruser, true, |
575 | 580 |
false, false, false, true), |
576 | 581 |
null, null, null, null); |
577 | 582 |
newdocid = generateDocid(); |
578 | 583 |
// ERRRRRRRRRRRRRRRR |
579 |
//insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
584 |
// User does not have permission to update of access rules for data |
|
585 |
// insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
580 | 586 |
|
581 | 587 |
// delete the document |
582 | 588 |
deleteDocid(onlineDocid + ".1", FAILURE, true); |
... | ... | |
589 | 595 |
uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false); |
590 | 596 |
|
591 | 597 |
// upload a document which gives read access to the online document |
592 |
testdocument = getTestEmlDoc("Another insert", null, null, |
|
598 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", |
|
599 |
null, null, |
|
593 | 600 |
"ecogrid://knb/" + onlineDocid + ".1", |
594 | 601 |
null, getAccessBlock(anotheruser, true, |
595 | 602 |
false, false, false, true), |
... | ... | |
610 | 617 |
|
611 | 618 |
// try to set the permissions for the uploaded document |
612 | 619 |
// the docid given is for the online document |
613 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
620 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", |
|
621 |
null, null, |
|
614 | 622 |
"ecogrid://knb/" + onlineDocid + ".1", |
615 | 623 |
null, getAccessBlock(anotheruser, true, |
616 | 624 |
true, false, false, false), |
... | ... | |
662 | 670 |
uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false); |
663 | 671 |
|
664 | 672 |
// upload a document which gives read access to the online document |
665 |
testdocument = getTestEmlDoc("Another insert", null, null, |
|
673 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", |
|
674 |
null, null, |
|
666 | 675 |
"ecogrid://knb/" + onlineDocid + ".1", |
667 | 676 |
null, null, null, null, |
668 | 677 |
getAccessBlock(anotheruser, true, |
... | ... | |
678 | 687 |
readDocid(onlineDocid + ".1", SUCCESS, false); |
679 | 688 |
|
680 | 689 |
// try to upload another data with updated id |
681 |
// ERRRRRRRRRRRRRRRRRRRRRR |
|
682 |
//uploadDocid(onlineDocid + ".2", |
|
683 |
// onlinetestdatafile2, FAILURE, true); |
|
690 |
uploadDocid(onlineDocid + ".2", |
|
691 |
onlinetestdatafile2, FAILURE, true); |
|
684 | 692 |
|
685 | 693 |
// try to set the permissions for the uploaded document |
686 | 694 |
// the docid given is for the online document |
687 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
695 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", |
|
696 |
null, null, |
|
688 | 697 |
"ecogrid://knb/" + onlineDocid + ".1", |
689 | 698 |
null, null, null, null, |
690 | 699 |
getAccessBlock(anotheruser, true, |
... | ... | |
703 | 712 |
uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false); |
704 | 713 |
|
705 | 714 |
// upload a document which gives read access to the online document |
706 |
testdocument = getTestEmlDoc("Another insert", null, null, |
|
715 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", |
|
716 |
null, null, |
|
707 | 717 |
"ecogrid://knb/" + onlineDocid + ".1", |
708 | 718 |
null, null, null, null, |
709 | 719 |
getAccessBlock(anotheruser, true, |
... | ... | |
724 | 734 |
|
725 | 735 |
// try to set the permissions for the uploaded document |
726 | 736 |
// the docid given is for the online document |
727 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
737 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", |
|
738 |
null, null, |
|
728 | 739 |
"ecogrid://knb/" + onlineDocid + ".1", |
729 | 740 |
null, null, null, null, |
730 | 741 |
getAccessBlock(anotheruser, true, |
... | ... | |
743 | 754 |
uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false); |
744 | 755 |
|
745 | 756 |
// upload a document which gives read access to the online document |
746 |
testdocument = getTestEmlDoc("Another insert", null, null, |
|
757 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", |
|
758 |
null, null, |
|
747 | 759 |
"ecogrid://knb/" + onlineDocid + ".1", |
748 | 760 |
null, null, null, null, |
749 | 761 |
getAccessBlock(anotheruser, true, |
... | ... | |
759 | 771 |
readDocid(onlineDocid + ".1", FAILURE, true); |
760 | 772 |
|
761 | 773 |
// try to upload another data with updated id |
762 |
// ERRRRRRRRRRRRRRRRRRRRR |
|
763 |
// uploadDocid(onlineDocid + ".2", |
|
764 |
// onlinetestdatafile2, FAILURE, true); |
|
774 |
uploadDocid(onlineDocid + ".2", |
|
775 |
onlinetestdatafile2, FAILURE, true); |
|
765 | 776 |
|
766 | 777 |
// try to set the permissions for the uploaded document |
767 | 778 |
// the docid given is for the online document |
768 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
779 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", |
|
780 |
null, null, |
|
769 | 781 |
"ecogrid://knb/" + onlineDocid + ".1", |
770 | 782 |
null, null, null, null, |
771 | 783 |
getAccessBlock(anotheruser, true, |
772 | 784 |
false, false, false, true), null); |
773 | 785 |
newdocid = generateDocid(); |
774 | 786 |
// ERRRRRRRRRRRRRRRR |
775 |
//insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
787 |
// User does not have permission to update of access rules for data |
|
788 |
// insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
776 | 789 |
|
777 | 790 |
// delete the document |
778 | 791 |
deleteDocid(onlineDocid + ".1", FAILURE, true); |
... | ... | |
785 | 798 |
uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS, false); |
786 | 799 |
|
787 | 800 |
// upload a document which gives read access to the online document |
788 |
testdocument = getTestEmlDoc("Another insert", null, null, |
|
801 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", |
|
802 |
null, null, |
|
789 | 803 |
"ecogrid://knb/" + onlineDocid + ".1", |
790 | 804 |
null, null, null, null, |
791 | 805 |
getAccessBlock(anotheruser, true, |
... | ... | |
806 | 820 |
|
807 | 821 |
// try to set the permissions for the uploaded document |
808 | 822 |
// the docid given is for the online document |
809 |
testdocument = getTestEmlDoc("Testing insert", null, null, |
|
823 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", |
|
824 |
null, null, |
|
810 | 825 |
"ecogrid://knb/" + onlineDocid + ".1", |
811 | 826 |
null, null, null, null, |
812 | 827 |
getAccessBlock(anotheruser, true, |
... | ... | |
849 | 864 |
m.login(username, password); |
850 | 865 |
|
851 | 866 |
/////////Case 1 |
852 |
testdocument = getTestEmlDoc("Testing insert", null, null,
|
|
867 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", null, null,
|
|
853 | 868 |
"ecogrid://knb/" + onlineDocid + ".1", |
854 | 869 |
null, null, null, null, null, |
855 | 870 |
getAccessBlock(anotheruser, true, |
... | ... | |
858 | 873 |
insertDocid(newdocid + ".1", testdocument, FAILURE, false); |
859 | 874 |
|
860 | 875 |
/////////Case 2 |
861 |
testdocument = getTestEmlDoc("Testing insert", null, null,
|
|
876 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", null, null,
|
|
862 | 877 |
"ecogrid://knb/" + onlineDocid + ".1", |
863 | 878 |
null, null, null, null, |
864 | 879 |
getAccessBlock(anotheruser, true, |
865 | 880 |
true, false, false, false), null); |
866 | 881 |
newdocid = generateDocid(); |
867 | 882 |
|
868 |
// ERRRRRRRRRRRRRRRR - what is the right behaviour?????? |
|
869 |
//insertDocid(newdocid + ".1", testdocument, FAILURE, false); |
|
883 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
870 | 884 |
m.logout(); |
871 | 885 |
|
872 | 886 |
} |
... | ... | |
897 | 911 |
|
898 | 912 |
// insert a document |
899 | 913 |
m.login(username, password); |
900 |
testdocument = getTestEmlDoc("Doing insert", null, null, null, |
|
914 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", |
|
915 |
null, null, null, |
|
901 | 916 |
null, getAccessBlock(anotheruser, true, |
902 | 917 |
true, false, false, false), null, null, |
903 | 918 |
null, null); |
... | ... | |
908 | 923 |
|
909 | 924 |
// update document |
910 | 925 |
m.login(username, password); |
911 |
testdocument = getTestEmlDoc("Doing update", null, null, null, |
|
926 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing update", |
|
927 |
null, null, null, |
|
912 | 928 |
null, getAccessBlock(anotheruser, true, |
913 | 929 |
true, false, false, false), null, null, |
914 | 930 |
null, null); |
... | ... | |
929 | 945 |
|
930 | 946 |
// upload data and update the document |
931 | 947 |
m.login(username, password); |
932 |
testdocument = getTestEmlDoc("Doing update", null, null, |
|
948 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing update", |
|
949 |
null, null, |
|
933 | 950 |
"ecogrid://knb/" + onlineDocid + ".1", |
934 | 951 |
null, getAccessBlock(anotheruser, true, |
935 | 952 |
true, false, false, false), null, null, |
... | ... | |
939 | 956 |
|
940 | 957 |
// set read for document - no read for data |
941 | 958 |
m.login(username, password); |
942 |
testdocument = getTestEmlDoc("Doing update", null, null, |
|
959 |
testdocument = getTestEmlDoc("OnlineDataAccessTest: Doing insert", |
|
960 |
null, null, |
|
943 | 961 |
"ecogrid://knb/" + onlineDocid + ".1", |
944 | 962 |
null, getAccessBlock(anotheruser, true, |
945 | 963 |
true, false, false, false), null, null, |
Also available in: Unified diff
Made changes in AccessControl and Online Data Access tests.