Project

General

Profile

« Previous | Next » 

Revision 10004

Added by Jing Tao about 8 years ago

Restore the testRightsHolderExpand method on the D1NodeServiceTest.

View differences:

test/edu/ucsb/nceas/metacat/dataone/CNodeServiceTest.java
125 125
		suite.addTest(new CNodeServiceTest("testListViews"));
126 126
		suite.addTest(new CNodeServiceTest("testUpdateSystemMetadata"));
127 127
		suite.addTest(new CNodeServiceTest("testArchive"));
128
		suite.addTest(new CNodeServiceTest("testExpandRighsHolder"));
129 128
		
130 129
		return suite;
131 130
	}
......
1473 1472
     }
1474 1473
  }
1475 1474
  
1476
  public void testExpandRighsHolder() throws Exception {
1477
      // set back to force it to use defaults
1478
       D1Client.setNodeLocator(null);
1479
       Subject rightsHolder = new Subject();
1480
       rightsHolder.setValue("CN=arctic-data-admins,DC=dataone,DC=org");
1481
       Subject user = new Subject();
1482
       
1483
       user.setValue("CN=Christopher Jones A2108,O=Google,C=US,DC=cilogon,DC=org");
1484
       assertTrue(D1NodeService.expandRightsHolder(rightsHolder, user));
1485
       
1486
       user.setValue("uid=foo");
1487
       assertTrue(!D1NodeService.expandRightsHolder(rightsHolder, user));
1488
       
1489
       user.setValue("http://orcid.org/0000-0002-1586-0121");
1490
       assertTrue(D1NodeService.expandRightsHolder(rightsHolder, user));
1491
       
1492
       rightsHolder.setValue("CN=foo,,DC=dataone,DC=org");
1493
       assertTrue(!D1NodeService.expandRightsHolder(rightsHolder, user));
1494
       
1495
       user.setValue("uid=foo");
1496
       assertTrue(!D1NodeService.expandRightsHolder(rightsHolder, user));
1497
       
1498
       rightsHolder.setValue(null);
1499
       assertTrue(!D1NodeService.expandRightsHolder(rightsHolder, user));
1500
       
1501
       rightsHolder.setValue("CN=foo,,DC=dataone,DC=org");
1502
       user.setValue(null);
1503
       assertTrue(!D1NodeService.expandRightsHolder(rightsHolder, user));
1504
       
1505
       rightsHolder.setValue(null);
1506
       assertTrue(!D1NodeService.expandRightsHolder(rightsHolder, user));
1507
       
1508
       rightsHolder.setValue("");
1509
       user.setValue("");
1510
       assertTrue(!D1NodeService.expandRightsHolder(rightsHolder, user));
1511
       NodeLocator nodeLocator = new NodeLocator() {
1512
           @Override
1513
           public D1Node getCNode() throws ClientSideException {
1514
               D1Node node = null;
1515
               try {
1516
                   node = new MockCNode();
1517
               } catch (IOException e) {
1518
                   throw new ClientSideException(e.getMessage());
1519
               }
1520
               return node;
1521
           }
1522
       };
1523
       D1Client.setNodeLocator(nodeLocator );
1524
   }
1525 1475
  
1476
  
1526 1477
  public Session getMNSessionFromCN() throws NotImplemented, ServiceFailure {
1527 1478
      Session session = new Session();
1528 1479
      Subject subject = null;
test/edu/ucsb/nceas/metacat/dataone/D1NodeServiceTest.java
86 86
    {
87 87
        TestSuite suite = new TestSuite();
88 88
        suite.addTest(new D1NodeServiceTest("initialize"));
89
        //suite.addTest(new D1NodeServiceTest("testExpandRighsHolder"));
89
        suite.addTest(new D1NodeServiceTest("testExpandRighsHolder"));
90 90
        return suite;
91 91
    }
92 92
    
......
119 119
		D1Client.setNodeLocator(null);
120 120
	}
121 121
	
122
	public void testExpandRighsHolder() throws Exception {
123
	      // set back to force it to use defaults
124
	       D1Client.setNodeLocator(null);
125
	       Subject rightsHolder = new Subject();
126
	       rightsHolder.setValue("CN=arctic-data-admins,DC=dataone,DC=org");
127
	       Subject user = new Subject();
128
	       
129
	       user.setValue("CN=Christopher Jones A2108,O=Google,C=US,DC=cilogon,DC=org");
130
	       assertTrue(D1NodeService.expandRightsHolder(rightsHolder, user));
131
	       
132
	       user.setValue("uid=foo");
133
	       assertTrue(!D1NodeService.expandRightsHolder(rightsHolder, user));
134
	       
135
	       user.setValue("http://orcid.org/0000-0002-1586-0121");
136
	       assertTrue(D1NodeService.expandRightsHolder(rightsHolder, user));
137
	       
138
	       rightsHolder.setValue("CN=foo,,DC=dataone,DC=org");
139
	       assertTrue(!D1NodeService.expandRightsHolder(rightsHolder, user));
140
	       
141
	       user.setValue("uid=foo");
142
	       assertTrue(!D1NodeService.expandRightsHolder(rightsHolder, user));
143
	       
144
	       rightsHolder.setValue(null);
145
	       assertTrue(!D1NodeService.expandRightsHolder(rightsHolder, user));
146
	       
147
	       rightsHolder.setValue("CN=foo,,DC=dataone,DC=org");
148
	       user.setValue(null);
149
	       assertTrue(!D1NodeService.expandRightsHolder(rightsHolder, user));
150
	       
151
	       rightsHolder.setValue(null);
152
	       assertTrue(!D1NodeService.expandRightsHolder(rightsHolder, user));
153
	       
154
	       rightsHolder.setValue("");
155
	       user.setValue("");
156
	       assertTrue(!D1NodeService.expandRightsHolder(rightsHolder, user));
157
	       NodeLocator nodeLocator = new NodeLocator() {
158
	           @Override
159
	           public D1Node getCNode() throws ClientSideException {
160
	               D1Node node = null;
161
	               try {
162
	                   node = new MockCNode();
163
	               } catch (IOException e) {
164
	                   throw new ClientSideException(e.getMessage());
165
	               }
166
	               return node;
167
	           }
168
	       };
169
	       D1Client.setNodeLocator(nodeLocator );
170
	   }
122 171
	
123
	
124 172
	/**
125 173
	 * constructs a "fake" session with a test subject
126 174
	 * @return

Also available in: Unified diff