Skip to content

Commit ad2aaa3

Browse files
committed
test(integration): add test for importing a group with a name >= 64
characters Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
1 parent f784dbc commit ad2aaa3

3 files changed

Lines changed: 36 additions & 7 deletions

File tree

.github/workflows/integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
MYSQL_ROOT_PASSWORD: rootpassword
8383
options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5
8484
directory:
85-
image: ghcr.io/nextcloud/continuous-integration-user_saml-dirsrv:latest # zizmor: ignore[unpinned-images]
85+
image: ghcr.io/nextcloud/continuous-integration-user_saml-dirsrv:2
8686
ports:
8787
- 389:3389/tcp
8888
options:

tests/integration/features/Shibboleth.feature

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,22 @@ Feature: Shibboleth
8787
And the group "SAML_Students" should exists
8888
And The last login timestamp of "student1" should not be empty
8989

90+
Scenario: Authenticating using Shibboleth with SAML in provisioning mode and an overlong group name
91+
Given The setting "saml-attribute-mapping-displayName_mapping" is set to "urn:oid:2.5.4.42 urn:oid:2.5.4.4"
92+
And The setting "saml-attribute-mapping-group_mapping" is set to "groups"
93+
When I send a GET request to "http://localhost:8080/index.php/login"
94+
Then I should be redirected to "https://localhost:4443/idp/profile/SAML2/Redirect/SSO"
95+
And I send a POST request to "https://localhost:4443/idp/profile/SAML2/Redirect/SSO?execution=e1s1" with the following data
96+
|j_username|j_password|_eventId_proceed|
97+
|student3 |password | |
98+
And The response should be a SAML redirect page that gets submitted
99+
And I should be redirected to "http://localhost:8080/index.php/apps/dashboard/"
100+
And The user value "id" should be "student3"
101+
And The user value "display-name" should be "Alice Alisson"
102+
And The user value "groups" should be "SAML_a8c9502da8297f759c8d3ad26860efa9527d83e17130901d,SAML_Students"
103+
And the group "SAML_a8c9502da8297f759c8d3ad26860efa9527d83e17130901d" should exists
104+
And the group "SAML_a8c9502da8297f759c8d3ad26860efa9527d83e17130901d" has the display name "AGroupNameContainingMoreThan64CharactersRepeatAGroupNameContainingMoreThan64Characters"
105+
90106
Scenario: Authenticating using Shibboleth with SAML with custom redirect URL
91107
Given The setting "saml-attribute-mapping-email_mapping" is set to "urn:oid:0.9.2342.19200300.100.1.3"
92108
And The setting "saml-attribute-mapping-displayName_mapping" is set to "urn:oid:2.5.4.42 urn:oid:2.5.4.4"

tests/integration/features/bootstrap/FeatureContext.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -597,19 +597,32 @@ public function theEnvironmentVariableIsSetTo($key, $value) {
597597
* @Given /^the group "([^"]*)" should exists$/
598598
*/
599599
public function theGroupShouldExists(string $gid): void {
600-
$response = shell_exec(
600+
$groupInfo = $this->fetchGroupInfo($gid);
601+
if (!isset($groupInfo['groupID']) || $groupInfo['groupID'] !== $gid) {
602+
throw new UnexpectedValueException('Group does not exist');
603+
}
604+
}
605+
606+
/**
607+
* @Then the group :gid has the display name :expectedDisplayName
608+
*/
609+
public function theGroupHasTheDisplayName(string $gid, string $expectedDisplayName): void {
610+
$groupInfo = $this->fetchGroupInfo($gid);
611+
if (!isset($groupInfo['displayName']) || $groupInfo['displayName'] !== $expectedDisplayName) {
612+
throw new UnexpectedValueException('The group`s display name does not match');
613+
}
614+
}
615+
616+
protected function fetchGroupInfo(string $gid): ?array {
617+
$groupInfoOutput = shell_exec(
601618
sprintf(
602619
'%s %s group:info --output=json "%s"',
603620
PHP_BINARY,
604621
__DIR__ . '/../../../../../../occ',
605622
$gid
606623
)
607624
);
608-
609-
$responseArray = json_decode($response, true);
610-
if (!isset($responseArray['groupID']) || $responseArray['groupID'] !== $gid) {
611-
throw new UnexpectedValueException('Group does not exist');
612-
}
625+
return json_decode($groupInfoOutput, true);
613626
}
614627

615628
/**

0 commit comments

Comments
 (0)