Browse Source

feat(tests): Test application enabling/disabling and routes

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/53287/head
Côme Chilliet 5 months ago
parent
commit
a15c473ae2
No known key found for this signature in database GPG Key ID: A3E2F658B28C760A
  1. 1
      .github/workflows/integration-sqlite.yml
  2. 12
      build/integration/config/behat.yml
  3. 18
      build/integration/features/bootstrap/RoutingContext.php
  4. 52
      build/integration/routing_features/apps-and-routes.feature

1
.github/workflows/integration-sqlite.yml

@ -66,6 +66,7 @@ jobs:
- 'openldap_numerical_features'
- 'ldap_features'
- 'remoteapi_features'
- 'routing_features'
- 'setup_features'
- 'sharees_features'
- 'sharing_features'

12
build/integration/config/behat.yml

@ -253,4 +253,14 @@ default:
admin:
- admin
- admin
regular_user_password: 123456
regular_user_password: 123456
routing:
paths:
- "%paths.base%/../routing_features"
contexts:
- RoutingContext:
baseUrl: http://localhost:8080
admin:
- admin
- admin
regular_user_password: 123456

18
build/integration/features/bootstrap/RoutingContext.php

@ -0,0 +1,18 @@
<?php
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
require __DIR__ . '/../../vendor/autoload.php';
class RoutingContext implements Context, SnippetAcceptingContext {
use Provisioning;
use AppConfiguration;
use CommandLine;
protected function resetAppConfigs(): void {
}
}

52
build/integration/routing_features/apps-and-routes.feature

@ -0,0 +1,52 @@
# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
Feature: appmanagement
Background:
Given using api version "2"
And user "user1" exists
And user "user2" exists
And group "group1" exists
And user "user1" belongs to group "group1"
Scenario: Enable app and test route
Given As an "admin"
And sending "DELETE" to "/cloud/apps/weather_status"
And app "weather_status" is disabled
When sending "GET" to "/apps/weather_status/api/v1/location"
Then the OCS status code should be "998"
And the HTTP status code should be "404"
When sending "POST" to "/cloud/apps/weather_status"
Then the OCS status code should be "200"
And the HTTP status code should be "200"
And app "weather_status" is enabled
When sending "GET" to "/apps/weather_status/api/v1/location"
Then the OCS status code should be "200"
And the HTTP status code should be "200"
Given As an "user1"
When sending "GET" to "/apps/weather_status/api/v1/location"
Then the OCS status code should be "200"
And the HTTP status code should be "200"
Given As an "user2"
When sending "GET" to "/apps/weather_status/api/v1/location"
Then the OCS status code should be "200"
And the HTTP status code should be "200"
Scenario: Enable app only for some groups
Given As an "admin"
And sending "DELETE" to "/cloud/apps/weather_status"
And app "weather_status" is disabled
When sending "GET" to "/apps/weather_status/api/v1/location"
Then the OCS status code should be "998"
And the HTTP status code should be "404"
Given invoking occ with "app:enable weather_status --groups group1"
Then the command was successful
Given As an "user2"
When sending "GET" to "/apps/weather_status/api/v1/location"
Then the HTTP status code should be "412"
Given As an "user1"
When sending "GET" to "/apps/weather_status/api/v1/location"
Then the OCS status code should be "200"
And the HTTP status code should be "200"
Given As an "admin"
And sending "DELETE" to "/cloud/apps/weather_status"
And app "weather_status" is disabled
Loading…
Cancel
Save