diff --git a/scm-ui/e2e-tests/cypress/integration/anonymous_mode_disabled.feature b/scm-ui/e2e-tests/cypress/integration/anonymous_mode_disabled.feature deleted file mode 100644 index cdd3bfcb17..0000000000 --- a/scm-ui/e2e-tests/cypress/integration/anonymous_mode_disabled.feature +++ /dev/null @@ -1,38 +0,0 @@ -# -# MIT License -# -# Copyright (c) 2020-present Cloudogu GmbH and Contributors -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -Feature: Anonymous Mode Disabled - - Background: - Given Anonymous Mode is disabled - - Scenario: There is no primary navigation - Given User is not authenticated - When User visits any page - Then There is no primary navigation - - Scenario: Authenticated users have a footer navigation - Given User is authenticated - When User visits any page - Then There is a footer navigation diff --git a/scm-ui/e2e-tests/cypress/support/step_definitions/scm-manager.js b/scm-ui/e2e-tests/cypress/integration/anonymous_mode_disabled_spec.ts similarity index 65% rename from scm-ui/e2e-tests/cypress/support/step_definitions/scm-manager.js rename to scm-ui/e2e-tests/cypress/integration/anonymous_mode_disabled_spec.ts index d57cc6938c..ca17830980 100644 --- a/scm-ui/e2e-tests/cypress/support/step_definitions/scm-manager.js +++ b/scm-ui/e2e-tests/cypress/integration/anonymous_mode_disabled_spec.ts @@ -22,16 +22,32 @@ * SOFTWARE. */ -When("User visits repository", function() { - cy.visit(`/repo/${this.repository.namespace}/${this.repository.name}/code/sources`); -}); +import { hri } from "human-readable-ids"; -When("User performs file search inside repository", function() { - cy.byTestId("file_search_button").click(); - cy.url().should("include", `/repo/${this.repository.namespace}/${this.repository.name}/code/search/main?q=`); - cy.get("[data-testid=file_search_filter_input]").type("README"); -}); +describe("Anonymous Mode Disabled", () => { + beforeEach(() => { + cy.restSetAnonymousMode("OFF"); + }); -Then("The search results are found", function() { - cy.get("[data-testid=file_search_single_result]").contains("README.md"); + it("should show login page when not authenticated", () => { + // Act + cy.visit("/repos/"); + + // Assert + cy.byTestId("login-button"); + }); + + it("should show footer for authenticated user", () => { + // Arrange + const username = hri.random(); + const password = hri.random(); + cy.restCreateUser(username, password); + cy.restLogin(username, password); + + // Act + cy.visit("/home"); + + // Assert + cy.byTestId("footer-user-profile"); + }); }); diff --git a/scm-ui/e2e-tests/cypress/integration/anonymous_mode_full.feature b/scm-ui/e2e-tests/cypress/integration/anonymous_mode_full.feature deleted file mode 100644 index 71c80c0de0..0000000000 --- a/scm-ui/e2e-tests/cypress/integration/anonymous_mode_full.feature +++ /dev/null @@ -1,51 +0,0 @@ -# -# MIT License -# -# Copyright (c) 2020-present Cloudogu GmbH and Contributors -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -Feature: Anonymous Mode Full - - Background: - Given Full Anonymous Mode is enabled - And User is not authenticated - - Scenario: Show login button on anonymous route - Given Anonymous user has permission to read all repositories - When User visits the repository overview page - Then The repository overview page is shown - And There is a login button - - Scenario: Show login page - When User visits login page - Then The login page is shown - - Scenario: Navigate to login page - When Users clicks login button - Then The login page is shown - - Scenario: Redirect to repositories overview after login - When User logs in - Then User should be authenticated - - Scenario: Anonymous user cannot change password - When User visits their user settings - Then There is no option to change the password diff --git a/scm-ui/e2e-tests/cypress/integration/anonymous_mode_full_spec.ts b/scm-ui/e2e-tests/cypress/integration/anonymous_mode_full_spec.ts new file mode 100644 index 0000000000..1260aa4f0a --- /dev/null +++ b/scm-ui/e2e-tests/cypress/integration/anonymous_mode_full_spec.ts @@ -0,0 +1,76 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import { hri } from "human-readable-ids"; + +describe("Anonymous Mode Full", () => { + beforeEach(() => { + cy.restSetAnonymousMode("FULL"); + }); + + it("should show login button on anonymous route", () => { + // Arrange + cy.restSetUserPermissions("_anonymous", ["repository:read,pull:*"]); + // Act + cy.visit("/repos/"); + // Assert + cy.byTestId("repository-overview-filter"); + cy.byTestId("primary-navigation-login"); + }); + + it("should show login page", () => { + // Act + cy.visit("/login/"); + // Assert + cy.byTestId("login-button"); + }); + + it("should navigate to login page", () => { + // Act + cy.byTestId("login-button").click(); + // Assert + cy.byTestId("login-button"); + }); + + it("should redirect to repositories overview after login", () => { + // Arrange + const username = hri.random(); + const password = hri.random(); + cy.restCreateUser(username, password); + + // Act + cy.login(username, password); + + // Assert + cy.byTestId(username); + }); + + it("should not allow anonymous user to change password", () => { + // Act + cy.visit("/me/settings/"); + // Assert + cy.containsNotByTestId("ul", "user-settings-link"); + cy.get("section").not("Change password"); + }); +}); diff --git a/scm-ui/e2e-tests/cypress/integration/anonymous_mode_protocol_only.feature b/scm-ui/e2e-tests/cypress/integration/anonymous_mode_protocol_only.feature deleted file mode 100644 index 8fb27f0095..0000000000 --- a/scm-ui/e2e-tests/cypress/integration/anonymous_mode_protocol_only.feature +++ /dev/null @@ -1,32 +0,0 @@ -# -# MIT License -# -# Copyright (c) 2020-present Cloudogu GmbH and Contributors -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -Feature: Anonymous Mode with Protocol Only - Background: - Given Protocol Only Anonymous Mode is enabled - - Scenario: There is no primary navigation - Given User is not authenticated - When User visits the repository overview page - Then The login page is shown diff --git a/scm-ui/e2e-tests/cypress/integration/anonymous_mode_protocol_only_spec.ts b/scm-ui/e2e-tests/cypress/integration/anonymous_mode_protocol_only_spec.ts new file mode 100644 index 0000000000..d16693e566 --- /dev/null +++ b/scm-ui/e2e-tests/cypress/integration/anonymous_mode_protocol_only_spec.ts @@ -0,0 +1,61 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +describe("Anonymous Mode with Protocol Only", () => { + beforeEach(() => { + cy.restSetAnonymousMode("PROTOCOL_ONLY"); + }); + + it("should show login page when not authenticated", () => { + // Act + cy.visit("/repos/"); + + // Assert + cy.byTestId("login-button"); + }); +}); diff --git a/scm-ui/e2e-tests/cypress/integration/repository_code_filesearch.feature b/scm-ui/e2e-tests/cypress/integration/repository_code_filesearch.feature deleted file mode 100644 index 5e42d94ec2..0000000000 --- a/scm-ui/e2e-tests/cypress/integration/repository_code_filesearch.feature +++ /dev/null @@ -1,35 +0,0 @@ -# -# MIT License -# -# Copyright (c) 2020-present Cloudogu GmbH and Contributors -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -Feature: Repository File Search - - Background: - Given User is authenticated - And A git repository exists - - Scenario: Search file inside repository - Given User has permission to read and write repository - When User visits repository - And User performs file search inside repository - Then The search results are found diff --git a/scm-ui/e2e-tests/cypress/support/step_definitions/index.js b/scm-ui/e2e-tests/cypress/integration/repository_code_filesearch_spec.ts similarity index 53% rename from scm-ui/e2e-tests/cypress/support/step_definitions/index.js rename to scm-ui/e2e-tests/cypress/integration/repository_code_filesearch_spec.ts index 1a7c718dc0..a4cc43c60d 100644 --- a/scm-ui/e2e-tests/cypress/support/step_definitions/index.js +++ b/scm-ui/e2e-tests/cypress/integration/repository_code_filesearch_spec.ts @@ -22,4 +22,38 @@ * SOFTWARE. */ -export * from "@scm-manager/integration-test-runner/steps"; +import { hri } from "human-readable-ids"; + +describe("Repository File Search", () => { + let username: string; + let password: string; + let namespace: string; + let name: string; + + beforeEach(() => { + // Create user and login + username = hri.random(); + password = hri.random(); + cy.restCreateUser(username, password); + cy.restLogin(username, password); + + // Create repo + namespace = hri.random(); + name = hri.random(); + cy.restCreateRepo("git", namespace, name, true); + }); + + it("should search file inside repository", () => { + // Arrange + cy.restSetUserRepositoryRole(username, namespace, name, "WRITE"); + + // Act + cy.visit(`/repo/${namespace}/${name}/code/sources`); + cy.byTestId("file_search_button").click(); + cy.url().should("include", `/repo/${namespace}/${name}/code/search/main?q=`); + cy.byTestId("file_search_filter_input").type("README"); + + // Assert + cy.byTestId("file_search_single_result").contains("README.md"); + }); +}); diff --git a/scm-ui/e2e-tests/cypress/plugins/index.js b/scm-ui/e2e-tests/cypress/plugins/index.ts similarity index 88% rename from scm-ui/e2e-tests/cypress/plugins/index.js rename to scm-ui/e2e-tests/cypress/plugins/index.ts index f9d4a4d5e3..1983b3b209 100644 --- a/scm-ui/e2e-tests/cypress/plugins/index.js +++ b/scm-ui/e2e-tests/cypress/plugins/index.ts @@ -22,4 +22,6 @@ * SOFTWARE. */ -module.exports = require("@scm-manager/integration-test-runner/plugins"); +// This file was generated, please DO NOT EDIT THIS FILE! +import register from "@scm-manager/integration-test-runner/plugins"; +export default register; diff --git a/scm-ui/e2e-tests/cypress/support/commands/index.js b/scm-ui/e2e-tests/cypress/support/commands/index.ts similarity index 100% rename from scm-ui/e2e-tests/cypress/support/commands/index.js rename to scm-ui/e2e-tests/cypress/support/commands/index.ts diff --git a/scm-ui/e2e-tests/cypress/support/index.js b/scm-ui/e2e-tests/cypress/support/index.ts similarity index 95% rename from scm-ui/e2e-tests/cypress/support/index.js rename to scm-ui/e2e-tests/cypress/support/index.ts index 747fcb781e..201e67c639 100644 --- a/scm-ui/e2e-tests/cypress/support/index.js +++ b/scm-ui/e2e-tests/cypress/support/index.ts @@ -21,5 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ + +// This file was generated, please DO NOT EDIT THIS FILE import "@scm-manager/integration-test-runner/commands"; import "./commands"; diff --git a/scm-ui/e2e-tests/cypress/tsconfig.json b/scm-ui/e2e-tests/cypress/tsconfig.json new file mode 100644 index 0000000000..cb2a4d9fe4 --- /dev/null +++ b/scm-ui/e2e-tests/cypress/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "noEmit": true, + "target": "es5", + "lib": ["es5", "dom"], + "types": ["cypress"] + }, + "include": ["**/*.ts"] +} \ No newline at end of file diff --git a/scm-ui/e2e-tests/package.json b/scm-ui/e2e-tests/package.json index cc52f06638..da7ddbd658 100644 --- a/scm-ui/e2e-tests/package.json +++ b/scm-ui/e2e-tests/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@ffmpeg-installer/ffmpeg": "^1.0.20", - "@scm-manager/integration-test-runner": "^1.3.7", + "@scm-manager/integration-test-runner": "^3.0.0", "fluent-ffmpeg": "^2.1.2" }, "prettier": "@scm-manager/prettier-config",