[tests-only] use new json schema assertion lib that supports latest schema drafts (#8503)

* test(api): use new json schema assertion lib that supports latest schema drafts

* test(api): fix json schema

* test(api): fix method call

* test(api): update expected failure lines

* test(api): add custom schema validator

* test(api): add custom schema validator

* test(api): add custom schema validator

* test(api): add custom schema validator

* test(api): make json array validation strict

* test(api): fix php code style

* test(api): update expected failure lines
This commit is contained in:
Sawjan Gurung
2024-02-23 16:24:22 +05:45
committed by GitHub
parent ee501f225e
commit 3cea035d6d
17 changed files with 2563 additions and 2312 deletions
@@ -59,24 +59,24 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiGraphUserGroup/getUser.feature:98](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L98)
- [apiGraphUserGroup/getUser.feature:99](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L99)
- [apiGraphUserGroup/getUser.feature:100](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L100)
- [apiGraphUserGroup/getUser.feature:650](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L650)
- [apiGraphUserGroup/getUser.feature:651](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L651)
- [apiGraphUserGroup/getUser.feature:652](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L652)
- [apiGraphUserGroup/getUser.feature:653](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L653)
- [apiGraphUserGroup/getUser.feature:654](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L654)
- [apiGraphUserGroup/getUser.feature:655](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L655)
- [apiGraphUserGroup/getUser.feature:656](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L656)
- [apiGraphUserGroup/getUser.feature:657](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L657)
- [apiGraphUserGroup/getUser.feature:658](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L658)
- [apiGraphUserGroup/getUser.feature:659](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L659)
- [apiGraphUserGroup/getUser.feature:660](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L660)
- [apiGraphUserGroup/getUser.feature:661](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L661)
- [apiGraphUserGroup/getUser.feature:662](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L662)
- [apiGraphUserGroup/getUser.feature:663](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L663)
- [apiGraphUserGroup/getUser.feature:664](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L664)
- [apiGraphUserGroup/getUser.feature:665](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L665)
- [apiGraphUserGroup/getUser.feature:666](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L666)
- [apiGraphUserGroup/getUser.feature:667](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L667)
- [apiGraphUserGroup/getUser.feature:668](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getUser.feature#L668)
#### [Normal user can get expanded members information of a group](https://github.com/owncloud/ocis/issues/5604)
- [apiGraphUserGroup/getGroup.feature:389](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getGroup.feature#L389)
- [apiGraphUserGroup/getGroup.feature:390](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getGroup.feature#L390)
- [apiGraphUserGroup/getGroup.feature:391](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getGroup.feature#L391)
- [apiGraphUserGroup/getGroup.feature:399](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getGroup.feature#L399)
- [apiGraphUserGroup/getGroup.feature:400](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getGroup.feature#L400)
- [apiGraphUserGroup/getGroup.feature:401](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/getGroup.feature#L401)
#### [Same users can be added in a group multiple time](https://github.com/owncloud/ocis/issues/5702)
@@ -389,12 +389,12 @@ Feature: user GDPR (General Data Protection Regulation) report
},
"groups": {
"type": "array",
"items": [
{
"type": "string",
"pattern": "^%group_id_pattern%$"
}
]
"minItems": 1,
"maxItems": 1,
"items": {
"type": "string",
"pattern": "^%group_id_pattern%$"
}
},
"uid_number": {
"type": "number",
@@ -672,8 +672,10 @@ Feature: user GDPR (General Data Protection Regulation) report
"opaque_id"
],
"properties": {
"type": "object",
"pattern": "^%user_id_pattern%:%user_id_pattern%:%user_id_pattern%$"
"opaque_id": {
"type": "string",
"pattern": "^%user_id_pattern%:%user_id_pattern%:%user_id_pattern%$"
}
}
},
"Sharee": {
@@ -55,7 +55,6 @@ Feature: edit user
"onPremisesSamAccountName"
],
"properties": {
"type": "string",
"onPremisesSamAccountName": {
"enum": ["<newUserName>"]
}
@@ -131,35 +131,35 @@ Feature: get groups and their members
"properties": {
"members": {
"type": "array",
"items": [
{
"type": "object",
"required": [
"displayName",
"id",
"mail",
"onPremisesSamAccountName"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Brian Murphy"]
},
"id" : {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["brian@example.org"]
},
"onPremisesSamAccountName": {
"type": "string",
"enum": ["Brian"]
}
"maxItems": 1,
"minItems": 1,
"items": {
"type": "object",
"required": [
"displayName",
"id",
"mail",
"onPremisesSamAccountName"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Brian Murphy"]
},
"id" : {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["brian@example.org"]
},
"onPremisesSamAccountName": {
"type": "string",
"enum": ["Brian"]
}
}
]
}
}
}
}
@@ -174,62 +174,67 @@ Feature: get groups and their members
"properties": {
"members": {
"type": "array",
"items": [
{
"type": "object",
"required": [
"displayName",
"id",
"mail",
"onPremisesSamAccountName"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Alice Hansen"]
},
"id" : {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["alice@example.org"]
},
"onPremisesSamAccountName": {
"type": "string",
"enum": ["Alice"]
"maxItems": 2,
"minItems": 2,
"uniqueItems": true,
"items": {
"oneOf": [
{
"type": "object",
"required": [
"displayName",
"id",
"mail",
"onPremisesSamAccountName"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Alice Hansen"]
},
"id" : {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["alice@example.org"]
},
"onPremisesSamAccountName": {
"type": "string",
"enum": ["Alice"]
}
}
},
{
"type": "object",
"required": [
"displayName",
"id",
"mail",
"onPremisesSamAccountName"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Carol King"]
},
"id" : {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["carol@example.org"]
},
"onPremisesSamAccountName": {
"type": "string",
"enum": ["Carol"]
}
}
}
},
{
"type": "object",
"required": [
"displayName",
"id",
"mail",
"onPremisesSamAccountName"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Carol King"]
},
"id" : {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["carol@example.org"]
},
"onPremisesSamAccountName": {
"type": "string",
"enum": ["Carol"]
}
}
}
]
]
}
}
}
}
@@ -291,62 +296,67 @@ Feature: get groups and their members
"properties": {
"members": {
"type": "array",
"items": [
{
"type": "object",
"required": [
"displayName",
"id",
"mail",
"onPremisesSamAccountName"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Alice Hansen"]
},
"id" : {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["alice@example.org"]
},
"onPremisesSamAccountName": {
"type": "string",
"enum": ["Alice"]
"maxItems": 2,
"minItems": 2,
"uniqueItems": true,
"items": {
"oneOf": [
{
"type": "object",
"required": [
"displayName",
"id",
"mail",
"onPremisesSamAccountName"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Alice Hansen"]
},
"id" : {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["alice@example.org"]
},
"onPremisesSamAccountName": {
"type": "string",
"enum": ["Alice"]
}
}
},
{
"type": "object",
"required": [
"displayName",
"id",
"mail",
"onPremisesSamAccountName"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Brian Murphy"]
},
"id" : {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["brian@example.org"]
},
"onPremisesSamAccountName": {
"type": "string",
"enum": ["Brian"]
}
}
}
},
{
"type": "object",
"required": [
"displayName",
"id",
"mail",
"onPremisesSamAccountName"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Brian Murphy"]
},
"id" : {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["brian@example.org"]
},
"onPremisesSamAccountName": {
"type": "string",
"enum": ["Brian"]
}
}
}
]
]
}
}
}
}
@@ -471,23 +481,27 @@ Feature: get groups and their members
"properties": {
"value": {
"type": "array",
"required": [
"displayName",
"id",
"groupTypes"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["tea-lover"]
},
"id": {
"type": "string",
"pattern": "%group_id_pattern%"
},
"groupTypes": {
"type": "array",
"enum": []
"maxItems": 1,
"minItems": 1,
"items": {
"type": "object",
"required": [
"displayName",
"id",
"groupTypes"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["tea-lover"]
},
"id": {
"type": "string",
"pattern": "%group_id_pattern%"
},
"groupTypes": {
"const": []
}
}
}
}
@@ -493,14 +493,16 @@ Feature: get users
"user"
],
"properties": {
"user": "string",
"required": [
"id"
],
"properties": {
"id": {
"type": "string",
"enum": ["%user_id_pattern%"]
"user": {
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"type": "string",
"pattern": "%user_id_pattern%"
}
}
}
}
@@ -583,32 +585,37 @@ Feature: get users
},
"memberOf": {
"type": "array",
"items": [
{
"type": "object",
"required": [
"displayName"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["tea-lover"]
"minItems": 2,
"maxItems": 2,
"uniqueItems": true,
"items": {
"oneOf": [
{
"type": "object",
"required": [
"displayName"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["tea-lover"]
}
}
},
{
"type": "object",
"required": [
"displayName"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["coffee-lover"]
}
}
}
},
{
"type": "object",
"required": [
"displayName"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["coffee-lover"]
}
}
}
]
]
}
}
}
}
@@ -682,72 +689,76 @@ Feature: get users
"properties": {
"value": {
"type": "array",
"items": [
{
"type": "object",
"required": [
"id",
"mail",
"onPremisesSamAccountName",
"accountEnabled",
"userType"
],
"properties": {
"id" : {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["alice@example.org"]
},
"onPremisesSamAccountName": {
"type": "string",
"enum": ["Alice"]
},
"accountEnabled": {
"type": "boolean",
"enum": [true]
},
"userType": {
"type": "string",
"enum": ["Member"]
"minItems": 2,
"maxItems": 2,
"uniqueItems": true,
"items": {
"oneOf": [
{
"type": "object",
"required": [
"id",
"mail",
"onPremisesSamAccountName",
"accountEnabled",
"userType"
],
"properties": {
"id" : {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["alice@example.org"]
},
"onPremisesSamAccountName": {
"type": "string",
"enum": ["Alice"]
},
"accountEnabled": {
"type": "boolean",
"enum": [true]
},
"userType": {
"type": "string",
"enum": ["Member"]
}
}
},
{
"type": "object",
"required": [
"id",
"mail",
"onPremisesSamAccountName",
"accountEnabled"
],
"properties": {
"id" : {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["brian@example.org"]
},
"onPremisesSamAccountName": {
"type": "string",
"enum": ["Brian"]
},
"accountEnabled": {
"type": "boolean",
"enum": [true]
},
"userType": {
"type": "string",
"enum": ["Member"]
}
}
}
},
{
"type": "object",
"required": [
"id",
"mail",
"onPremisesSamAccountName",
"accountEnabled"
],
"properties": {
"id" : {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["brian@example.org"]
},
"onPremisesSamAccountName": {
"type": "string",
"enum": ["Brian"]
},
"accountEnabled": {
"type": "boolean",
"enum": [true]
},
"userType": {
"type": "string",
"enum": ["Member"]
}
}
}
],
"additionalItems": false
]
}
}
}
}
@@ -765,41 +776,40 @@ Feature: get users
"properties": {
"value": {
"type": "array",
"items": [
{
"type": "object",
"required": [
"id",
"mail",
"onPremisesSamAccountName",
"accountEnabled",
"userType"
],
"properties": {
"id" : {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["brian@example.org"]
},
"onPremisesSamAccountName": {
"type": "string",
"enum": ["Brian"]
},
"accountEnabled": {
"type": "boolean",
"enum": [true]
},
"userType": {
"type": "string",
"enum": ["Member"]
}
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
"id",
"mail",
"onPremisesSamAccountName",
"accountEnabled",
"userType"
],
"properties": {
"id" : {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["brian@example.org"]
},
"onPremisesSamAccountName": {
"type": "string",
"enum": ["Brian"]
},
"accountEnabled": {
"type": "boolean",
"enum": [true]
},
"userType": {
"type": "string",
"enum": ["Member"]
}
}
],
"additionalItems": false
}
}
}
}
@@ -1354,28 +1364,33 @@ Feature: get users
"properties": {
"value": {
"type": "array",
"required": [
"displayName",
"id",
"mail",
"userType"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Alice Hansen"]
},
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["alice@example.org"]
},
"userType": {
"type": "string",
"enum": ["Member"]
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
"displayName",
"id",
"mail",
"userType"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Alice Hansen"]
},
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["alice@example.org"]
},
"userType": {
"type": "string",
"enum": ["Member"]
}
}
}
}
@@ -1458,28 +1473,33 @@ Feature: get users
"properties": {
"value": {
"type": "array",
"required": [
"displayName",
"id",
"mail",
"userType"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Alice Hansen"]
},
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["alice@example.org"]
},
"userType": {
"type": "string",
"enum": ["Member"]
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
"displayName",
"id",
"mail",
"userType"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Alice Hansen"]
},
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["alice@example.org"]
},
"userType": {
"type": "string",
"enum": ["Member"]
}
}
}
}
@@ -1502,28 +1522,33 @@ Feature: get users
"properties": {
"value": {
"type": "array",
"required": [
"displayName",
"id",
"mail",
"userType"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Alice Hansen"]
},
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["alice@example.org"]
},
"userType": {
"type": "string",
"enum": ["Member"]
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
"displayName",
"id",
"mail",
"userType"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Alice Hansen"]
},
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["alice@example.org"]
},
"userType": {
"type": "string",
"enum": ["Member"]
}
}
}
}
@@ -1550,63 +1575,68 @@ Feature: get users
],
"properties": {
"value": {
"type": "array",
"items": [
{
"type": "object",
"required": [
"displayName",
"id",
"mail",
"userType"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Alice Hansen"]
},
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["alice@example.org"]
},
"userType": {
"type": "string",
"enum": ["Member"]
"type": "array",
"minItems": 2,
"maxItems": 2,
"uniqueItems": true,
"items": {
"oneOf": [
{
"type": "object",
"required": [
"displayName",
"id",
"mail",
"userType"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Alice Hansen"]
},
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["alice@example.org"]
},
"userType": {
"type": "string",
"enum": ["Member"]
}
}
},
{
"type": "object",
"required": [
"displayName",
"id",
"mail",
"userType"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Alice Hansen"]
},
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["another-alice@example.org"]
},
"userType": {
"type": "string",
"enum": ["Member"]
}
}
}
},
{
"type": "object",
"required": [
"displayName",
"id",
"mail",
"userType"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["Alice Hansen"]
},
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
},
"mail": {
"type": "string",
"enum": ["another-alice@example.org"]
},
"userType": {
"type": "string",
"enum": ["Member"]
}
}
}
]
]
}
}
}
}
@@ -68,32 +68,37 @@ Feature: get user's own information
},
"memberOf": {
"type": "array",
"items": [
{
"type": "object",
"required": [
"displayName"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["tea-lover"]
"minItems": 2,
"maxItems": 2,
"uniqueItems": true,
"items": {
"oneOf": [
{
"type": "object",
"required": [
"displayName"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["tea-lover"]
}
}
},
{
"type": "object",
"required": [
"displayName"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["coffee-lover"]
}
}
}
},
{
"type": "object",
"required": [
"displayName"
],
"properties": {
"displayName": {
"type": "string",
"enum": ["coffee-lover"]
}
}
}
]
]
}
}
}
}
@@ -50,148 +50,151 @@ Feature: List a sharing permissions
"type": "array",
"minItems": 4,
"maxItems": 4,
"items": [
{
"type": "object",
"required": [
"@libre.graph.weight",
"description",
"displayName",
"id"
],
"properties": {
"@libre.graph.weight": {
"type": "integer",
"enum": [
1
]
},
"description": {
"type": "string",
"enum": [
"Allows upload file or folder"
]
},
"displayName": {
"type": "string",
"enum": [
"Uploader"
]
},
"id": {
"type": "string",
"enum": [
"1c996275-f1c9-4e71-abdf-a42f6495e960"
]
"uniqueItems": true,
"items": {
"oneOf": [
{
"type": "object",
"required": [
"@libre.graph.weight",
"description",
"displayName",
"id"
],
"properties": {
"@libre.graph.weight": {
"type": "integer",
"enum": [
1
]
},
"description": {
"type": "string",
"enum": [
"Allows upload file or folder"
]
},
"displayName": {
"type": "string",
"enum": [
"Uploader"
]
},
"id": {
"type": "string",
"enum": [
"1c996275-f1c9-4e71-abdf-a42f6495e960"
]
}
}
},
{
"type": "object",
"required": [
"@libre.graph.weight",
"description",
"displayName",
"id"
],
"properties": {
"@libre.graph.weight": {
"type": "integer",
"enum": [
2
]
},
"description": {
"type": "string",
"enum": [
"Allows reading the shared file or folder"
]
},
"displayName": {
"type": "string",
"enum": [
"Viewer"
]
},
"id": {
"type": "string",
"enum": [
"b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5"
]
}
}
},
{
"type": "object",
"required": [
"@libre.graph.weight",
"description",
"displayName",
"id"
],
"properties": {
"@libre.graph.weight": {
"type": "integer",
"enum": [
3
]
},
"description": {
"type": "string",
"enum": [
"Allows reading and updating file"
]
},
"displayName": {
"type": "string",
"enum": [
"Editor"
]
},
"id": {
"type": "string",
"enum": [
"2d00ce52-1fc2-4dbc-8b95-a73b73395f5a"
]
}
}
},
{
"type": "object",
"required": [
"@libre.graph.weight",
"description",
"displayName",
"id"
],
"properties": {
"@libre.graph.weight": {
"type": "integer",
"enum": [
4
]
},
"description": {
"type": "string",
"enum": [
"Allows creating, reading, updating and deleting the shared file or folder"
]
},
"displayName": {
"type": "string",
"enum": [
"Editor"
]
},
"id": {
"type": "string",
"enum": [
"fb6c3e19-e378-47e5-b277-9732f9de6e21"
]
}
}
}
},
{
"type": "object",
"required": [
"@libre.graph.weight",
"description",
"displayName",
"id"
],
"properties": {
"@libre.graph.weight": {
"type": "integer",
"enum": [
2
]
},
"description": {
"type": "string",
"enum": [
"Allows reading the shared file or folder"
]
},
"displayName": {
"type": "string",
"enum": [
"Viewer"
]
},
"id": {
"type": "string",
"enum": [
"b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5"
]
}
}
},
{
"type": "object",
"required": [
"@libre.graph.weight",
"description",
"displayName",
"id"
],
"properties": {
"@libre.graph.weight": {
"type": "integer",
"enum": [
3
]
},
"description": {
"type": "string",
"enum": [
"Allows reading and updating file"
]
},
"displayName": {
"type": "string",
"enum": [
"Editor"
]
},
"id": {
"type": "string",
"enum": [
"2d00ce52-1fc2-4dbc-8b95-a73b73395f5a"
]
}
}
},
{
"type": "object",
"required": [
"@libre.graph.weight",
"description",
"displayName",
"id"
],
"properties": {
"@libre.graph.weight": {
"type": "integer",
"enum": [
4
]
},
"description": {
"type": "string",
"enum": [
"Allows creating, reading, updating and deleting the shared file or folder"
]
},
"displayName": {
"type": "string",
"enum": [
"Editor"
]
},
"id": {
"type": "string",
"enum": [
"fb6c3e19-e378-47e5-b277-9732f9de6e21"
]
}
}
}
]
]
}
}
}
}
@@ -34,6 +34,8 @@ Feature: Send a sharing invitations
"properties": {
"value": {
"type": "array",
"maxItems": 1,
"minItems": 1,
"items": {
"type": "object",
"required": [
@@ -48,6 +50,8 @@ Feature: Send a sharing invitations
},
"roles": {
"type": "array",
"maxItems": 1,
"minItems": 1,
"items": {
"type": "string",
"pattern": "^%role_id_pattern%$"
@@ -125,6 +129,8 @@ Feature: Send a sharing invitations
"properties": {
"value": {
"type": "array",
"maxItems": 1,
"minItems": 1,
"items": {
"type": "object",
"required": [
@@ -139,6 +145,8 @@ Feature: Send a sharing invitations
},
"roles": {
"type": "array",
"maxItems": 1,
"minItems": 1,
"items": {
"type": "string",
"pattern": "^%role_id_pattern%$"
@@ -205,6 +213,8 @@ Feature: Send a sharing invitations
"properties": {
"value": {
"type": "array",
"maxItems": 1,
"minItems": 1,
"items": {
"type": "object",
"required": [
@@ -219,6 +229,8 @@ Feature: Send a sharing invitations
},
"@libre.graph.permissions.actions": {
"type": "array",
"maxItems": 1,
"minItems": 1,
"items": {
"type": "string",
"pattern": "^libre\\.graph\\/driveItem\\/<permissionsAction>$"
@@ -296,6 +308,8 @@ Feature: Send a sharing invitations
"properties": {
"value": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
@@ -310,6 +324,8 @@ Feature: Send a sharing invitations
},
"@libre.graph.permissions.actions": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "string",
"pattern": "^libre\\.graph\\/driveItem\\/<permissionsAction>$"
@@ -396,6 +412,8 @@ Feature: Send a sharing invitations
"properties": {
"value": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
@@ -410,6 +428,8 @@ Feature: Send a sharing invitations
},
"@libre.graph.permissions.actions": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "string",
"pattern": "^libre\\.graph\\/driveItem\\/<permissionsAction>$"
@@ -493,6 +513,8 @@ Feature: Send a sharing invitations
"properties": {
"value": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
@@ -507,6 +529,8 @@ Feature: Send a sharing invitations
},
"@libre.graph.permissions.actions": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "string",
"pattern": "^libre\\.graph\\/driveItem\\/<permissionsAction>$"
@@ -589,6 +613,8 @@ Feature: Send a sharing invitations
"properties": {
"value": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
@@ -604,6 +630,8 @@ Feature: Send a sharing invitations
},
"roles": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "string",
"pattern": "^%role_id_pattern%$"
@@ -684,6 +712,8 @@ Feature: Send a sharing invitations
"properties": {
"value": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
@@ -699,6 +729,8 @@ Feature: Send a sharing invitations
},
"roles": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "string",
"pattern": "^%role_id_pattern%$"
@@ -773,6 +805,8 @@ Feature: Send a sharing invitations
"properties": {
"value": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
@@ -787,6 +821,8 @@ Feature: Send a sharing invitations
},
"roles": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "string",
"pattern": "^%role_id_pattern%$"
@@ -1637,6 +1673,8 @@ Feature: Send a sharing invitations
"properties": {
"value": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
@@ -1673,6 +1711,8 @@ Feature: Send a sharing invitations
},
"roles": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "string",
"pattern": "^%role_id_pattern%$"
@@ -1813,6 +1853,8 @@ Feature: Send a sharing invitations
"properties": {
"value": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
@@ -1849,6 +1891,8 @@ Feature: Send a sharing invitations
},
"roles": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "string",
"pattern": "^%role_id_pattern%$"
@@ -2092,6 +2136,8 @@ Feature: Send a sharing invitations
"properties": {
"value": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
@@ -2128,6 +2174,8 @@ Feature: Send a sharing invitations
},
"roles": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "string",
"pattern": "^%role_id_pattern%$"
@@ -2181,6 +2229,8 @@ Feature: Send a sharing invitations
"properties": {
"value": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
@@ -2195,6 +2245,8 @@ Feature: Send a sharing invitations
},
"roles": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "string",
"pattern": "^%role_id_pattern%$"
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -71,12 +71,12 @@ Feature: Update permission of a share
},
"roles": {
"type": "array",
"items": [
{
"type": "string",
"pattern": "^%role_id_pattern%$"
}
]
"minItems": 1,
"maxItems": 1,
"items": {
"type": "string",
"pattern": "^%role_id_pattern%$"
}
}
}
}
@@ -141,12 +141,12 @@ Feature: Update permission of a share
},
"roles": {
"type": "array",
"items": [
{
"type": "string",
"pattern": "^%role_id_pattern%$"
}
]
"minItems": 1,
"maxItems": 1,
"items": {
"type": "string",
"pattern": "^%role_id_pattern%$"
}
}
}
}
@@ -212,12 +212,12 @@ Feature: Update permission of a share
},
"roles": {
"type": "array",
"items": [
{
"type": "string",
"pattern": "^%role_id_pattern%$"
}
]
"minItems": 1,
"maxItems": 1,
"items": {
"type": "string",
"pattern": "^%role_id_pattern%$"
}
}
}
}
@@ -167,61 +167,61 @@ Feature: Change data of space
},
"special": {
"type": "array",
"items": [
{
"type": "object",
"required": [
"size",
"name",
"specialFolder",
"file",
"id",
"eTag"
],
"properties": {
"size": {
"type": "number",
"enum": [17]
},
"name": {
"type": "string",
"enum": ["readme.md"]
},
"specialFolder": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string",
"enum": ["readme"]
}
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
"size",
"name",
"specialFolder",
"file",
"id",
"eTag"
],
"properties": {
"size": {
"type": "number",
"enum": [17]
},
"name": {
"type": "string",
"enum": ["readme.md"]
},
"specialFolder": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string",
"enum": ["readme"]
}
},
"file": {
"type": "object",
"required": [
"mimeType"
],
"properties": {
"mimeType": {
"type": "string",
"enum": ["text/markdown"]
}
}
},
"id": {
"type": "string",
"enum": ["%file_id%"]
},
"tag": {
"type": "string",
"enum": ["%eTag%"]
}
},
"file": {
"type": "object",
"required": [
"mimeType"
],
"properties": {
"mimeType": {
"type": "string",
"enum": ["text/markdown"]
}
}
},
"id": {
"type": "string",
"enum": ["%file_id%"]
},
"tag": {
"type": "string",
"enum": ["%eTag%"]
}
}
]
}
}
}
}
@@ -262,61 +262,61 @@ Feature: Change data of space
},
"special": {
"type": "array",
"items": [
{
"type": "object",
"required": [
"size",
"name",
"specialFolder",
"file",
"id",
"eTag"
],
"properties": {
"size": {
"type": "number",
"enum": [0]
},
"name": {
"type": "string",
"enum": ["<nameInResponse>"]
},
"specialFolder": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string",
"enum": ["image"]
}
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
"size",
"name",
"specialFolder",
"file",
"id",
"eTag"
],
"properties": {
"size": {
"type": "number",
"enum": [0]
},
"name": {
"type": "string",
"enum": ["<nameInResponse>"]
},
"specialFolder": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string",
"enum": ["image"]
}
},
"file": {
"type": "object",
"required": [
"mimeType"
],
"properties": {
"mimeType": {
"type": "string",
"enum": ["<mimeType>"]
}
}
},
"id": {
"type": "string",
"enum": ["%file_id%"]
},
"tag": {
"type": "string",
"enum": ["%eTag%"]
}
},
"file": {
"type": "object",
"required": [
"mimeType"
],
"properties": {
"mimeType": {
"type": "string",
"enum": ["<mimeType>"]
}
}
},
"id": {
"type": "string",
"enum": ["%file_id%"]
},
"tag": {
"type": "string",
"enum": ["%eTag%"]
}
}
]
}
}
}
}
@@ -359,61 +359,61 @@ Feature: Change data of space
},
"special": {
"type": "array",
"items": [
{
"type": "object",
"required": [
"size",
"name",
"specialFolder",
"file",
"id",
"eTag"
],
"properties": {
"size": {
"type": "number",
"enum": [<expectedSize>]
},
"name": {
"type": "string",
"enum": ["readme.md"]
},
"specialFolder": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string",
"enum": ["readme"]
}
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
"size",
"name",
"specialFolder",
"file",
"id",
"eTag"
],
"properties": {
"size": {
"type": "number",
"enum": [<expectedSize>]
},
"name": {
"type": "string",
"enum": ["readme.md"]
},
"specialFolder": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string",
"enum": ["readme"]
}
},
"file": {
"type": "object",
"required": [
"mimeType"
],
"properties": {
"mimeType": {
"type": "string",
"enum": ["text/markdown"]
}
}
},
"id": {
"type": "string",
"enum": ["%file_id%"]
},
"tag": {
"type": "string",
"enum": ["%eTag%"]
}
},
"file": {
"type": "object",
"required": [
"mimeType"
],
"properties": {
"mimeType": {
"type": "string",
"enum": ["text/markdown"]
}
}
},
"id": {
"type": "string",
"enum": ["%file_id%"]
},
"tag": {
"type": "string",
"enum": ["%eTag%"]
}
}
]
}
}
}
}
@@ -447,61 +447,61 @@ Feature: Change data of space
},
"special": {
"type": "array",
"items": [
{
"type": "object",
"required": [
"size",
"name",
"specialFolder",
"file",
"id",
"eTag"
],
"properties": {
"size": {
"type": "number",
"enum": [0]
},
"name": {
"type": "string",
"enum": ["newSpaceImage.png"]
},
"specialFolder": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string",
"enum": ["image"]
}
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
"size",
"name",
"specialFolder",
"file",
"id",
"eTag"
],
"properties": {
"size": {
"type": "number",
"enum": [0]
},
"name": {
"type": "string",
"enum": ["newSpaceImage.png"]
},
"specialFolder": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string",
"enum": ["image"]
}
},
"file": {
"type": "object",
"required": [
"mimeType"
],
"properties": {
"mimeType": {
"type": "string",
"enum": ["image/png"]
}
}
},
"id": {
"type": "string",
"enum": ["%file_id%"]
},
"tag": {
"type": "string",
"enum": ["%eTag%"]
}
},
"file": {
"type": "object",
"required": [
"mimeType"
],
"properties": {
"mimeType": {
"type": "string",
"enum": ["image/png"]
}
}
},
"id": {
"type": "string",
"enum": ["%file_id%"]
},
"tag": {
"type": "string",
"enum": ["%eTag%"]
}
}
]
}
}
}
}
@@ -24,7 +24,6 @@
use Behat\Behat\Hook\Scope\BeforeStepScope;
use GuzzleHttp\Exception\GuzzleException;
use Helmich\JsonAssert\JsonAssertions;
use rdx\behatvars\BehatVariablesContext;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Behat\Hook\Scope\AfterScenarioScope;
@@ -35,6 +34,7 @@ use Behat\Testwork\Hook\Scope\AfterSuiteScope;
use GuzzleHttp\Cookie\CookieJar;
use Psr\Http\Message\ResponseInterface;
use PHPUnit\Framework\Assert;
use Swaggest\JsonSchema\Schema as JsonSchema;
use TestHelpers\AppConfigHelper;
use TestHelpers\OcsApiHelper;
use TestHelpers\SetupHelper;
@@ -55,7 +55,6 @@ class FeatureContext extends BehatVariablesContext {
use Provisioning;
use Sharing;
use WebDav;
use JsonAssertions;
/**
* Unix timestamp seconds
@@ -1207,6 +1206,117 @@ class FeatureContext extends BehatVariablesContext {
return $a;
}
/**
* Validates against the requirements that array schema should adhere to
*
* @param JsonSchema $schemaObj
*
* @return void
* @throws Exception
*/
private function validateSchemaArrayEntries(JsonSchema $schemaObj): void {
$hasTwoElementValidator = ($schemaObj->enum && $schemaObj->const) || ($schemaObj->enum && $schemaObj->items) || ($schemaObj->const && $schemaObj->items);
Assert::assertFalse($hasTwoElementValidator, "'items', 'enum' and 'const' should not be used together");
if ($schemaObj->enum || $schemaObj->const) {
// do not try to validate of enum or const is present
return;
}
$requiredValidators = ["maxItems", "minItems"];
$optionalValidators = ["items", "uniqueItems"];
$errMsg = "'%s' is required for array assertion";
// validate required keywords
foreach ($requiredValidators as $validator) {
Assert::assertNotNull($schemaObj->$validator, \sprintf($errMsg, $validator));
}
Assert::assertEquals($schemaObj->minItems, $schemaObj->maxItems, "'minItems' and 'maxItems' should be equal for strict assertion");
// validate optional keywords
foreach ($optionalValidators as $validator) {
$value = $schemaObj->$validator;
switch ($validator) {
case 'items':
if ($schemaObj->maxItems === 0) {
break;
}
Assert::assertNotNull($schemaObj->$validator, \sprintf($errMsg, $validator));
if ($schemaObj->maxItems > 1) {
if (\is_array($value)) {
foreach ($value as $element) {
Assert::assertNotNull($element->oneOf, "'oneOf' is required to assert more than one elements");
}
Assert::fail("'$validator' should be an object not an array");
break;
}
Assert::assertFalse($value->allOf || $value->anyOf, "'allOf' and 'anyOf' are not allowed in array");
Assert::assertNotNull($value->oneOf, "'oneOf' is required to assert more than one elements");
Assert::assertTrue(\is_array($value->oneOf), "'oneOf' should be an array");
Assert::assertEquals($schemaObj->maxItems, \count($value->oneOf), "There are more 'oneOf' elements than expected by 'maxItems'");
}
Assert::assertTrue(\is_object($value), "'$validator' should be an object when expecting 1 element");
break;
case "uniqueItems":
if ($schemaObj->minItems > 1) {
$errMsg = $value === null ? \sprintf($errMsg, $validator) : "'$validator' should be true";
Assert::assertTrue($value, $errMsg);
}
break;
default:
break;
}
}
}
/**
* Validates the json schema requirements
*
* @param JsonSchema $schema
*
* @return void
* @throws Exception
*/
public function validateSchemaRequirements(JsonSchema $schema): void {
$propNames = $schema->getPropertyNames();
$props = $schema->getProperties();
foreach ($propNames as $propName) {
switch ($props->$propName->type) {
case 'array':
$this->validateSchemaArrayEntries($props->$propName);
$items = $props->$propName->items;
if ($items && $items->oneOf) {
foreach ($items->oneOf as $oneOfItem) {
$this->validateSchemaRequirements($oneOfItem);
}
break;
} elseif ($items) {
$this->validateSchemaRequirements($items);
}
break;
default:
break;
}
// traverse for nested properties
if ($props->$propName->getProperties()) {
$this->validateSchemaRequirements($props->$propName);
}
}
}
/**
* @param object $json
* @param object $schema
*
* @return void
* @throws Exception
*/
public function assertJsonDocumentMatchesSchema(object $json, object $schema): void {
$schema = JsonSchema::import($schema);
$this->validateSchemaRequirements($schema);
$schema->in($json);
}
/**
* @When /^user "([^"]*)" sends HTTP method "([^"]*)" to URL "([^"]*)"$/
*
@@ -1445,13 +1555,12 @@ class FeatureContext extends BehatVariablesContext {
* @Then the JSON data of the response should match
*
* @param PyStringNode $schemaString
* @param ResponseInterface|null $response
*
* @return void
* @throws Exception
*/
public function theDataOfTheResponseShouldMatch(PyStringNode $schemaString, ResponseInterface $response=null): void {
$responseBody = $this->getJsonDecodedResponseBodyContent($response);
public function theJsonDataOfTheResponseShouldMatch(PyStringNode $schemaString): void {
$responseBody = $this->getJsonDecodedResponseBodyContent();
$this->assertJsonDocumentMatchesSchema(
$responseBody,
$this->getJSONSchema($schemaString)
@@ -206,7 +206,11 @@ class GraphContext implements Context {
*/
public function theUserInformationShouldMatchTheJSON(string $user, PyStringNode $schemaString): void {
$response = $this->adminHasRetrievedUserUsingTheGraphApi($user);
$this->featureContext->theDataOfTheResponseShouldMatch($schemaString, $response);
$responseBody = $this->featureContext->getJsonDecodedResponseBodyContent($response);
$this->featureContext->assertJsonDocumentMatchesSchema(
$responseBody,
$this->featureContext->getJSONSchema($schemaString)
);
}
/**
@@ -198,6 +198,7 @@ Feature: capabilities
"blacklisted_files": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "string",
"enum": [".htaccess"]