Ejemplo n.º 1
0
 @Test
 public void testRereadNeededAfterTouch()
     throws PatternSyntaxException, IOException, InterruptedException {
   _check.rereadConfig();
   // Sleep for 1s to allow filesystem to notice a filechange.
   Thread.sleep(1000);
   saveContents("");
   assertTrue("no read required after touch", _check.fileNeedsRereading());
 }
Ejemplo n.º 2
0
 @Test
 public void testNullFilepath() throws PatternSyntaxException, IOException {
   CheckStagePermission check = new CheckStagePermission(null);
   assertTrue(
       "Null filepath to config file allows user with DN and FQAN",
       check.canPerformStaging(VALID_DN, VALID_FQAN, VALID_STOREUNIT));
   assertTrue(
       "Null filepath to config file allows user with DN",
       check.canPerformStaging(VALID_DN, null, VALID_STOREUNIT));
 }
Ejemplo n.º 3
0
 @Test
 public void testNullFqan() throws PatternSyntaxException, IOException {
   authoriseDn(VALID_DN);
   assertTrue(
       "user with DN and FQAN=null staging when DN is in file",
       _check.canPerformStaging(VALID_DN, null, VALID_STOREUNIT));
 }
Ejemplo n.º 4
0
 @Test
 public void testStringNullFqan2() throws PatternSyntaxException, IOException {
   authoriseDnFqan(VALID_DN, VALID_FQAN);
   assertFalse(
       "user with DN and FQAN=null cannot stage when DN and FQAN is in file",
       _check.canPerformStaging(VALID_DN, null, VALID_STOREUNIT));
 }
Ejemplo n.º 5
0
 @Test
 public void testStringWildecardsNotMatchingDN() throws PatternSyntaxException, IOException {
   authoriseDnFqan(TEST_DN, TEST_FQAN);
   assertFalse(
       "check pattern .* : user's DN does not match, staging not allowed",
       _check.canPerformStaging(USER_TEST2_DN, USER_TEST1_FQAN, VALID_STOREUNIT));
 }
Ejemplo n.º 6
0
 @Test
 public void testStringWildcardsMatchingDNandFQAN() throws PatternSyntaxException, IOException {
   authoriseDnFqan(TEST_DN, TEST_FQAN);
   assertTrue(
       "check pattern .* : user with DN and FQAN can stage when DN and FQAN are in file",
       _check.canPerformStaging(USER_TEST1_DN, USER_TEST1_FQAN, VALID_STOREUNIT));
 }
Ejemplo n.º 7
0
 @Test
 public void testStringUserWithDnAndSameFqanAuthorisedWithDnAndFqanCanStage() throws IOException {
   authoriseDnFqan(VALID_DN, VALID_FQAN);
   assertTrue(
       "user with DN and same FQAN staging when DN and FQAN is in file",
       _check.canPerformStaging(VALID_DN, VALID_FQAN, VALID_STOREUNIT));
 }
Ejemplo n.º 8
0
 // below there are 7 tests for canPerformStaging(String dn, String fqan, String storeUnit),
 // to show that StageConfiguration.conf file may remain unchanged (using only 2 parameters as
 // before: DN, FQAN)
 // when the new stage permission check is performed (using DN, FQAN, StoreUnit)
 @Test
 public void testStringUserWithDnAuthorisedWithDnCanStage() throws IOException {
   authoriseDn(VALID_DN);
   assertTrue(
       "user with DN staging when DN is in file",
       _check.canPerformStaging(VALID_DN, null, VALID_STOREUNIT));
 }
Ejemplo n.º 9
0
 @Test
 public void testUserWithDnAndDifferentFqanAuthorisedWithDnAndFqanCanStage() throws IOException {
   authoriseDnFqan(VALID_DN, VALID_FQAN);
   assertFalse(
       "user with DN and different FQAN staging when DN and FQAN is in file",
       _check.canPerformStaging(VALID_DN, OTHER_VALID_FQAN, VALID_STOREUNIT));
 }
Ejemplo n.º 10
0
 @Test()
 public void testCanStageWithMissingFile() throws PatternSyntaxException, IOException {
   _testConfigFile.delete();
   assertFalse(
       "Missing file allowed user to stage",
       _check.canPerformStaging(VALID_DN, VALID_FQAN, VALID_STOREUNIT));
 }
