diff --git a/app/client/cypress/e2e/Regression/ClientSide/FormLogin/EnableFormLogin_spec.js b/app/client/cypress/e2e/Regression/ClientSide/FormLogin/EnableFormLogin_spec.js deleted file mode 100644 index 9cd3c8ff50..0000000000 --- a/app/client/cypress/e2e/Regression/ClientSide/FormLogin/EnableFormLogin_spec.js +++ /dev/null @@ -1,141 +0,0 @@ -import adminSettings from "../../../../locators/AdminsSettings"; -import homePage from "../../../../locators/HomePage"; - -describe("Form Login test functionality", function () { - it( - "1. Go to admin settings and disable Form Signup", - { tags: ["@tag.Authentication", "@tag.Settings"] }, - function () { - cy.LogOut(); - cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD")); - cy.openAuthentication(); - cy.get(adminSettings.formloginButton) - .should("be.visible") - .should("contain", "Edit"); - cy.get(adminSettings.formloginButton).click(); - cy.wait(2000); - // disable form signup - cy.get(adminSettings.formSignupDisabled).should("have.value", "on"); - cy.get(adminSettings.formSignupDisabled).click({ force: true }); - cy.wait(2000); - // assert server is restarting - cy.get(adminSettings.saveButton).should("be.visible"); - cy.get(adminSettings.saveButton).should("not.be.disabled"); - cy.get(adminSettings.saveButton).click(); - cy.waitUntil(() => cy.get(homePage.profileMenu).should("be.visible")); - cy.get(homePage.profileMenu).click(); - cy.get(homePage.signOutIcon).click(); - cy.wait(500); - // validating form signup is disabled - cy.get(".t--sign-up").click({ force: true }); - cy.generateUUID().then((uid) => { - cy.get("[type='email']").type(uid + "@appsmith.com"); - cy.get("[type='password']").type(uid); - cy.get("[type='submit']").click({ force: true }); - cy.get(".ads-v2-callout__children").should( - "contain", - "Signup is restricted on this instance of Appsmith", - ); - // restore setting - cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD")); - cy.get(".admin-settings-menu-option").click(); - cy.get(adminSettings.authenticationTab).click(); - cy.get(adminSettings.formloginButton).click(); - cy.wait(2000); - cy.get(adminSettings.formSignupDisabled).click({ force: true }); - cy.wait(2000); - cy.get(adminSettings.saveButton).click(); - cy.waitUntil(() => cy.get(homePage.profileMenu).should("be.visible")); - cy.get(homePage.profileMenu).click(); - cy.get(homePage.signOutIcon).click(); - }); - cy.wait(500); - // validating form signup is disabled - cy.get(".t--sign-up").click({ force: true }); - cy.generateUUID().then((uid) => { - cy.get("[type='email']").type(uid + "@appsmith.com"); - cy.get("[type='password']").type(uid); - cy.get("[type='submit']").click({ force: true }); - cy.get(".ads-v2-callout__children").should("not.exist"); - }); - }, - ); - - it( - "2. Go to admin settings and disable Form Login", - { tags: ["@tag.excludeForAirgap"] }, - function () { - cy.LogOut(false); - cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD")); - cy.openAuthentication(); - cy.get(adminSettings.formloginButton) - .should("be.visible") - .should("contain", "Edit"); - - // enable github login - cy.get(adminSettings.githubButton).click(); - cy.wait(2000); - // fill github form - cy.fillGithubForm(); - cy.wait(120000); - cy.waitUntil(() => cy.get(homePage.profileMenu).should("be.visible")); - cy.wait(5000); - cy.reload(); - cy.get(adminSettings.authenticationTab).click(); - cy.get(adminSettings.formloginButton).click(); - cy.wait(2000); - // disable form signup - cy.get(adminSettings.formLoginEnabled).should("have.value", "on"); - cy.get(adminSettings.formLoginEnabled).click({ force: true }); - cy.wait(2000); - // assert server is restarting - cy.get(adminSettings.saveButton).should("be.visible"); - cy.get(adminSettings.saveButton).should("not.be.disabled"); - cy.get(adminSettings.saveButton).click(); - cy.waitUntil(() => cy.get(homePage.profileMenu).should("be.visible")); - cy.get(homePage.profileMenu).click(); - cy.get(homePage.signOutIcon).click(); - cy.wait(500); - cy.reload(); - cy.wait(5000); - // validating form signup is disabled - cy.get("form").should("not.exist"); - cy.get(".t--sign-up").should("not.exist"); - // cy.wait(30000); // restart nginx docker - cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD")); - cy.openAuthentication(); - - // enable form login - cy.get(adminSettings.formloginButton) - .should("be.visible") - .should("contain", "Enable"); - cy.get(adminSettings.formloginButton).click(); - cy.get(adminSettings.formLoginEnabled).click({ force: true }); - cy.wait(2000); - // assert server is restarting - cy.get(adminSettings.saveButton).should("be.visible"); - cy.get(adminSettings.saveButton).should("not.be.disabled"); - cy.get(adminSettings.saveButton).click(); - cy.waitUntil(() => cy.get(homePage.profileMenu).should("be.visible")); - cy.reload(); - - // disable github - cy.get(adminSettings.authenticationTab).click(); - cy.get(adminSettings.githubButton).click(); - cy.wait(2000); - cy.get(adminSettings.disconnectBtn) - .click() - .should("contain", "Are you sure?"); - cy.get(adminSettings.disconnectBtn).click(); - cy.wait(120000); - cy.waitUntil(() => cy.get(homePage.profileMenu).should("be.visible")); - cy.reload(); - cy.get(homePage.profileMenu).click(); - cy.get(homePage.signOutIcon).click(); - cy.wait(500); - cy.get(adminSettings.loginWithGithub).should("not.exist"); - cy.get("form").should("exist"); - cy.get(".t--sign-up").should("exist"); - }, - ); -}); diff --git a/app/client/cypress/e2e/Regression/ClientSide/FormLogin/EnableFormLogin_spec.ts b/app/client/cypress/e2e/Regression/ClientSide/FormLogin/EnableFormLogin_spec.ts new file mode 100644 index 0000000000..a0266eb347 --- /dev/null +++ b/app/client/cypress/e2e/Regression/ClientSide/FormLogin/EnableFormLogin_spec.ts @@ -0,0 +1,104 @@ +import adminSettings from "../../../../locators/AdminsSettings"; +import loginPage from "../../../../locators/LoginPage.json"; +import { + agHelper, + adminSettings as objectsCoreAdminSettings, +} from "../../../../support/Objects/ObjectsCore"; + +describe("Form Login test functionality", function () { + it( + "1. Go to admin settings and disable Form Signup", + { tags: ["@tag.Authentication", "@tag.Settings"] }, + function () { + objectsCoreAdminSettings.NavigateToAuthenticationSettings(); + objectsCoreAdminSettings.verifyFormLogin(); + + // disable form signup + objectsCoreAdminSettings.toggleFormSignupLoginAndSave(false, "signup"); + objectsCoreAdminSettings.logoutFromApp(); + + agHelper.GetNClick(loginPage.signupLink); + agHelper.GenerateUUID(); + agHelper.GetElement("@guid").then((uid) => { + const email = uid.toString() + "@appsmith.com"; + const password = uid.toString(); + + agHelper.TypeText("[type='email']", email); + agHelper.TypeText("[type='password']", password); + agHelper.GetNClick("[type='submit']"); + + agHelper.AssertContains( + "Signup is restricted on this instance of Appsmith", + "exist", + ".ads-v2-callout__children", + ); + + // Cleanup: Restore form signup to enabled state + cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD")); + objectsCoreAdminSettings.NavigateToAuthenticationSettings(); + objectsCoreAdminSettings.toggleFormSignupLoginAndSave(true, "signup"); + objectsCoreAdminSettings.logoutFromApp(); + + agHelper.GetNClick(loginPage.signupLink); + agHelper.GenerateUUID(); + agHelper.GetElement("@guid").then((uid) => { + const email = uid.toString() + "@appsmith.com"; + const password = uid.toString(); + + agHelper.TypeText("[type='email']", email); + agHelper.TypeText("[type='password']", password); + agHelper.GetNClick("[type='submit']"); + + agHelper.AssertElementAbsence(".ads-v2-callout__children"); + }); + }); + }, + ); + + it( + "2. Go to admin settings and disable Form Login", + { tags: ["@tag.excludeForAirgap"] }, + function () { + cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD")); + // agHelper.Sleep(10000); + objectsCoreAdminSettings.NavigateToAuthenticationSettings(false); + objectsCoreAdminSettings.verifyFormLogin(); + + // enable github login + agHelper.GetNClick(adminSettings.githubButton); + agHelper.WaitForCondition(() => + agHelper.AssertContains("GitHub authentication", "exist"), + ); + objectsCoreAdminSettings.fillSaveAndAssertGithubForm(); + + // Disable form login + objectsCoreAdminSettings.NavigateToAuthenticationSettings(); + objectsCoreAdminSettings.verifyFormLogin(); + objectsCoreAdminSettings.toggleFormSignupLoginAndSave(false, "login"); + objectsCoreAdminSettings.logoutFromApp(); + + // validate login is disabled + agHelper.AssertElementAbsence(loginPage.loginForm); + agHelper.AssertElementAbsence(loginPage.signupLink); + + // restore settings + cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD")); + + objectsCoreAdminSettings.NavigateToAuthenticationSettings(false); + objectsCoreAdminSettings.toggleFormSignupLoginAndSave(true, "login"); + objectsCoreAdminSettings.NavigateToAuthenticationSettings(true); + agHelper.GetNClick(adminSettings.githubButton); + agHelper.GetNClick(adminSettings.disconnectBtn); + agHelper + .GetElement(adminSettings.disconnectBtn) + .should("contain.text", "Are you sure?"); + agHelper.GetNClick(adminSettings.disconnectBtn); + agHelper.WaitUntilEleAppear(adminSettings.restartNotice); + agHelper.AssertElementAbsence(adminSettings.restartNotice, 200000); + objectsCoreAdminSettings.logoutFromApp(); + agHelper.AssertElementAbsence(adminSettings.loginWithGithub); + agHelper.AssertElementExist(loginPage.loginForm); + agHelper.AssertElementExist(loginPage.signupLink); + }, + ); +}); diff --git a/app/client/cypress/locators/LoginPage.json b/app/client/cypress/locators/LoginPage.json index a13558ec23..6197a87401 100644 --- a/app/client/cypress/locators/LoginPage.json +++ b/app/client/cypress/locators/LoginPage.json @@ -1,6 +1,7 @@ { - "username": "input[name='username'], input[name='email']", - "password": "input[name='password']", - "submitBtn": "button[type='submit']", - "signupLink": ".t--sign-up" + "username": "input[name='username'], input[name='email']", + "password": "input[name='password']", + "submitBtn": "button[type='submit']", + "signupLink": ".t--sign-up", + "loginForm": "form" } diff --git a/app/client/cypress/support/Pages/AdminSettings.ts b/app/client/cypress/support/Pages/AdminSettings.ts index b075f7f93b..e7ff123f53 100644 --- a/app/client/cypress/support/Pages/AdminSettings.ts +++ b/app/client/cypress/support/Pages/AdminSettings.ts @@ -1,5 +1,8 @@ -import { ObjectsRegistry } from "../Objects/Registry"; +import AdminsSettings from "../../locators/AdminsSettings"; +import githubForm from "../../locators/GithubForm.json"; +import HomePage from "../../locators/HomePage"; import { featureFlagIntercept } from "../Objects/FeatureFlags"; +import { ObjectsRegistry } from "../Objects/Registry"; export class AdminSettings { public agHelper = ObjectsRegistry.AggregateHelper; @@ -8,6 +11,7 @@ export class AdminSettings { public assertHelper = ObjectsRegistry.AssertHelper; public _adminSettingsBtn = ".admin-settings-menu-option"; + public _authenticationTab = ".t--settings-category-authentication"; public _saveButton = ".t--admin-settings-save-button"; private _settingsList = ".t--settings-category-list"; public _usersTab = ".t--settings-category-users"; @@ -47,6 +51,60 @@ export class AdminSettings { this.agHelper.AssertElementVisibility(this._settingsList); } + public NavigateToAuthenticationSettings(toNavigateToHome = true) { + this.NavigateToAdminSettings(toNavigateToHome); + this.agHelper.GetNClick(this._authenticationTab); + } + + public FillAndSaveGithubForm() { + this.agHelper.GetNClick(githubForm.githubClientId); + this.agHelper.TypeText( + githubForm.githubClientId, + Cypress.env("APPSMITH_OAUTH2_GITHUB_CLIENT_ID"), + ); + + this.agHelper.GetNClick(githubForm.githubClientSecret); + this.agHelper.TypeText( + githubForm.githubClientSecret, + Cypress.env("APPSMITH_OAUTH2_GITHUB_CLIENT_SECRET"), + ); + + this.agHelper.GetNClick(githubForm.saveBtn); + } + + public fillSaveAndAssertGithubForm() { + this.FillAndSaveGithubForm(); + this.agHelper.WaitUntilEleAppear(AdminsSettings.restartNotice); + this.agHelper.AssertElementAbsence(AdminsSettings.restartNotice, 200000); + } + + public toggleFormSignupLoginAndSave(enable = true, type = "signup") { + const selector = + type === "signup" + ? AdminsSettings.formSignupDisabled + : AdminsSettings.formLoginEnabled; + this.agHelper.GetNClick(AdminsSettings.formloginButton); + this.agHelper.WaitUntilEleAppear(selector); + + if (enable) { + this.agHelper.GetElement(selector).then(($el) => { + if (!$el.prop("checked")) { + this.agHelper.GetNClick(selector); + } + }); + } else { + this.agHelper.GetElement(selector).then(($el) => { + if ($el.prop("checked")) { + this.agHelper.GetNClick(selector); + } + }); + } + + this.agHelper.AssertElementVisibility(AdminsSettings.saveButton); + this.agHelper.GetNClick(AdminsSettings.saveButton); + this.agHelper.WaitUntilToastDisappear("Successfully saved"); + } + public EnableGAC( toNavigateToHome = true, toNavigateBackToHome = true, @@ -74,6 +132,20 @@ export class AdminSettings { } } + public logoutFromApp() { + this.agHelper.GetNClick(HomePage.profileMenu); + this.agHelper.GetNClick(HomePage.signOutIcon); + } + + public verifyFormLogin() { + this.agHelper.AssertElementVisibility(AdminsSettings.formloginButton); + this.agHelper.AssertContains( + "Edit", + "exist", + AdminsSettings.formloginButton, + ); + } + private enableGACFeatureFlag() { featureFlagIntercept({ license_gac_enabled: true }); }