Skip to content

Commit 848d52c

Browse files
authored
Merge pull request #92 from SawamiWataru/Issue-78-Add-value-check-RequireSchemaAuthz
Issue 78 add value check require schema authz
2 parents 464bd2a + 0dc8191 commit 848d52c

File tree

11 files changed

+190
-54
lines changed

11 files changed

+190
-54
lines changed

src/main/java/io/personium/core/auth/OAuth2Helper.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ public static class SchemaLevel {
328328
*/
329329
public static boolean isMatchPermittedValue(String value) {
330330
if (value == null
331-
|| value.isEmpty()
332331
|| NONE.equals(value)
333332
|| PUBLIC.equals(value)
334333
|| CONFIDENTIAL.equals(value)) {

src/main/java/io/personium/core/model/jaxb/Acl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public boolean allows(final Privilege priv, final AccessContext ac, Map<String,
199199
public void validateAcl(boolean isCellLevel) {
200200
// Check whether requireSchemaAuthz matches permitted value.
201201
if (!OAuth2Helper.SchemaLevel.isMatchPermittedValue(requireSchemaAuthz)) {
202-
String cause = String.format("Value [%s] of requireSchemaAuthz is invalid", requireSchemaAuthz);
202+
String cause = String.format("Value [%s] for requireSchemaAuthz is invalid", requireSchemaAuthz);
203203
throw PersoniumCoreException.Dav.XML_VALIDATE_ERROR.params(cause);
204204
}
205205
// <!ELEMENT acl (ace*) >

src/test/java/io/personium/test/jersey/box/CollectionTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ private void depthTest(final NodeList nodeList, final String resorce, final Stri
14551455
.with("colname", path)
14561456
.with("token", TOKEN)
14571457
.with("roleBaseUrl", UrlUtils.roleResource(testcell, null, ""))
1458-
.with("level", "")
1458+
.with("level", "none")
14591459
.returns()
14601460
.statusCode(HttpStatus.SC_OK);
14611461

@@ -1556,7 +1556,7 @@ private void depthTest(final NodeList nodeList, final String resorce, final Stri
15561556
.with("colname", path)
15571557
.with("token", TOKEN)
15581558
.with("roleBaseUrl", UrlUtils.roleResource(testcell, null, ""))
1559-
.with("level", "")
1559+
.with("level", "none")
15601560
.returns()
15611561
.statusCode(HttpStatus.SC_OK);
15621562

@@ -1611,7 +1611,7 @@ private void depthTest(final NodeList nodeList, final String resorce, final Stri
16111611
.with("colname", path)
16121612
.with("token", TOKEN)
16131613
.with("roleBaseUrl", UrlUtils.roleResource(testcell, null, ""))
1614-
.with("level", "")
1614+
.with("level", "none")
16151615
.returns()
16161616
.statusCode(HttpStatus.SC_OK);
16171617

@@ -1662,7 +1662,7 @@ private void depthTest(final NodeList nodeList, final String resorce, final Stri
16621662
.with("colname", path)
16631663
.with("token", TOKEN)
16641664
.with("roleBaseUrl", UrlUtils.roleResource(testcell, null, ""))
1665-
.with("level", "")
1665+
.with("level", "none")
16661666
.returns()
16671667
.statusCode(HttpStatus.SC_BAD_REQUEST);
16681668

@@ -1696,7 +1696,7 @@ private void depthTest(final NodeList nodeList, final String resorce, final Stri
16961696
.with("col", Setup.TEST_ODATA)
16971697
.with("token", AbstractCase.MASTER_TOKEN_NAME)
16981698
.with("roleBaseUrl", UrlUtils.roleResource(Setup.TEST_CELL1, "notExistsBox", "role1"))
1699-
.with("level", "")
1699+
.with("level", "none")
17001700
.returns()
17011701
.statusCode(HttpStatus.SC_BAD_REQUEST);
17021702
}
@@ -1714,7 +1714,7 @@ private void depthTest(final NodeList nodeList, final String resorce, final Stri
17141714
.with("role", "notExistsCol/../__/role1")
17151715
.with("token", AbstractCase.MASTER_TOKEN_NAME)
17161716
.with("roleBaseUrl", UrlUtils.roleResource(Setup.TEST_CELL1, null, ""))
1717-
.with("level", "")
1717+
.with("level", "none")
17181718
.returns()
17191719
.statusCode(HttpStatus.SC_BAD_REQUEST);
17201720
}
@@ -1740,7 +1740,7 @@ private void depthTest(final NodeList nodeList, final String resorce, final Stri
17401740
.with("col", Setup.TEST_ODATA)
17411741
.with("token", AbstractCase.MASTER_TOKEN_NAME)
17421742
.with("roleBaseUrl", UrlUtils.roleResource(Setup.TEST_CELL1, testBox, testRole))
1743-
.with("level", "")
1743+
.with("level", "none")
17441744
.returns()
17451745
.statusCode(HttpStatus.SC_BAD_REQUEST);
17461746
} finally {
@@ -1767,7 +1767,7 @@ private void depthTest(final NodeList nodeList, final String resorce, final Stri
17671767
.with("colname", "")
17681768
.with("token", TOKEN)
17691769
.with("roleBaseUrl", UrlUtils.roleResource(testcell, null, ""))
1770-
.with("level", "")
1770+
.with("level", "none")
17711771
.returns()
17721772
.statusCode(HttpStatus.SC_OK);
17731773

@@ -1799,7 +1799,7 @@ private void depthTest(final NodeList nodeList, final String resorce, final Stri
17991799
// ACLの設定を下に戻す
18001800
DavResourceUtils.setACL(testcell, AbstractCase.MASTER_TOKEN_NAME,
18011801
HttpStatus.SC_OK, "", ACL_AUTH_TEST_SETTING_FILE, Setup.TEST_BOX1,
1802-
"");
1802+
"none");
18031803
}
18041804
}
18051805

@@ -1822,7 +1822,7 @@ private void depthTest(final NodeList nodeList, final String resorce, final Stri
18221822

18231823
// ACLの設定
18241824
DavResourceUtils.setACLwithBox(testcell, token, HttpStatus.SC_OK,
1825-
path, "", "box/acl-setting.txt", role, path, "<D:write/>", "");
1825+
path, "", "box/acl-setting.txt", role, path, "<D:write/>", "none");
18261826

18271827
// ACLの確認
18281828
TResponse tresponseWebDav = CellUtils.propfind(testcell + "/" + path,
@@ -1850,7 +1850,7 @@ private void depthTest(final NodeList nodeList, final String resorce, final Stri
18501850
// ACL設定を元に戻す
18511851
DavResourceUtils.setACL(testcell, AbstractCase.MASTER_TOKEN_NAME,
18521852
HttpStatus.SC_OK, "", ACL_AUTH_TEST_SETTING_FILE, Setup.TEST_BOX1,
1853-
"");
1853+
"none");
18541854
}
18551855
}
18561856

src/test/java/io/personium/test/jersey/box/acl/AclTest.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public AclTest() {
103103
// Principal:all
104104
// Privilege:readのACLをbox1に設定
105105
DavResourceUtils.setACL(null, TOKEN, HttpStatus.SC_OK, TEST_CELL1 + "/" + BOX_NAME, ACL_ALL_TEST,
106-
null, "<D:read/>", "");
106+
null, "<D:read/>", "none");
107107

108108
// PROPFINDでACLの確認
109109
TResponse tresponse = CellUtils.propfind(TEST_CELL1 + "/" + BOX_NAME,
@@ -155,7 +155,7 @@ public AclTest() {
155155
.with("colname", "")
156156
.with("roleBaseUrl", UrlUtils.roleResource(TEST_CELL1, null, ""))
157157
.with("token", AbstractCase.MASTER_TOKEN_NAME)
158-
.with("level", "")
158+
.with("level", "none")
159159
.returns()
160160
.statusCode(HttpStatus.SC_OK);
161161
}
@@ -171,7 +171,7 @@ public AclTest() {
171171
// Principal:role1 Privilege:write
172172
// のACLをbox1に設定
173173
setAclAllandRole(TEST_CELL1, TOKEN, HttpStatus.SC_OK, TEST_CELL1 + "/" + BOX_NAME,
174-
"box/acl-setting-all-role.txt", "role1", "<D:read/>", "<D:write/>", "");
174+
"box/acl-setting-all-role.txt", "role1", "<D:read/>", "<D:write/>", "none");
175175

176176
// PROPFINDでACLの確認
177177
CellUtils.propfind(TEST_CELL1 + "/" + BOX_NAME,
@@ -210,7 +210,7 @@ public AclTest() {
210210
.with("colname", "")
211211
.with("roleBaseUrl", UrlUtils.roleResource(TEST_CELL1, null, ""))
212212
.with("token", AbstractCase.MASTER_TOKEN_NAME)
213-
.with("level", "")
213+
.with("level", "none")
214214
.returns()
215215
.statusCode(HttpStatus.SC_OK);
216216
}
@@ -227,7 +227,7 @@ public AclTest() {
227227
// Principal:all
228228
// Privilege:readのACLをbox1に設定
229229
DavResourceUtils.setACL(null, TOKEN, HttpStatus.SC_OK, TEST_CELL1 + "/" + BOX_NAME, ACL_ALL_TEST,
230-
null, "<D:read/>", "");
230+
null, "<D:read/>", "none");
231231

232232
// PROPFINDでACLの確認
233233
TResponse tresponse = CellUtils.propfind(TEST_CELL1 + "/" + BOX_NAME,
@@ -239,7 +239,7 @@ public AclTest() {
239239

240240
// ・空のACLを設定してACLが消えることを確認
241241
DavResourceUtils.setACL(TEST_CELL1, TOKEN, HttpStatus.SC_OK, "", ACL_NULL_TEST,
242-
null, null, "");
242+
null, null, "none");
243243

244244
// PROPFINDでACLの確認
245245
TResponse tresponse2 = CellUtils.propfind(TEST_CELL1 + "/" + BOX_NAME,
@@ -254,7 +254,7 @@ public AclTest() {
254254
.with("colname", "")
255255
.with("roleBaseUrl", UrlUtils.roleResource(TEST_CELL1, null, ""))
256256
.with("token", AbstractCase.MASTER_TOKEN_NAME)
257-
.with("level", "")
257+
.with("level", "none")
258258
.returns()
259259
.statusCode(HttpStatus.SC_OK);
260260
}
@@ -276,7 +276,7 @@ public AclTest() {
276276

277277
// 上記Boxに上記RoleでACL設定
278278
DavResourceUtils.setACLwithBox(TEST_CELL1, TOKEN, HttpStatus.SC_OK, testBox, "",
279-
ACL_SETTING_TEST, testRole, testBox, "<D:read/>", "");
279+
ACL_SETTING_TEST, testRole, testBox, "<D:read/>", "none");
280280

281281
// PROPFIND
282282
TResponse res = DavResourceUtils.propfind("box/propfind-box-allprop.txt",
@@ -324,7 +324,7 @@ public AclTest() {
324324

325325
// 上記BoxにBoxに紐付かないRoleでACL設定
326326
DavResourceUtils.setACLwithBox(TEST_CELL1, TOKEN, HttpStatus.SC_OK, testBox, "", ACL_SETTING_TEST,
327-
testRole, null, "<D:read/>", "");
327+
testRole, null, "<D:read/>", "none");
328328

329329
// PROPFIND
330330
TResponse res = DavResourceUtils.propfind("box/propfind-box-allprop.txt",
@@ -388,7 +388,7 @@ public AclTest() {
388388

389389
// 上記Boxに上記RoleでACL設定
390390
DavResourceUtils.setACLwithBox(TEST_CELL1, TOKEN, HttpStatus.SC_OK, testBox1, "",
391-
ACL_SETTING_TEST, testRole, testBox1, "<D:read/>", "");
391+
ACL_SETTING_TEST, testRole, testBox1, "<D:read/>", "none");
392392

393393
// PROPFIND
394394
TResponse res = DavResourceUtils.propfind("box/propfind-box-allprop.txt",
@@ -437,7 +437,7 @@ public AclTest() {
437437
// 上記Boxに上記RoleでACL設定
438438
DavResourceUtils.setACLwithRoleBaseUrl(TEST_CELL1, TOKEN, HttpStatus.SC_OK, testBox1, "",
439439
"box/acl-setting-baseurl.txt", UrlUtils.roleResource(TEST_CELL1, testBox1, testRole),
440-
"<D:read/>", "");
440+
"<D:read/>", "none");
441441

442442
// PROPFIND
443443
TResponse res = DavResourceUtils.propfind("box/propfind-box-allprop.txt",
@@ -505,7 +505,7 @@ public AclTest() {
505505
.with("colname", "")
506506
.with("roleBaseUrl", UrlUtils.roleResource(TEST_CELL1, null, ""))
507507
.with("token", AbstractCase.MASTER_TOKEN_NAME)
508-
.with("level", "")
508+
.with("level", "none")
509509
.returns()
510510
.statusCode(HttpStatus.SC_OK);
511511
}
@@ -528,7 +528,7 @@ public AclTest() {
528528
// ACLをtestcell1/box2に設定
529529
DavResourceUtils.setACLwithBox(TEST_CELL1, AbstractCase.BEARER_MASTER_TOKEN, HttpStatus.SC_OK, box2, "",
530530
"box/acl-2role-setting.txt", roleNotDelete, roleDelete, box2, "<D:read/>",
531-
"<D:write/>", "");
531+
"<D:write/>", "none");
532532

533533
// roleを削除
534534
RoleUtils.delete(TEST_CELL1, TOKEN, roleDelete, box2, HttpStatus.SC_NO_CONTENT);
@@ -555,7 +555,7 @@ public AclTest() {
555555
.with("colname", "")
556556
.with("roleBaseUrl", UrlUtils.roleResource(TEST_CELL1, null, ""))
557557
.with("token", AbstractCase.MASTER_TOKEN_NAME)
558-
.with("level", "")
558+
.with("level", "none")
559559
.returns()
560560
.statusCode(HttpStatus.SC_OK);
561561
}
@@ -575,7 +575,7 @@ public AclTest() {
575575

576576
// ACLをtestcell1/box2に設定
577577
DavResourceUtils.setACLwithBox(TEST_CELL1, TOKEN, HttpStatus.SC_OK, box2, "",
578-
ACL_SETTING_TEST, roleDelete, null, "<D:read/>", "");
578+
ACL_SETTING_TEST, roleDelete, null, "<D:read/>", "none");
579579

580580
// roleを削除
581581
RoleUtils.delete(TEST_CELL1, TOKEN, roleDelete, null, HttpStatus.SC_NO_CONTENT);
@@ -598,7 +598,7 @@ public AclTest() {
598598
.with("colname", "")
599599
.with("roleBaseUrl", UrlUtils.roleResource(TEST_CELL1, null, ""))
600600
.with("token", AbstractCase.MASTER_TOKEN_NAME)
601-
.with("level", "")
601+
.with("level", "none")
602602
.returns()
603603
.statusCode(HttpStatus.SC_OK);
604604
}

src/test/java/io/personium/test/jersey/cell/AclTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public AclTest() {
205205
// Principal:all Privilege:read
206206
// Principal:role1 Privilege:write
207207
setAclAllandRole(TEST_CELL1, TOKEN, HttpStatus.SC_OK, TEST_CELL1 + "/" + testBox1,
208-
"box/acl-setting-all-role.txt", "role1", "<D:read/>", "<D:write/>", "");
208+
"box/acl-setting-all-role.txt", "role1", "<D:read/>", "<D:write/>", "none");
209209

210210
// PROPFINDでACLの確認
211211
CellUtils.propfind(TEST_CELL1 + "/" + testBox1, TOKEN, "0", HttpStatus.SC_MULTI_STATUS);
@@ -236,7 +236,7 @@ public AclTest() {
236236
.with("colname", "")
237237
.with("roleBaseUrl", UrlUtils.roleResource(TEST_CELL1, null, ""))
238238
.with("token", TOKEN)
239-
.with("level", "")
239+
.with("level", "none")
240240
.returns()
241241
.statusCode(HttpStatus.SC_OK);
242242

@@ -247,7 +247,6 @@ public AclTest() {
247247
.with("role2", TEST_ROLE2)
248248
.with("box", testBox1)
249249
.with("roleBaseUrl", UrlUtils.roleResource(TEST_CELL1, null, ""))
250-
.with("level", "")
251250
.returns()
252251
.statusCode(HttpStatus.SC_OK);
253252
}

src/test/java/io/personium/test/jersey/cell/auth/SchemaAuthTest.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import org.junit.experimental.categories.Category;
2626
import org.junit.runner.RunWith;
2727

28+
import com.sun.jersey.test.framework.JerseyTest;
29+
2830
import io.personium.common.auth.token.AbstractOAuth2Token.TokenDsigException;
2931
import io.personium.common.auth.token.AbstractOAuth2Token.TokenParseException;
3032
import io.personium.common.auth.token.AbstractOAuth2Token.TokenRootCrtException;
@@ -46,10 +48,9 @@
4648
import io.personium.test.utils.CellUtils;
4749
import io.personium.test.utils.DavResourceUtils;
4850
import io.personium.test.utils.Http;
49-
import io.personium.test.utils.UserDataUtils;
5051
import io.personium.test.utils.ResourceUtils;
5152
import io.personium.test.utils.TResponse;
52-
import com.sun.jersey.test.framework.JerseyTest;
53+
import io.personium.test.utils.UserDataUtils;
5354

5455
/**
5556
* スキーマ認証のテスト.
@@ -176,8 +177,12 @@ private void cheackResourceSchema(String path, String file, String token,
176177
* @param cellPath セル
177178
*/
178179
private void setAclSchema(String box, String path, String level, String cellPath) {
180+
String settingFile = ACL_AUTH_TEST_SETTING_FILE;
181+
if (level.isEmpty()) {
182+
settingFile = "box/acl-setscheme-none-schema-level.txt";
183+
}
179184
DavResourceUtils.setACL(cellPath, AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_OK, path,
180-
ACL_AUTH_TEST_SETTING_FILE, box, level);
185+
settingFile, box, level);
181186
}
182187

183188
/**
@@ -678,7 +683,7 @@ private void setAclSchema(String box, String path, String roleBaseUrl, String le
678683
"hoge", Box.DEFAULT_BOX_NAME, DAV_RESOURCE, -1);
679684
// ACL設定
680685
DavResourceUtils.setACL(TEST_CELL1, AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_OK, DAV_RESOURCE,
681-
"box/acl-all.txt", Box.DEFAULT_BOX_NAME, "");
686+
"box/acl-all-none-schema-level.txt", Box.DEFAULT_BOX_NAME, "");
682687

683688
this.checkResourcesWithSchema("", DAV_RESOURCE, tokenStr, Box.DEFAULT_BOX_NAME, TEST_CELL1);
684689
} finally {
@@ -791,7 +796,7 @@ private TResponse setACL(String box, String path, String setFile) {
791796
.with("box", box)
792797
.with("token", AbstractCase.MASTER_TOKEN_NAME)
793798
.with("roleBaseUrl", UrlUtils.roleResource(TEST_CELL1, null, ""))
794-
.with("level", "")
799+
.with("level", "none")
795800
.returns()
796801
.statusCode(HttpStatus.SC_OK);
797802
return tresponseWebDav;

src/test/java/io/personium/test/setup/Setup.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ private void create(Config conf) {
409409
if ("box1".equals(box.boxName)) {
410410
// BoxレベルACLテスト用
411411
DavResourceUtils.setACL(conf.cellName, AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_OK, "",
412-
"box/acl-authtest.txt", Setup.TEST_BOX1, "");
412+
"box/acl-setscheme-none-schema-level.txt", Setup.TEST_BOX1, "");
413413
}
414414
}
415415

@@ -419,14 +419,14 @@ private void create(Config conf) {
419419
createOdataCollection(conf.cellName, TEST_BOX1, SEARCH_ODATA);
420420

421421
DavResourceUtils.setACL(conf.cellName, AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_OK, TEST_ODATA,
422-
"box/acl-authtest.txt", Setup.TEST_BOX1, "");
422+
"box/acl-setscheme-none-schema-level.txt", Setup.TEST_BOX1, "");
423423
createWebdavCollection(conf.cellName, TEST_BOX1, "setdavcol");
424424
DavResourceUtils.setACL(conf.cellName, AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_OK, "setdavcol",
425-
"box/acl-authtest.txt", Setup.TEST_BOX1, "");
425+
"box/acl-setscheme-none-schema-level.txt", Setup.TEST_BOX1, "");
426426
this.createPatch2("setservice", conf.cellName);
427427
createServiceCollection(conf.cellName, TEST_BOX1, "service_relay");
428428
DavResourceUtils.setACL(conf.cellName, AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_OK, "service_relay",
429-
"box/acl-authtest.txt", Setup.TEST_BOX1, "");
429+
"box/acl-setscheme-none-schema-level.txt", Setup.TEST_BOX1, "");
430430

431431
// テストコレクションのエンティティ作成
432432
createTestCollectionSchema(conf.cellName);
@@ -452,14 +452,14 @@ private void create(Config conf) {
452452
createOdataCollection(conf.cellName, TEST_BOX1, TEST_ODATA);
453453

454454
DavResourceUtils.setACL(conf.cellName, AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_OK, TEST_ODATA,
455-
"box/acl-authtest.txt", Setup.TEST_BOX1, "");
455+
"box/acl-setscheme-none-schema-level.txt", Setup.TEST_BOX1, "");
456456
createWebdavCollection(conf.cellName, TEST_BOX1, "setdavcol");
457457
DavResourceUtils.setACL(conf.cellName, AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_OK, "setdavcol",
458-
"box/acl-authtest.txt", Setup.TEST_BOX1, "");
458+
"box/acl-setscheme-none-schema-level.txt", Setup.TEST_BOX1, "");
459459
this.createPatch2("setservice", conf.cellName);
460460
createServiceCollection(conf.cellName, TEST_BOX1, "service_relay");
461461
DavResourceUtils.setACL(conf.cellName, AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_OK, "service_relay",
462-
"box/acl-authtest.txt", Setup.TEST_BOX1, "");
462+
"box/acl-setscheme-none-schema-level.txt", Setup.TEST_BOX1, "");
463463

464464
// テストコレクションのエンティティ作成
465465
createTestCollectionSchema(conf.cellName);

0 commit comments

Comments
 (0)