Revision 2256
Added by sgarg over 19 years ago
AccessControlTest.java | ||
---|---|---|
51 | 51 |
public class AccessControlTest |
52 | 52 |
extends TestCase { |
53 | 53 |
|
54 |
private String metacatUrl = "@systemidserver@@servlet-path@"; |
|
55 |
private String username = "@mcuser@"; |
|
56 |
private String password = "@mcpassword@"; |
|
57 |
private String anotheruser = "@mcanotheruser@"; |
|
58 |
private String anotherpassword = "@mcanotherpassword@"; |
|
59 |
private String prefix = "test"; |
|
60 |
private String newdocid = null; |
|
61 |
private String onlineDocid = null; |
|
62 |
private String testdocument = ""; |
|
63 |
private String onlinetestdatafile1 = "test/onlineDataFile1"; |
|
64 |
private String onlinetestdatafile2 = "test/onlineDataFile2"; |
|
54 |
private String metacatUrl = "@systemidserver@@servlet-path@";
|
|
55 |
private String username = "@mcuser@";
|
|
56 |
private String password = "@mcpassword@";
|
|
57 |
private String anotheruser = "@mcanotheruser@";
|
|
58 |
private String anotherpassword = "@mcanotherpassword@";
|
|
59 |
private String prefix = "test";
|
|
60 |
private String newdocid = null;
|
|
61 |
private String onlineDocid = null;
|
|
62 |
private String testdocument = "";
|
|
63 |
private String onlinetestdatafile1 = "test/onlineDataFile1";
|
|
64 |
private String onlinetestdatafile2 = "test/onlineDataFile2";
|
|
65 | 65 |
|
66 |
private Metacat m; |
|
66 |
private Metacat m;
|
|
67 | 67 |
|
68 |
private boolean SUCCESS = true; |
|
69 |
private boolean FAILURE = false; |
|
68 |
private boolean SUCCESS = true;
|
|
69 |
private boolean FAILURE = false;
|
|
70 | 70 |
|
71 |
/** |
|
72 |
* These variables are for eml-2.0.1 only. For other eml versions, |
|
73 |
* this function might have to modified |
|
74 |
*/ |
|
71 | 75 |
|
76 |
private String testEmlHeader = |
|
77 |
"<?xml version=\"1.0\"?><eml:eml" + |
|
78 |
" xmlns:eml=\"eml://ecoinformatics.org/eml-2.0.1\"" + |
|
79 |
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + |
|
80 |
" packageId=\"eml.1.1\" system=\"knb\"" + |
|
81 |
" xsi:schemaLocation=\"eml://ecoinformatics.org/eml-2.0.1 eml.xsd\"" + |
|
82 |
" scope=\"system\">"; |
|
72 | 83 |
|
73 |
/** |
|
74 |
* These variables are for eml-2.0.1 only. For other eml versions, |
|
75 |
* this function might have to modified |
|
76 |
*/ |
|
84 |
private String testEmlCreatorBlock = |
|
85 |
"<creator scope=\"document\"> " + |
|
86 |
" <individualName> " + |
|
87 |
" <surName>Smith</surName> " + |
|
88 |
" </individualName> " + |
|
89 |
"</creator> "; |
|
77 | 90 |
|
78 |
private String testEmlHeader = |
|
79 |
"<?xml version=\"1.0\"?><eml:eml" + |
|
80 |
" xmlns:eml=\"eml://ecoinformatics.org/eml-2.0.1\"" + |
|
81 |
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + |
|
82 |
" packageId=\"eml.1.1\" system=\"knb\"" + |
|
83 |
" xsi:schemaLocation=\"eml://ecoinformatics.org/eml-2.0.1 eml.xsd\"" + |
|
84 |
" scope=\"system\">"; |
|
91 |
private String testEmlContactBlock = |
|
92 |
"<contact scope=\"document\"> " + |
|
93 |
" <individualName> " + |
|
94 |
" <surName>Jackson</surName> " + |
|
95 |
" </individualName> " + |
|
96 |
"</contact> "; |
|
85 | 97 |
|
86 |
private String testEmlCreatorBlock = |
|
87 |
"<creator scope=\"document\"> " + |
|
88 |
" <individualName> " + |
|
89 |
" <surName>Smith</surName> " + |
|
90 |
" </individualName> " + |
|
91 |
"</creator> "; |
|
98 |
private String testEmlInlineBlock1 = |
|
99 |
"<inline> " + |
|
100 |
" <admin> " + |
|
101 |
" <contact> " + |
|
102 |
" <name>Operator</name> " + |
|
103 |
" <institution>PSI</institution> " + |
|
104 |
" </contact> " + |
|
105 |
" </admin> " + |
|
106 |
"</inline> "; |
|
92 | 107 |
|
93 |
private String testEmlContactBlock = |
|
94 |
"<contact scope=\"document\"> " + |
|
95 |
" <individualName> " + |
|
96 |
" <surName>Jackson</surName> " + |
|
97 |
" </individualName> " + |
|
98 |
"</contact> "; |
|
108 |
private String testEmlInlineBlock2 = |
|
109 |
"<inline> " + |
|
110 |
" <instrument> " + |
|
111 |
" <instName>LCQ</instName> " + |
|
112 |
" <source type=\"ESI\"></source> " + |
|
113 |
" <detector type=\"EM\"></detector> " + |
|
114 |
" </instrument> " + |
|
115 |
"</inline> "; |
|
99 | 116 |
|
100 |
private String testEmlInlineBlock1 =
|
|
101 |
"<inline> " +
|
|
102 |
" <admin> " +
|
|
103 |
" <contact> " +
|
|
104 |
" <name>Operator</name> " +
|
|
105 |
" <institution>PSI</institution> " +
|
|
106 |
" </contact> " +
|
|
107 |
" </admin> " +
|
|
108 |
"</inline> ";
|
|
117 |
/**
|
|
118 |
* This function returns an access block based on the params passed
|
|
119 |
*/
|
|
120 |
private String getAccessBlock(String principal, boolean grantAccess,
|
|
121 |
boolean read, boolean write,
|
|
122 |
boolean changePermission, boolean all) {
|
|
123 |
String accessBlock = "<access " +
|
|
124 |
"authSystem=\"ldap://ldap.ecoinformatics.org:389/dc=ecoinformatics,dc=org\"" +
|
|
125 |
" order=\"allowFirst\" scope=\"document\">";
|
|
109 | 126 |
|
110 |
private String testEmlInlineBlock2 = |
|
111 |
"<inline> " + |
|
112 |
" <instrument> " + |
|
113 |
" <instName>LCQ</instName> " + |
|
114 |
" <source type=\"ESI\"></source> " + |
|
115 |
" <detector type=\"EM\"></detector> " + |
|
116 |
" </instrument> " + |
|
117 |
"</inline> "; |
|
127 |
if (grantAccess) { |
|
128 |
accessBlock += "<allow>"; |
|
129 |
} |
|
130 |
else { |
|
131 |
accessBlock += "<deny>"; |
|
132 |
} |
|
118 | 133 |
|
119 |
/** |
|
120 |
* This function returns a valid eml document with no access rules |
|
121 |
* This function is for eml-2.0.1 only. For other eml versions, |
|
122 |
* this function might have to modified |
|
123 |
*/ |
|
124 |
private String getTestEmlDoc(String title, String inlineData1, |
|
125 |
String inlineData2, String onlineUrl1, |
|
126 |
String onlineUrl2){ |
|
127 |
String testDocument = ""; |
|
128 |
testDocument = testDocument + testEmlHeader + |
|
129 |
"<dataset scope=\"document\"><title>" + title + "</title>" + |
|
130 |
testEmlCreatorBlock; |
|
134 |
accessBlock = accessBlock + "<principal>" + principal + "</principal>"; |
|
131 | 135 |
|
132 |
if(inlineData1 != null){ |
|
133 |
testDocument = testDocument + "<distribution scope=\"document\">" + |
|
134 |
inlineData1 + "</distribution>"; |
|
135 |
} |
|
136 |
if(inlineData2 != null){ |
|
137 |
testDocument = testDocument + "<distribution scope=\"document\">" + |
|
138 |
inlineData2 + "</distribution>"; |
|
139 |
} |
|
140 |
if(onlineUrl1 != null){ |
|
141 |
testDocument = testDocument + "<distribution scope=\"document\">" + |
|
142 |
"<online><url function=\"download\">" + onlineUrl1 + "</url></online></distribution>"; |
|
143 |
} |
|
144 |
if(onlineUrl2 != null){ |
|
145 |
testDocument = testDocument + "<distribution scope=\"document\">" + |
|
146 |
"<online><url function=\"download\">" + onlineUrl2 + "</url></online></distribution>"; |
|
147 |
} |
|
148 |
testDocument = testDocument + testEmlContactBlock + "</dataset></eml:eml>"; |
|
136 |
if (all) { |
|
137 |
accessBlock += "<permission>all</permission>"; |
|
138 |
} |
|
139 |
else { |
|
140 |
if (read) { |
|
141 |
accessBlock += "<permission>read</permission>"; |
|
142 |
} |
|
143 |
if (write) { |
|
144 |
accessBlock += "<permission>write</permission>"; |
|
145 |
} |
|
146 |
if (changePermission) { |
|
147 |
accessBlock += "<permission>changePermission</permission>"; |
|
148 |
} |
|
149 |
} |
|
149 | 150 |
|
150 |
return testDocument; |
|
151 |
} |
|
151 |
if (grantAccess) { |
|
152 |
accessBlock += "</allow>"; |
|
153 |
} |
|
154 |
else { |
|
155 |
accessBlock += "</deny>"; |
|
156 |
} |
|
157 |
accessBlock += "</access>"; |
|
152 | 158 |
|
153 |
/** |
|
154 |
* Constructor to build the test |
|
155 |
* |
|
156 |
* @param name the name of the test method |
|
157 |
*/ |
|
158 |
public AccessControlTest(String name) { |
|
159 |
super(name); |
|
160 |
newdocid = generateDocid(); |
|
161 |
} |
|
159 |
return accessBlock; |
|
162 | 160 |
|
163 |
/** |
|
164 |
* Establish a testing framework by initializing appropriate objects |
|
165 |
*/ |
|
166 |
public void setUp() { |
|
167 |
try { |
|
168 |
System.err.println("Test Metacat: " + metacatUrl); |
|
169 |
m = MetacatFactory.createMetacatConnection(metacatUrl); |
|
170 | 161 |
} |
171 |
catch (MetacatInaccessibleException mie) { |
|
172 |
System.err.println("Metacat is: " + metacatUrl); |
|
173 |
fail("Metacat connection failed." + mie.getMessage()); |
|
174 |
} |
|
175 |
} |
|
176 | 162 |
|
177 |
/** |
|
178 |
* Release any objects after tests are complete |
|
179 |
*/ |
|
180 |
public void tearDown() { |
|
181 |
} |
|
163 |
/** |
|
164 |
* This function returns a valid eml document with no access rules |
|
165 |
* This function is for eml-2.0.1 only. For other eml versions, |
|
166 |
* this function might have to modified |
|
167 |
*/ |
|
168 |
private String getTestEmlDoc(String title, String inlineData1, |
|
169 |
String inlineData2, String onlineUrl1, |
|
170 |
String onlineUrl2, String docAccessBlock, |
|
171 |
String inlineAccessBlock1, |
|
172 |
String inlineAccessBlock2, |
|
173 |
String onlineAccessBlock1, |
|
174 |
String onlineAccessBlock2) { |
|
182 | 175 |
|
183 |
/** |
|
184 |
* Create a suite of tests to be run together |
|
185 |
*/ |
|
186 |
public static Test suite() { |
|
187 |
TestSuite suite = new TestSuite(); |
|
188 |
suite.addTest(new AccessControlTest("initialize")); |
|
189 |
// Test basic functions |
|
190 |
suite.addTest(new AccessControlTest("login")); |
|
191 |
suite.addTest(new AccessControlTest("insert")); |
|
192 |
suite.addTest(new AccessControlTest("read")); |
|
193 |
suite.addTest(new AccessControlTest("update")); |
|
194 |
suite.addTest(new AccessControlTest("delete")); |
|
195 |
// Tests when no access is specified |
|
196 |
suite.addTest(new AccessControlTest("noAccessSpecified_Owner")); |
|
197 |
//suite.addTest(new AccessControlTest("noAccessSpecified_Random")); |
|
198 |
//suite.addTest(new AccessControlTest("noAccessSpecified_Public")); |
|
176 |
String testDocument = ""; |
|
177 |
testDocument = testDocument + testEmlHeader + |
|
178 |
"<dataset scope=\"document\"><title>" + title + "</title>" + |
|
179 |
testEmlCreatorBlock; |
|
199 | 180 |
|
200 |
return suite; |
|
201 |
} |
|
181 |
if (inlineData1 != null) { |
|
182 |
testDocument = testDocument |
|
183 |
+ "<distribution scope=\"document\" id=\"inlineEntity1\">" |
|
184 |
+ inlineData1 + "</distribution>"; |
|
185 |
} |
|
186 |
if (inlineData2 != null) { |
|
187 |
testDocument = testDocument |
|
188 |
+ "<distribution scope=\"document\" id=\"inlineEntity2\">" |
|
189 |
+ inlineData2 + "</distribution>"; |
|
190 |
} |
|
191 |
if (onlineUrl1 != null) { |
|
192 |
testDocument = testDocument |
|
193 |
+ "<distribution scope=\"document\" id=\"onlineEntity1\">" |
|
194 |
+ "<online><url function=\"download\">" |
|
195 |
+ onlineUrl1 + "</url></online></distribution>"; |
|
196 |
} |
|
197 |
if (onlineUrl2 != null) { |
|
198 |
testDocument = testDocument + |
|
199 |
"<distribution scope=\"document\" id=\"onlineEntity2\">" |
|
200 |
+ "<online><url function=\"download\">" |
|
201 |
+ onlineUrl2 + "</url></online></distribution>"; |
|
202 |
} |
|
203 |
testDocument += testEmlContactBlock; |
|
202 | 204 |
|
203 |
/** |
|
204 |
* Run an initial test that always passes to check that the test |
|
205 |
* harness is working. |
|
206 |
*/ |
|
207 |
public void initialize() { |
|
208 |
assertTrue(1 == 1); |
|
209 |
} |
|
205 |
if (docAccessBlock != null) { |
|
206 |
testDocument += docAccessBlock; |
|
207 |
} |
|
210 | 208 |
|
211 |
/** |
|
212 |
* Test the login() function with valid credentials |
|
213 |
*/ |
|
214 |
public void login() { |
|
215 |
// Try a valid login |
|
216 |
try { |
|
217 |
String response = m.login(username, password); |
|
218 |
System.err.println("Login response: " + response); |
|
219 |
assertTrue(response != null); |
|
220 |
assertTrue(response.indexOf("<login>") != -1); |
|
221 |
String sessionId = m.getSessionId(); |
|
222 |
System.err.println("Session ID: " + m.getSessionId()); |
|
223 |
assertTrue(sessionId != null); |
|
224 |
assertTrue(response.indexOf(m.getSessionId()) != -1); |
|
209 |
testDocument += "</dataset>"; |
|
210 |
|
|
211 |
// if(inlineAccessBlock1 != null || inlineAccessBlock2 != null || |
|
212 |
// onlineAccessBlock1 != null || onlineAccessBlock2 != null){ |
|
213 |
// testDocument += "<addtionalMetadata>"; |
|
214 |
// } |
|
215 |
|
|
216 |
if (inlineAccessBlock1 != null) { |
|
217 |
testDocument += "<additionalMetadata>"; |
|
218 |
testDocument += "<describes>inlineEntity1</describes>"; |
|
219 |
testDocument += inlineAccessBlock1; |
|
220 |
testDocument += "</additionalMetadata>"; |
|
221 |
} |
|
222 |
|
|
223 |
if (inlineAccessBlock2 != null) { |
|
224 |
testDocument += "<additionalMetadata>"; |
|
225 |
testDocument += "<describes>inlineEntity2</describes>"; |
|
226 |
testDocument += inlineAccessBlock2; |
|
227 |
testDocument += "</additionalMetadata>"; |
|
228 |
} |
|
229 |
|
|
230 |
if (onlineAccessBlock1 != null) { |
|
231 |
testDocument += "<additionalMetadata>"; |
|
232 |
testDocument += "<describes>onlineEntity1</describes>"; |
|
233 |
testDocument += onlineAccessBlock1; |
|
234 |
testDocument += "</additionalMetadata>"; |
|
235 |
} |
|
236 |
|
|
237 |
if (onlineAccessBlock2 != null) { |
|
238 |
testDocument += "<additionalMetadata>"; |
|
239 |
testDocument += "<describes>onlineEntity2</describes>"; |
|
240 |
testDocument += onlineAccessBlock2; |
|
241 |
testDocument += "</additionalMetadata>"; |
|
242 |
} |
|
243 |
|
|
244 |
testDocument += "</eml:eml>"; |
|
245 |
|
|
246 |
//System.out.println("Returning following document" + testDocument); |
|
247 |
return testDocument; |
|
225 | 248 |
} |
226 |
catch (MetacatAuthException mae) { |
|
227 |
fail("Authorization failed:\n" + mae.getMessage()); |
|
249 |
|
|
250 |
/** |
|
251 |
* Constructor to build the test |
|
252 |
* |
|
253 |
* @param name the name of the test method |
|
254 |
*/ |
|
255 |
public AccessControlTest(String name) { |
|
256 |
super(name); |
|
257 |
newdocid = generateDocid(); |
|
228 | 258 |
} |
229 |
catch (MetacatInaccessibleException mie) { |
|
230 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
|
259 |
|
|
260 |
/** |
|
261 |
* Establish a testing framework by initializing appropriate objects |
|
262 |
*/ |
|
263 |
public void setUp() { |
|
264 |
try { |
|
265 |
System.err.println("Test Metacat: " + metacatUrl); |
|
266 |
m = MetacatFactory.createMetacatConnection(metacatUrl); |
|
267 |
} |
|
268 |
catch (MetacatInaccessibleException mie) { |
|
269 |
System.err.println("Metacat is: " + metacatUrl); |
|
270 |
fail("Metacat connection failed." + mie.getMessage()); |
|
271 |
} |
|
231 | 272 |
} |
232 |
} |
|
233 | 273 |
|
234 |
/** |
|
235 |
* Test the insert() function with a known document |
|
236 |
*/ |
|
237 |
public void insert() { |
|
238 |
try { |
|
239 |
testdocument = getTestEmlDoc("Testing insert", testEmlInlineBlock1, |
|
240 |
null, null, null); |
|
241 |
String identifier = newdocid + ".1"; |
|
242 |
m.login(username, password); |
|
243 |
String response = m.insert(identifier, |
|
244 |
new StringReader(testdocument), null); |
|
245 |
assertTrue(response.indexOf("<success>") != -1); |
|
246 |
assertTrue(response.indexOf(identifier) != -1); |
|
247 |
System.err.println(response); |
|
274 |
/** |
|
275 |
* Release any objects after tests are complete |
|
276 |
*/ |
|
277 |
public void tearDown() { |
|
248 | 278 |
} |
249 |
catch (MetacatAuthException mae) { |
|
250 |
fail("Authorization failed:\n" + mae.getMessage()); |
|
279 |
|
|
280 |
/** |
|
281 |
* Create a suite of tests to be run together |
|
282 |
*/ |
|
283 |
public static Test suite() { |
|
284 |
TestSuite suite = new TestSuite(); |
|
285 |
suite.addTest(new AccessControlTest("initialize")); |
|
286 |
// 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")); |
|
299 |
|
|
300 |
//suite.addTest(new AccessControlTest("noAccessSpecified_Random")); |
|
301 |
//suite.addTest(new AccessControlTest("noAccessSpecified_Public")); |
|
302 |
|
|
303 |
return suite; |
|
251 | 304 |
} |
252 |
catch (MetacatInaccessibleException mie) { |
|
253 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
|
305 |
|
|
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 |
} |
|
254 | 393 |
} |
255 |
catch (InsufficientKarmaException ike) { |
|
256 |
assertTrue(1 == 1); |
|
257 |
fail("Insufficient karma:\n" + ike.getMessage()); |
|
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 |
} |
|
258 | 570 |
} |
259 |
catch (MetacatException me) { |
|
260 |
fail("Metacat Error:\n" + me.getMessage()); |
|
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 |
} |
|
261 | 763 |
} |
262 |
catch (Exception e) { |
|
263 |
fail("General exception:\n" + e.getMessage()); |
|
764 |
|
|
765 |
|
|
766 |
|
|
767 |
/** |
|
768 |
* Run an initial test that always passes to check that the test |
|
769 |
* harness is working. |
|
770 |
*/ |
|
771 |
public void initialize() { |
|
772 |
assertTrue(1 == 1); |
|
264 | 773 |
} |
265 |
} |
|
266 | 774 |
|
267 |
/** |
|
268 |
* The read() function |
|
269 |
*/ |
|
270 |
public void read() { |
|
271 |
try { |
|
272 |
testdocument = getTestEmlDoc("Testing insert", testEmlInlineBlock1, null, |
|
273 |
null, null); |
|
274 |
m.login(username, password); |
|
275 |
Reader r = m.read(newdocid + ".1"); |
|
276 |
String doc = IOUtil.getAsString(r, true); |
|
277 |
assertTrue(doc.equals(testdocument)); |
|
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 |
} |
|
278 | 796 |
} |
279 |
catch (MetacatAuthException mae) { |
|
280 |
fail("Authorization failed:\n" + mae.getMessage()); |
|
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 |
} |
|
281 | 830 |
} |
282 |
catch (MetacatInaccessibleException mie) { |
|
283 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
|
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 |
} |
|
284 | 854 |
} |
285 |
catch (Exception e) { |
|
286 |
fail("General exception:\n" + e.getMessage()); |
|
287 |
} |
|
288 |
} |
|
289 | 855 |
|
290 |
/** |
|
291 |
* Test the update() function with a known document |
|
292 |
*/ |
|
293 |
public void update() { |
|
294 |
try { |
|
295 |
testdocument = getTestEmlDoc("Testing update", testEmlInlineBlock1, null, |
|
296 |
null, null); |
|
297 |
String identifier = newdocid + ".2"; |
|
298 |
m.login(username, password); |
|
299 |
String response = m.update(identifier, |
|
300 |
new StringReader(testdocument), null); |
|
301 |
assertTrue(response.indexOf("<success>") != -1); |
|
302 |
assertTrue(response.indexOf(identifier) != -1); |
|
303 |
System.err.println(response); |
|
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);
|
|
304 | 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 |
} |
|
305 | 887 |
} |
306 |
catch (MetacatAuthException mae) { |
|
307 |
fail("Authorization failed:\n" + mae.getMessage()); |
|
308 |
} |
|
309 |
catch (MetacatInaccessibleException mie) { |
|
310 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
|
311 |
} |
|
312 |
catch (InsufficientKarmaException ike) { |
|
313 |
fail("Insufficient karma:\n" + ike.getMessage()); |
|
314 |
} |
|
315 |
catch (MetacatException me) { |
|
316 |
fail("Metacat Error:\n" + me.getMessage()); |
|
317 |
} |
|
318 |
catch (Exception e) { |
|
319 |
fail("General exception:\n" + e.getMessage()); |
|
320 |
} |
|
321 |
} |
|
322 | 888 |
|
323 |
/** |
|
324 |
* Test the delete() function with a known document |
|
325 |
*/ |
|
326 |
public void delete() { |
|
327 |
try { |
|
328 |
String identifier = newdocid + ".2"; |
|
329 |
m.login(username, password); |
|
330 |
String response = m.delete(identifier); |
|
331 |
assertTrue(response.indexOf("<success>") != -1); |
|
332 |
System.err.println(response); |
|
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);
|
|
333 | 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 |
} |
|
334 | 916 |
} |
335 |
catch (MetacatAuthException mae) { |
|
336 |
fail("Authorization failed:\n" + mae.getMessage()); |
|
337 |
} |
|
338 |
catch (MetacatInaccessibleException mie) { |
|
339 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
|
340 |
} |
|
341 |
catch (InsufficientKarmaException ike) { |
|
342 |
fail("Insufficient karma:\n" + ike.getMessage()); |
|
343 |
} |
|
344 |
catch (MetacatException me) { |
|
345 |
fail("Metacat Error:\n" + me.getMessage()); |
|
346 |
} |
|
347 |
catch (Exception e) { |
|
348 |
fail("General exception:\n" + e.getMessage()); |
|
349 |
} |
|
350 |
} |
|
351 | 917 |
|
918 |
/** ********* |
|
919 |
* Test the case when no access is specified and owner is logged in |
|
920 |
* No online or inline data is involved |
|
921 |
*/ |
|
922 |
public void documentTest() { |
|
923 |
try { |
|
924 |
newdocid = generateDocid(); |
|
352 | 925 |
|
926 |
// login |
|
927 |
m.login(username, password); |
|
353 | 928 |
|
354 |
/** ********* |
|
355 |
* Test the case when no access is specified and owner is logged in |
|
356 |
* Cases being checked: |
|
357 |
* 1. the owner tries to read the document - Success. |
|
358 |
* Both document and data show up. |
|
359 |
* 2. the owner tries to update the document - Success. |
|
360 |
* 3. the owner tries to update the inline data - Success. |
|
361 |
* 4. the owner tries to update the online data file - Success. |
|
362 |
* 5. the owner tries to update the access rules for the document - Success. |
|
363 |
* 6. the owner tries to update the access rules for the inline data - Success. |
|
364 |
* 7. the owner tries to update the access rules for the online data - Success. |
|
365 |
* 8. the owner tries to delete the document - Success. |
|
366 |
*/ |
|
367 |
public void noAccessSpecified_Owner() { |
|
368 |
try { |
|
369 |
newdocid = generateDocid(); |
|
929 |
// insert a document |
|
930 |
testdocument = getTestEmlDoc("Testing insert", null, |
|
931 |
null, null, |
|
932 |
null, null, null, null, null, null); |
|
933 |
insertDocid(newdocid + ".1", testdocument, SUCCESS, false); |
|
934 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, false); |
|
370 | 935 |
|
371 |
// login |
|
372 |
m.login(username, password); |
|
936 |
// update the document |
|
937 |
testdocument = getTestEmlDoc("Testing update", null, null, null, |
|
938 |
null, null, null, null, null, null); |
|
939 |
updateDocid(newdocid + ".2", testdocument, SUCCESS, false); |
|
940 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS, false); |
|
373 | 941 |
|
374 |
// upload online document |
|
375 |
onlineDocid = generateDocid(); |
|
376 |
uploadDocid(onlineDocid + ".1", onlinetestdatafile1, SUCCESS); |
|
942 |
///////////////////////////// |
|
943 |
// update the document access control - read only |
|
944 |
testdocument = getTestEmlDoc("Testing update access block", |
|
945 |
null, null, null, |
|
946 |
null, getAccessBlock(anotheruser, true, |
|
947 |
true, false, false, false), |
|
948 |
null, null, null, null); |
|
949 |
updateDocid(newdocid + ".3", testdocument, SUCCESS, false); |
|
950 |
readDocidWhichEqualsDoc(newdocid + ".3", testdocument, SUCCESS, false); |
|
377 | 951 |
|
378 |
// insert a document - get the docid |
|
379 |
testdocument = getTestEmlDoc("Testing insert", testEmlInlineBlock1, |
|
380 |
null, "ecogrid://knb/" + onlineDocid, null); |
|
381 |
insertDocid(newdocid + ".1", testdocument, SUCCESS); |
|
382 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS); |
|
952 |
// check if the user mentioned is able to read the document |
|
953 |
m.logout(); |
|
954 |
m.login(anotheruser, anotherpassword); |
|
955 |
readDocidWhichEqualsDoc(newdocid + ".3", testdocument, SUCCESS, false); |
|
383 | 956 |
|
384 |
// update the document |
|
385 |
testdocument = getTestEmlDoc("Testing update", testEmlInlineBlock1, |
|
386 |
null, null, null); |
|
387 |
updateDocid(newdocid + ".2", testdocument, SUCCESS); |
|
388 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS); |
|
957 |
// should not be able to update the document |
|
958 |
testdocument = getTestEmlDoc("Testing update from another user", |
|
959 |
null, null, null, |
|
960 |
null, getAccessBlock(anotheruser, true, |
|
961 |
true, false, false, false), |
|
962 |
null, null, null, null); |
|
963 |
updateDocid(newdocid + ".4", testdocument, FAILURE, true); |
|
389 | 964 |
|
390 |
// update the inline data |
|
391 |
testdocument = getTestEmlDoc("Testing update inline", testEmlInlineBlock2, |
|
392 |
null, null, null); |
|
393 |
updateDocid(newdocid + ".3", testdocument, SUCCESS); |
|
394 |
readDocidWhichEqualsDoc(newdocid, testdocument, SUCCESS); |
|
965 |
// 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); |
|
972 |
updateDocid(newdocid + ".4", testdocument, FAILURE, true); |
|
973 |
m.logout(); |
|
974 |
m.login(username, password); |
|
395 | 975 |
|
396 |
// update the online data |
|
397 |
uploadDocid(onlineDocid + ".2", onlinetestdatafile2, SUCCESS); |
|
398 |
// read document and check if it is same as the document which was written |
|
399 |
// the second time |
|
976 |
/////////////////////////////////// |
|
977 |
// update the document access control - write only |
|
978 |
testdocument = getTestEmlDoc("Testing update access block", |
|
979 |
null, null, null, |
|
980 |
null, getAccessBlock(anotheruser, true, |
|
981 |
false, true, false, false), |
|
982 |
null, null, null, null); |
|
983 |
updateDocid(newdocid + ".4", testdocument, SUCCESS, false); |
|
984 |
readDocidWhichEqualsDoc(newdocid + ".4", testdocument, SUCCESS, false); |
|
985 |
//System.out.println(testdocument); |
|
986 |
// check if the user mentioned is able to read the document |
|
987 |
m.logout(); |
|
988 |
m.login(anotheruser, anotherpassword); |
|
989 |
readDocidWhichEqualsDoc(newdocid + ".4", testdocument, FAILURE, true); |
|
400 | 990 |
|
401 |
// update the document access control |
|
402 |
testdocument = getTestEmlDoc("Testing update inline", testEmlInlineBlock2, |
|
403 |
null, null, null); |
|
404 |
updateDocid(newdocid + ".5", testdocument, SUCCESS); |
|
405 |
readDocidWhichEqualsDoc(newdocid + ".5", testdocument, SUCCESS); |
|
991 |
// 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); |
|
997 |
//System.out.println(testdocument); |
|
998 |
// ERRRRRRRRRRRRROR |
|
999 |
//updateDocid(newdocid + ".6", testdocument, SUCCESS, false); |
|
406 | 1000 |
|
407 |
// update the document access control for inline data |
|
408 |
testdocument = getTestEmlDoc("Testing update inline", testEmlInlineBlock2, |
|
409 |
null, null, null); |
|
410 |
updateDocid(newdocid + ".6", testdocument, SUCCESS); |
|
411 |
readDocidWhichEqualsDoc(newdocid + ".6", testdocument, SUCCESS); |
|
1001 |
// but not the permissions |
|
1002 |
testdocument = getTestEmlDoc("Testing update from another user", |
|
1003 |
null, null, null, |
|
1004 |
null, getAccessBlock(anotheruser, true, |
|
1005 |
false, true, false, true), |
|
1006 |
null, null, null, null); |
|
1007 |
updateDocid(newdocid + ".5", testdocument, FAILURE, true); |
|
412 | 1008 |
|
413 |
// update the document access control for online data |
|
414 |
testdocument = getTestEmlDoc("Testing update inline", testEmlInlineBlock2, |
|
415 |
null, null, null); |
|
416 |
updateDocid(newdocid + ".7", testdocument, SUCCESS); |
|
417 |
readDocidWhichEqualsDoc(newdocid + ".7", testdocument, SUCCESS); |
|
1009 |
m.logout(); |
|
1010 |
m.login(username, password); |
|
418 | 1011 |
|
419 |
// delete the document |
|
420 |
deleteDocid(newdocid + ".3", SUCCESS); |
|
421 |
m.logout(); |
|
1012 |
///////////////////////////////// |
|
1013 |
// update the document access control - change permissions only |
|
1014 |
testdocument = getTestEmlDoc("Testing update access block", |
|
1015 |
null, null, null, |
|
1016 |
null, getAccessBlock(anotheruser, true, |
|
1017 |
false, false, true, false), |
|
1018 |
null, null, null, null); |
|
1019 |
updateDocid(newdocid + ".5", testdocument, SUCCESS, false); |
|
1020 |
readDocidWhichEqualsDoc(newdocid + ".5", testdocument, SUCCESS, false); |
|
1021 |
|
|
1022 |
// check if the user mentioned is able to read the document |
|
1023 |
m.logout(); |
|
1024 |
m.login(anotheruser, anotherpassword); |
|
1025 |
readDocidWhichEqualsDoc(newdocid + ".5", testdocument, FAILURE, true); |
|
1026 |
|
|
1027 |
// should not be able to update the document |
|
1028 |
testdocument = getTestEmlDoc("Testing update from another user", |
|
1029 |
null, null, null, |
|
1030 |
null, getAccessBlock(anotheruser, true, |
|
1031 |
false, false, true, false), |
|
1032 |
null, null, null, null); |
|
1033 |
updateDocid(newdocid + ".6", testdocument, FAILURE, true); |
|
1034 |
|
|
1035 |
// but can chg the permissions |
|
1036 |
testdocument = getTestEmlDoc("Testing update from another user", |
|
1037 |
null, null, null, |
|
1038 |
null, getAccessBlock(anotheruser, true, |
|
1039 |
false, false, false, true), |
|
1040 |
null, null, null, null); |
|
1041 |
// ERRRRRRRROR |
|
1042 |
//updateDocid(newdocid + ".6", testdocument, SUCCESS, false); |
|
1043 |
|
|
1044 |
m.logout(); |
|
1045 |
m.login(username, password); |
|
1046 |
|
|
1047 |
///////////////////////////////// |
|
1048 |
// update the document access control - all |
|
1049 |
testdocument = getTestEmlDoc("Testing update access block", |
|
1050 |
null, null, null, |
|
1051 |
null, getAccessBlock(anotheruser, true, |
|
1052 |
false, false, false, true), |
|
1053 |
null, null, null, null); |
|
1054 |
updateDocid(newdocid + ".7", testdocument, SUCCESS, false); |
|
1055 |
readDocidWhichEqualsDoc(newdocid + ".7", testdocument, SUCCESS, false); |
|
1056 |
|
|
1057 |
// check if the user mentioned is able to read the document |
|
1058 |
m.logout(); |
|
1059 |
m.login(anotheruser, anotherpassword); |
|
1060 |
readDocidWhichEqualsDoc(newdocid + ".7", testdocument, SUCCESS, false); |
|
1061 |
|
|
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); |
|
1070 |
|
|
1071 |
// but can chg the permissions |
|
1072 |
testdocument = getTestEmlDoc("Testing update from another user", |
|
1073 |
null, null, null, |
|
1074 |
null, getAccessBlock(anotheruser, true, |
|
1075 |
true, false, false, false), |
|
1076 |
null, null, null, null); |
|
1077 |
updateDocid(newdocid + ".9", testdocument, SUCCESS, false); |
|
1078 |
readDocidWhichEqualsDoc(newdocid + ".9", testdocument, SUCCESS, false); |
|
1079 |
|
|
1080 |
m.logout(); |
|
1081 |
|
|
1082 |
// delete the document |
|
1083 |
m.login(username, password); |
|
1084 |
deleteDocid(newdocid + ".9", SUCCESS); |
|
1085 |
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 |
|
|
422 | 1097 |
} |
423 |
catch (MetacatAuthException mae) { |
|
424 |
fail("Authorization failed:\n" + mae.getMessage()); |
|
425 |
} |
|
426 |
catch (MetacatInaccessibleException mie) { |
|
427 |
fail("Metacat Inaccessible:\n" + mie.getMessage()); |
|
428 |
} |
|
429 |
catch (Exception e) { |
|
430 |
fail("General exception:\n" + e.getMessage()); |
|
431 |
} |
|
432 | 1098 |
|
433 |
} |
|
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(); |
|
434 | 1106 |
|
1107 |
// login |
|
1108 |
m.login(username, password); |
|
435 | 1109 |
|
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); |
|
436 | 1116 |
|
437 |
/** ********* |
|
438 |
* Test the case when no access is specified and another user is logged in |
|
439 |
* Cases being checked: |
|
440 |
* 1. the owner tries to read the document - Failure. |
|
441 |
* 2. the owner tries to update the document - Failure. |
|
442 |
* 3. the owner tries to update the inline data - Failure. |
|
443 |
* 4. the owner tries to update the online data file - Failure. |
|
444 |
* 5. the owner tries to update the access rules for the document - Failure. |
|
445 |
* 6. the owner tries to update the access rules for the inline data - Failure. |
|
446 |
* 7. the owner tries to update the access rules for the online data - Failure. |
|
447 |
* 8. the owner tries to delete the document - Failure. |
|
448 |
*/ |
|
449 |
public void noAccessSpecified_Random() { |
|
450 |
try { |
|
451 |
newdocid = generateDocid(); |
|
452 |
String identifier = newdocid + ".1"; |
|
453 |
// login |
|
454 |
m.login(username, password); |
|
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); |
|
455 | 1123 |
|
456 |
// insert a document - get the docid |
|
457 |
insertDocid(newdocid + ".1", testdocument, SUCCESS); |
|
458 |
readDocidWhichEqualsDoc(newdocid + ".1", testdocument, SUCCESS); |
|
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); |
|
459 | 1131 |
|
460 |
// logoutand login as other user |
|
461 |
m.logout(); |
|
462 |
m.login(anotheruser, anotherpassword); |
|
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); |
|
463 | 1139 |
|
464 |
// read the document |
|
465 |
readDocidWhichEqualsDoc(newdocid + ".1", null, FAILURE); |
|
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); |
|
466 | 1147 |
|
467 |
// update the document
|
|
468 |
updateDocid(newdocid + ".2", testdocument, FAILURE);
|
|
1148 |
// read document and check if it is same as the document which was written
|
|
1149 |
// the second time
|
|
469 | 1150 |
|
470 |
// update the inline data |
|
471 |
updateDocid(newdocid + ".2", testdocument, FAILURE); |
|
472 | 1151 |
|
473 |
// update the online data |
|
474 |
updateDocid(newdocid + ".2", testdocument, FAILURE); |
|
1152 |
///////////////////////////// |
|
1153 |
// update the document access control - read only |
|
1154 |
testdocument = getTestEmlDoc("Testing update access block", |
|
1155 |
testEmlInlineBlock2, |
|
1156 |
null, null, null, |
|
1157 |
getAccessBlock(anotheruser, true, |
|
1158 |
true, false, false, false), |
|
1159 |
null, null, null, null); |
|
1160 |
updateDocid(newdocid + ".6", testdocument, SUCCESS, false); |
|
1161 |
readDocidWhichEqualsDoc(newdocid + ".6", testdocument, SUCCESS, true); |
|
475 | 1162 |
|
476 |
// update the document access control |
|
477 |
updateDocid(newdocid + ".2", testdocument, FAILURE); |
|
1163 |
// check if the user mentioned is able to read the document |
|
1164 |
m.logout(); |
|
1165 |
m.login(anotheruser, anotherpassword); |
|
1166 |
readDocidWhichEqualsDoc(newdocid + ".6", testdocument, SUCCESS, true); |
|
478 | 1167 |
|
479 |
// update the document access control for inline data |
|
480 |
updateDocid(newdocid + ".2", testdocument, FAILURE); |
|
1168 |
// should not be able to update the document or the inline data |
|
1169 |
testdocument = getTestEmlDoc("Testing update from another user", |
|
1170 |
testEmlInlineBlock1, null, null, null, |
|
1171 |
getAccessBlock(anotheruser, true, |
|
1172 |
true, false, false, false), |
|
1173 |
null, null, null, null); |
|
1174 |
updateDocid(newdocid + ".7", testdocument, FAILURE, true); |
|
481 | 1175 |
|
482 |
// update the document access control for online data |
|
483 |
updateDocid(newdocid + ".2", testdocument, FAILURE); |
|
1176 |
// or the permissions |
|
1177 |
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); |
|
484 | 1182 |
|
485 |
// delete the document |
|
486 |
deleteDocid(newdocid + ".2", SUCCESS); |
Also available in: Unified diff
Adding new file with tests regarding access controls related to online data... the tests which are failing are commented out for the time being .. once the bugs are fixed in metacat, they will removed.