Revision 8209
Added by ben leinfelder almost 11 years ago
test/edu/ucsb/nceas/metacat/dataone/MNodeServiceTest.java | ||
---|---|---|
1013 | 1013 |
|
1014 | 1014 |
} |
1015 | 1015 |
} |
1016 |
|
|
1017 |
/** |
|
1018 |
* Test if node admin is authorized to read a known object |
|
1019 |
*/ |
|
1020 |
public void testIsAdminAuthorized() { |
|
1021 |
printTestHeader("testIsAdminAuthorized"); |
|
1022 |
|
|
1023 |
try { |
|
1024 |
Session session = getTestSession(); |
|
1025 |
Identifier guid = new Identifier(); |
|
1026 |
guid.setValue("testIsAdminAuthorized." + System.currentTimeMillis()); |
|
1027 |
InputStream object = new ByteArrayInputStream("test".getBytes("UTF-8")); |
|
1028 |
SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object); |
|
1029 |
Identifier pid = |
|
1030 |
MNodeService.getInstance(request).create(session, guid, object, sysmeta); |
|
1031 |
|
|
1032 |
// test as public - read |
|
1033 |
boolean isAuthorized = |
|
1034 |
MNodeService.getInstance(request).isAuthorized(null, pid, Permission.READ); |
|
1035 |
assertEquals(isAuthorized, true); |
|
1036 |
|
|
1037 |
// test as public - change perm |
|
1038 |
isAuthorized = |
|
1039 |
MNodeService.getInstance(request).isAuthorized(null, pid, Permission.CHANGE_PERMISSION); |
|
1040 |
assertEquals(isAuthorized, false); |
|
1041 |
|
|
1042 |
// test as admin |
|
1043 |
isAuthorized = |
|
1044 |
MNodeService.getInstance(request).isAuthorized(getMNSession(), pid, Permission.CHANGE_PERMISSION); |
|
1045 |
assertEquals(isAuthorized, true); |
|
1046 |
|
|
1047 |
} catch (Exception e) { |
|
1048 |
e.printStackTrace(); |
|
1049 |
fail("Unexpected error: " + e.getMessage()); |
|
1016 | 1050 |
|
1051 |
} |
|
1052 |
} |
|
1053 |
|
|
1017 | 1054 |
|
1018 | 1055 |
public void testIsEquivIdentityAuthorized() { |
1019 | 1056 |
printTestHeader("testIsEquivIdentityAuthorized"); |
Also available in: Unified diff
test that d1 node admin is allowed all permissions. https://projects.ecoinformatics.org/ecoinfo/issues/6086