Skip to content

Commit

Permalink
Merge pull request #9597 from owncloud/listInvitationTest
Browse files Browse the repository at this point in the history
[test-only] list Invitation
  • Loading branch information
ScharfViktor authored Jul 15, 2024
2 parents ce199d5 + 1b8b911 commit 8e9ccf0
Show file tree
Hide file tree
Showing 8 changed files with 316 additions and 53 deletions.
4 changes: 2 additions & 2 deletions docs/ocis/development/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ OCM_OCM_INVITE_MANAGER_INSECURE=true \
OCM_OCM_SHARE_PROVIDER_INSECURE=true \
OCM_OCM_STORAGE_PROVIDER_INSECURE=true \
OCM_OCM_PROVIDER_AUTHORIZER_PROVIDERS_FILE="${workspaceFolder}/tests/config/drone/providers.json" \
OCIS_ADD_RUN_SERVICES="ocm"
OCIS_ADD_RUN_SERVICES="ocm" \
ocis/bin/ocis server
```

Expand All @@ -587,7 +587,7 @@ To enable ocm in the web interface, you need to set the following envs:
`FRONTEND_OCS_INCLUDE_OCM_SHAREES=true` \
`FRONTEND_OCS_LIST_OCM_SHARES=true` \
`FRONTEND_ENABLE_FEDERATED_SHARING_INCOMING=true` \
`FRONTEND_ENABLE_FEDERATED_SHARING_OUTGOING=true`
`FRONTEND_ENABLE_FEDERATED_SHARING_OUTGOING=true` \

and put `ocm` to apps https://github.com/owncloud/ocis/blob/master/services/web/pkg/config/defaults/defaultconfig.go#L101
{{< /hint>}}
Expand Down
26 changes: 25 additions & 1 deletion tests/TestHelpers/OcmHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace TestHelpers;

use GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

/**
Expand Down Expand Up @@ -132,4 +131,29 @@ public static function findAcceptedUsers(
self::getRequestHeaders()
);
}

/**
* @param string $baseUrl
* @param string $xRequestId
* @param string $user
* @param string $password
*
* @return ResponseInterface
* @throws GuzzleException
*/
public static function listInvite(
string $baseUrl,
string $xRequestId,
string $user,
string $password
): ResponseInterface {
$url = self::getFullUrl($baseUrl, 'list-invite');
return HttpRequestHelper::get(
$url,
$xRequestId,
$user,
$password,
self::getRequestHeaders()
);
}
}
1 change: 1 addition & 0 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ default:
- OcmContext:
- SharingNgContext:
- SpacesContext:
- OcisConfigContext:

cliCommands:
paths:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,5 +312,8 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiOcm/share.feature:12](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/share.feature#L12)
- [apiOcm/share.feature:91](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/share.feature#L91)

### [OCM. user cannot see invite description and inviteUser email](https://github.com/owncloud/ocis/issues/9591)

- [apiOcm/createInvitation.feature:63](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/createInvitation.feature#L63)
- Note: always have an empty line at the end of this file.
The bash script that processes this file requires that the last line has a newline on the end.
99 changes: 55 additions & 44 deletions tests/acceptance/features/apiOcm/acceptInvitation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,57 +14,15 @@ Feature: accepting invitation

Scenario: user accepts invitation
Given using server "LOCAL"
When "Alice" creates the federation share invitation
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"expiration",
"token"
],
"properties": {
"expiration": {
"type": "integer",
"pattern": "^[0-9]{10}$"
},
"token": {
"type": "string",
"pattern": "^%fed_invitation_token_pattern%$"
}
}
}
"""
And "Alice" has created the federation share invitation
When using server "REMOTE"
And "Brian" accepts the last federation share invitation
Then the HTTP status code should be "200"


Scenario: user accepts invitation sent with email and description
Given using server "LOCAL"
When "Alice" creates the federation share invitation with email "[email protected]" and description "a share invitation from Alice"
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"expiration",
"token"
],
"properties": {
"expiration": {
"type": "integer",
"pattern": "^[0-9]{10}$"
},
"token": {
"type": "string",
"pattern": "^%fed_invitation_token_pattern%$"
}
}
}
"""
And "Alice" has created the federation share invitation with email "[email protected]" and description "a share invitation from Alice"
When using server "REMOTE"
And "Brian" accepts the last federation share invitation
Then the HTTP status code should be "200"
Expand Down Expand Up @@ -135,3 +93,56 @@ Feature: accepting invitation
}
}
"""

@env-config
Scenario: user cannot accept expired invitation tokens
Given using server "LOCAL"
And the config "OCM_OCM_INVITE_MANAGER_TOKEN_EXPIRATION" has been set to "1s"
And "Alice" has created the federation share invitation
When using server "REMOTE"
And the user waits "2" seconds for the token to expire
And "Brian" tries to accept the last federation share invitation
Then the HTTP status code should be "400"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"code",
"message"
],
"properties": {
"code": {
"const": "INVALID_PARAMETER"
},
"message": {
"const": "token has expired"
}
}
}
"""


Scenario: user cannot accept invalid invitation token
Given using server "LOCAL"
And "Alice" tries to accept the invitation with invalid token
Then the HTTP status code should be "404"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"code",
"message"
],
"properties": {
"code": {
"const": "RESOURCE_NOT_FOUND"
},
"message": {
"const": "token not found"
}
}
}
"""

168 changes: 168 additions & 0 deletions tests/acceptance/features/apiOcm/createInvitation.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
@ocm
Feature: create invitation
As a user
I can create an invitations and send it to the person I want to share with

Background:
Given user "Alice" has been created with default attributes and without skeleton files


Scenario: user creates invitation
Given using server "LOCAL"
When "Alice" creates the federation share invitation
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"expiration",
"token"
],
"properties": {
"expiration": {
"type": "integer",
"pattern": "^[0-9]{10}$"
},
"token": {
"type": "string",
"pattern": "^%fed_invitation_token_pattern%$"
}
}
}
"""
When "Alice" lists the created invitations
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
"expiration",
"token"
],
"properties": {
"expiration": {
"type": "integer",
"pattern": "^[0-9]{10}$"
},
"token": {
"type": "string",
"pattern": "^%fed_invitation_token_pattern%$"
}
}
}
}
"""

@issue-9591
Scenario: user creates invitation with email and description
Given using server "LOCAL"
When "Alice" creates the federation share invitation with email "[email protected]" and description "a share invitation from Alice"
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"expiration",
"token",
"description",
"recipient"
],
"properties": {
"expiration": {
"type": "integer",
"pattern": "^[0-9]{10}$"
},
"token": {
"type": "string",
"pattern": "^%fed_invitation_token_pattern%$"
},
"description": {
"type": "string",
"const": "a share invitation from Alice"
},
"recipient": {
"type": "string",
"const": "[email protected]"
}
}
}
"""
And the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"required": [
"expiration",
"token"
],
"properties": {
"expiration": {
"type": "integer",
"pattern": "^[0-9]{10}$"
},
"token": {
"type": "string",
"pattern": "^%fed_invitation_token_pattern%$"
},
"description": {
"type": "string",
"const": "a share invitation from Alice"
},
"recipient": {
"type": "string",
"const": "[email protected]"
}
}
}
}
"""

@env-config
Scenario: user cannot see expired invitation tokens
Given using server "LOCAL"
And the config "OCM_OCM_INVITE_MANAGER_TOKEN_EXPIRATION" has been set to "1s"
When "Alice" creates the federation share invitation
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"expiration",
"token"
],
"properties": {
"expiration": {
"type": "integer",
"pattern": "^[0-9]{10}$"
},
"token": {
"type": "string",
"pattern": "^%fed_invitation_token_pattern%$"
}
}
}
"""
And the user waits "2" seconds for the token to expire
When "Alice" lists the created invitations
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "array",
"minItems": 0,
"maxItems": 0
}
"""
4 changes: 2 additions & 2 deletions tests/acceptance/features/apiOcm/share.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Feature: an user shares resources usin ScienceMesh application
And using server "REMOTE"
And user "Brian" has been created with default attributes and without skeleton files


@issue-9534
Scenario: users shares folder to federation users after receiver accepted invitation
Given using server "LOCAL"
And "Alice" has created the federation share invitation
Expand Down Expand Up @@ -87,7 +87,7 @@ Feature: an user shares resources usin ScienceMesh application
}
"""


@issue-9534
Scenario: users shares folder to federation users after accepting invitation
Given using server "LOCAL"
And "Alice" has created the federation share invitation
Expand Down
Loading

0 comments on commit 8e9ccf0

Please sign in to comment.