Ejemplo n.º 11
0
 @Test
 public void testDnAndSameFqanAuthorisedWithDnAndFqanCanStage() throws IOException {
   authoriseDnFqanStoreunit(".*", ".*", ".*"); // config line:  ".*" ".*" ".*"
   assertTrue(
       "user with DN, FQAN, and StorageGroup specified can stage in case ALL *s in ConfigFile",
       _check.canPerformStaging(VALID_DN, VALID_FQAN, VALID_STOREUNIT));
 }
Ejemplo n.º 12
0
 @Test
 public void testZeroLengthDNAndFqan() throws PatternSyntaxException, IOException {
   authoriseDnFqan(VALID_DN, VALID_FQAN);
   assertFalse(
       "user with ZeroLengthDN and FQAN can not stage",
       _check.canPerformStaging("", VALID_FQAN, VALID_STOREUNIT));
 }
Ejemplo n.º 13
0
 @Test
 public void testDnFqanCanStageWhenDnInConfigfile() throws IOException {
   authoriseDnFqanStoreunit(
       VALID_DN, (String) null, null); // config line: "/DC=org/DC=example/CN=test user"
   assertTrue(
       "user with DN and FQAN staging when DN is in file",
       _check.canPerformStaging(VALID_DN, VALID_FQAN, VALID_STOREUNIT));
 }
Ejemplo n.º 14
0
 @Test
 public void testNullFqanCanStage() throws PatternSyntaxException, IOException {
   authoriseDnFqanStoreunit(
       VALID_DN, (String) null, null); // config line: "/DC=org/DC=example/CN=test user"
   assertTrue(
       "user with DN staging when DN is in file",
       _check.canPerformStaging(VALID_DN, null, VALID_STOREUNIT));
 }
Ejemplo n.º 15
0
 @Test
 public void testNullFqanCannotStage() throws PatternSyntaxException, IOException {
   authoriseDnFqanStoreunit(
       VALID_DN,
       VALID_FQAN,
       null); // config line: "/DC=org/DC=example/CN=test user" "/atlas/Role=production"
   assertFalse(
       "user with DN and FQAN=null cannot stage when DN and FQAN is in file",
       _check.canPerformStaging(VALID_DN, null, VALID_STOREUNIT));
 }
Ejemplo n.º 16
0
 @Test
 public void testDnAndDifferentFqanAuthorisedWithDnAndFqanCanStage() throws IOException {
   authoriseDnFqanStoreunit(
       VALID_DN,
       VALID_FQAN,
       null); // config line: "/DC=org/DC=example/CN=test user" "/atlas/Role=production"
   assertFalse(
       "user with DN and wrong FQAN cannot stage when DN and FQAN is in file",
       _check.canPerformStaging(VALID_DN, OTHER_VALID_FQAN, VALID_STOREUNIT));
 }
Ejemplo n.º 17
0
 @Test
 public void testDnFqanStoreunitCanStageWhenDnFqanStoreunitInConfigfile() throws IOException {
   authoriseDnFqanStoreunit(
       VALID_DN,
       VALID_FQAN,
       VALID_STOREUNIT); // config line: "/DC=org/DC=example/CN=test user" "/atlas/Role=production"
                         // "sql:chimera@osm"
   assertTrue(
       "user with DN and FQAN staging when DN and FQAN are in file; also storage unit is in file ",
       _check.canPerformStaging(VALID_DN, VALID_FQAN, VALID_STOREUNIT));
 }
Ejemplo n.º 18
0
 // those 14 tests below were adopted for testing the method canPerformStaging(String dn, String
 // fqan, String StoreUnit)
 @Test
 public void testZeroLengthDNEmptyFile() throws PatternSyntaxException, IOException {
   assertFalse(
       "user with ZeroLength DN and FQAN can not stage with empty file",
       _check.canPerformStaging("", VALID_FQAN, VALID_STOREUNIT));
 }
Ejemplo n.º 19
0
 @Test()
 public void testCanStageWithEmptyFile() throws PatternSyntaxException, IOException {
   assertFalse(
       "Empty file allowed user to stage",
       _check.canPerformStaging(VALID_DN, VALID_FQAN, VALID_STOREUNIT));
 }
Ejemplo n.º 20
0
 @Test
 public void testNoReadAfterInitialRead() throws PatternSyntaxException, IOException {
   _check.rereadConfig();
   assertFalse("read still required after initial read", _check.fileNeedsRereading());
 }
Ejemplo n.º 21
0
 @Test
 public void testInitialShouldRead() {
   assertTrue("no initial read required", _check.fileNeedsRereading());
 }