Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • osl/code/org.etsi.osl.tmf.web
1 result
Show changes
Commits on Source (4)
...@@ -41,6 +41,8 @@ yarn-error.log ...@@ -41,6 +41,8 @@ yarn-error.log
testem.log testem.log
/typings /typings
.env .env
cypress/fixtures
cypress/screenshots
# System Files # System Files
.DS_Store .DS_Store
......
import { defineConfig } from "cypress"; import { defineConfig } from "cypress";
import * as dotenv from "dotenv"; import * as dotenv from "dotenv";
dotenv.config(); dotenv.config( { path: 'cypress/.env'});
export default defineConfig({ export default defineConfig({
...@@ -20,7 +20,12 @@ export default defineConfig({ ...@@ -20,7 +20,12 @@ export default defineConfig({
viewportHeight: 900, viewportHeight: 900,
env: { env: {
username: process.env.CYPRESS_username, username: process.env.CYPRESS_username,
password: process.env.CYPRESS_password password: process.env.CYPRESS_password,
authURL: process.env.CYPRESS_AUTH_URL,
authRealm: process.env.CYPRESS_AUTH_REALM,
resetCredentials: process.env.CYPRESS_RESET_CREDENTIALS,
registration: process.env.CYPRESS_REGISTRATION
} }
}, },
......
CYPRESS_username=admin
CYPRESS_password=openslice
CYPRESS_BASE_URL=http://localhost:4200/
CYPRESS_AUTH_URL=https://portal.openslice.eu/
CYPRESS_AUTH_REALM=/auth/realms/openslice/protocol/openid-connect/auth
CYPRESS_RESET_CREDENTIALS=/auth/realms/openslice/login-actions/reset-credentials
CYPRESS_REGISTRATION=/auth/realms/openslice/login-actions/registration
\ No newline at end of file
describe('user authentication', () => { describe("user authentication", () => {
beforeEach(() => { beforeEach(() => {
cy.visit(window.location.origin); cy.visit(window.location.origin);
});
})
//edit profile bug
it('should block unauthenticated user from entering a protected route', () => {
cy.fixture("routes.json").then((data) => {
cy.log(data.routes);
// cy.wrap(data.routes).as("protectedRoutes");
for(let route of data.routes) {
cy.intercept(route);
cy.log(route);
cy.visit(route);
cy.location("pathname").should("equal", "/");
}
});
});
it('should display login errors when nothing is typed', () => { it("should block unauthenticated user from entering a protected route", () => {
cy.get(':nth-child(1) > .nav-link').click(); cy.fixture("routes.json").then((data) => {
cy.location("pathname").should("equal", '/services'); cy.log(data.routes);
cy.get('.btn').should("contain", "Sign In").click(); for (let route of data.routes) {
cy.origin('https://portal.openslice.eu', () => { cy.intercept(route);
cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth"); cy.log(route);
cy.get('#kc-login').click(); cy.visit(route);
cy.get('#input-error').should('be.visible').and('contain','Invalid username or password.'); cy.location("pathname").should("equal", "/");
cy.get('[aria-invalid="true"]').should('have.length', 2); //the 2 input fields should have selector aria-invalid = 'true' }
});
}); });
});
it('should display login errors when credentials are wrong', () => { it("should display login errors when nothing is typed", () => {
cy.get(':nth-child(1) > .nav-link').click(); cy.get(":nth-child(1) > .nav-link").click();
cy.location("pathname").should("equal", '/services'); cy.location("pathname").should("equal", "/services");
cy.get('.btn').should("contain", "Sign In").click(); cy.get(".btn").should("contain", "Sign In").click();
cy.origin('https://portal.openslice.eu', () => { cy.origin(Cypress.env("authURL"), () => {
cy.location("pathname").should("equal", Cypress.env("authRealm"));
cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth"); cy.get("#kc-login").click();
cy.get("#input-error")
cy.get('#username').type('test').blur(); .should("be.visible")
cy.get('#password').type('test').blur(); .and("contain", "Invalid username or password.");
cy.get('#kc-login').click(); cy.get('[aria-invalid="true"]').should("have.length", 2); //the 2 input fields should have selector aria-invalid = 'true'
cy.get('#input-error').should('be.visible').and('contain','Invalid username or password.');
cy.get('[aria-invalid="true"]').should('have.length', 2); //the 2 input fields should have selector aria-invalid = 'true'
});
}); });
});
it("should display login errors when credentials are wrong", () => {
cy.get(":nth-child(1) > .nav-link").click();
cy.location("pathname").should("equal", "/services");
cy.get(".btn").should("contain", "Sign In").click();
cy.origin(Cypress.env("authURL"), () => {
cy.location("pathname").should("equal", Cypress.env("authRealm"));
it('should login, logout', () => { cy.get("#username").type("test").blur();
cy.get("#password").type("test").blur();
cy.loginPath(':nth-child(2) > .container > .row > :nth-child(2) > a > .btn', '/services'); cy.get("#kc-login").click();
cy.get('#navbarDropdown2').click(); cy.get("#input-error")
cy.window().then((win) => { .should("be.visible")
expect(win.localStorage.getItem('access_token')).to.exist; .and("contain", "Invalid username or password.");
}) cy.get('[aria-invalid="true"]').should("have.length", 2); //the 2 input fields should have selector aria-invalid = 'true'
cy.get(':nth-child(2) > .dropdown > .dropdown-menu > :nth-child(8)').click();
cy.location("pathname").should("equal", "/");
}); });
});
it('forget password should work', () => { it("should login, logout", () => {
cy.get(':nth-child(1) > .nav-link').click(); cy.loginPath(
cy.location("pathname").should("equal", '/services'); ":nth-child(2) > .container > .row > :nth-child(2) > a > .btn",
cy.get('.btn').should("contain", "Sign In").click(); "/services"
cy.origin('https://portal.openslice.eu', () => { );
cy.get("#navbarDropdown2").click();
cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth"); cy.window().then((win) => {
cy.get(':nth-child(2) > span > a').click(); expect(win.localStorage.getItem("access_token")).to.exist;
cy.location("pathname").should("equal", "/auth/realms/openslice/login-actions/reset-credentials");
cy.get('#username').should('exist');
});
}); });
context('register form', () => { cy.get(
beforeEach(() => { ":nth-child(2) > .dropdown > .dropdown-menu > :nth-child(8)"
cy.get(':nth-child(1) > .nav-link').click(); ).click();
cy.location("pathname").should("equal", '/services'); cy.location("pathname").should("equal", "/");
cy.get('.btn').should("contain", "Sign In").click(); });
cy.origin('https://portal.openslice.eu', () => { it("forget password should work", () => {
cy.get(":nth-child(1) > .nav-link").click();
cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth"); cy.location("pathname").should("equal", "/services");
cy.get('#kc-registration > span > a').click(); cy.get(".btn").should("contain", "Sign In").click();
cy.location("pathname").should("equal", "/auth/realms/openslice/login-actions/registration"); cy.origin(Cypress.env("authURL"), () => {
cy.location("pathname").should("equal", Cypress.env("authRealm"));
}); cy.get(":nth-child(2) > span > a").click();
}) cy.log(Cypress.env("resetCredentials"));
it('register form should not be empty when submitted', () => { cy.location("pathname").should("equal", Cypress.env("resetCredentials"));
cy.get("#username").should("exist");
cy.origin('https://portal.openslice.eu/auth/realms/openslice/login-actions/registration', () => { });
});
cy.get('.pf-c-button').click(); context("register form", () => {
cy.get('#input-error-firstname').should('exist').and('contain', 'Please specify first name.'); beforeEach(() => {
cy.get('#input-error-lastname').should('exist').and('contain', 'Please specify last name.'); cy.get(":nth-child(1) > .nav-link").click();
cy.get('#input-error-email').should('exist').and('contain', 'Please specify email.'); cy.location("pathname").should("equal", "/services");
cy.get('#input-error-username').should('exist').and('contain', 'Please specify username.'); cy.get(".btn").should("contain", "Sign In").click();
cy.get('#input-error-password').should('exist').and('contain', 'Please specify password.'); cy.origin(Cypress.env("authURL"), () => {
}); cy.location("pathname").should("equal", Cypress.env("authRealm"));
cy.get("#kc-registration > span > a").click();
}); cy.location("pathname").should("equal", Cypress.env("registration"));
});
it('invalid email', () => { });
cy.origin('https://portal.openslice.eu/auth/realms/openslice/login-actions/registration', () => { it("register form should not be empty when submitted", () => {
cy.origin(Cypress.env("authURL") + Cypress.env("registration"), () => {
cy.get('#email').type('email'); cy.get(".pf-c-button").click();
cy.get('.pf-c-button').click(); cy.get("#input-error-firstname")
cy.get('#input-error-email').should('exist').and('contain','Invalid email address.'); .should("exist")
cy.get('#email').type('@example.com'); .and("contain", "Please specify first name.");
cy.get('.pf-c-button').click(); cy.get("#input-error-lastname")
cy.get('#input-error-email').should('not.exist'); .should("exist")
}); .and("contain", "Please specify last name.");
}); cy.get("#input-error-email")
.should("exist")
it('confirm password field should be the same with password', () => { .and("contain", "Please specify email.");
cy.origin('https://portal.openslice.eu/auth/realms/openslice/login-actions/registration', () => { cy.get("#input-error-username")
cy.get('#password').type('123'); .should("exist")
cy.get('#password-confirm').type('1234'); .and("contain", "Please specify username.");
cy.get('.pf-c-button').click(); cy.get("#input-error-password")
cy.get('#input-error-password-confirm').should('exist').and('contain',"Password confirmation doesn't match."); .should("exist")
cy.get('#password').type('123'); .and("contain", "Please specify password.");
cy.get('#password-confirm').type('123'); });
cy.get('.pf-c-button').click(); });
cy.get('#input-error-password-confirm').should('not.exist'); it("invalid email", () => {
}); cy.origin(Cypress.env("authURL") + Cypress.env("registration"), () => {
}); cy.get("#email").type("email");
cy.get(".pf-c-button").click();
cy.get("#input-error-email")
}) .should("exist")
.and("contain", "Invalid email address.");
}) cy.get("#email").type("@example.com");
\ No newline at end of file cy.get(".pf-c-button").click();
cy.get("#input-error-email").should("not.exist");
});
});
it("confirm password field should be the same with password", () => {
cy.origin(Cypress.env("authURL") + Cypress.env("registration"), () => {
cy.get("#password").type("123");
cy.get("#password-confirm").type("1234");
cy.get(".pf-c-button").click();
cy.get("#input-error-password-confirm")
.should("exist")
.and("contain", "Password confirmation doesn't match.");
cy.get("#password").type("123");
cy.get("#password-confirm").type("123");
cy.get(".pf-c-button").click();
cy.get("#input-error-password-confirm").should("not.exist");
});
});
});
});
{
"routes": [
"resources/resource_catalogs",
"resources/resource_categories",
"resources/resource_categories_update",
"resources/resource_specs",
"resources/resource_spec_update",
"resources/resource_inventory",
"resources/resource_pools",
"resources/resource_pool",
"resources/resource_reservations",
"resources/resource_reservations_calendar",
"resources/resource_reservation_update",
"services/service_catalogs",
"services/service_categories",
"services/service_categories_update",
"services/service_specs",
"services/service_spec_update",
"services/list_nsds",
"services/list_tests",
"services/service_orders",
"services/service_order_checkout",
"services/my_service_orders",
"services/service_orders_calendar",
"services/organizations",
"services/organization_update",
"services/individuals",
"services/individual_update",
"services/service_inventory",
"services/alarms",
"services/action_specs",
"services/action_specs",
"services/action_rules",
"services/action_rule",
"services/service_rule_design",
"testing/service_test_specs",
"testing/service_test_spec",
"testing/service_tests",
"testing/organizations",
"testing/organization_update",
"testing/individuals",
"testing/individual_update",
"products/product_catalogs",
"products/product_catalog_update",
"products/product_categories",
"products/product_category_update",
"products/product_offerings",
"products/product_offering_update",
"products/product_specs",
"products/product_spec_update",
"products/organizations",
"products/organization_update",
"products/individuals",
"products/individual_update",
"/products/individual_update/myuser",
"/testing/individual_update/myuser",
"/services/individual_update/myuser",
"/resources/individual_update/myuser"
]
}
\ No newline at end of file
declare namespace Cypress { declare namespace Cypress {
interface Chainable {
interface Chainable { navigateToServices(selector): Chainable<any>;
navigateToServices(selector): Chainable<any>, navigateToResources(selector): Chainable<any>;
navigateToResources(selector): Chainable<any>, navigateToTesting(selector): Chainable<any>;
navigateToTesting(selector): Chainable<any>, navigateToProducts(selector): Chainable<any>;
navigateToProducts(selector): Chainable<any>, authUser(): Chainable<any>;
authUser(): Chainable<any>, loginPath(selector, path): Chainable<any>;
loginPath(selector, path): Chainable<any>, manageEntities(selector, button, scndIndx, numOfItems): Chainable<any>;
manageEntities(selector, button, scndIndx, numOfItems): Chainable<any>, checkProtectedRoutes(): Chainable<any>;
checkProtectedRoutes(): Chainable<any> }
}
} }
Cypress.Commands.add("navigateToServices", (selector) => {
Cypress.Commands.add('navigateToServices', (selector) => { cy.get(selector).click();
cy.get(selector).click(); cy.location("pathname").should("equal", "/services");
cy.location("pathname").should("equal", "/services"); cy.get(".btn").should("contain", "Sign In");
cy.get('.btn').should("contain", "Sign In"); cy.get(":nth-child(2) > .nav-item > .nav-link").should("exist");
cy.get(':nth-child(2) > .nav-item > .nav-link').should("exist"); //service marketplace button should exist and should redirect to /services_marketplace
cy.get(".mr-auto > .nav-item > .nav-link").click();
//service marketplace button should exist and should redirect to /services_marketplace cy.get(".jumbotron > h5.ng-tns-c147-1").should(
cy.get('.mr-auto > .nav-item > .nav-link').click(); "contain",
cy.get('.jumbotron > h5.ng-tns-c147-1').should("contain", "Browse available services and sign in to order"); "Browse available services and sign in to order"
cy.get('.catalog-tree-header').should("exist"); );
cy.get(".catalog-tree-header").should("exist");
//sign in button should exist //sign in button should exist
cy.get(':nth-child(2) > .nav-item > .nav-link').click(); cy.get(":nth-child(2) > .nav-item > .nav-link").click();
//sign in button should redirect to auth form
//sign in button should redirect to auth form cy.origin(Cypress.env("authURL"), () => {
cy.origin('https://portal.openslice.eu', () => { cy.location("pathname").should("equal", Cypress.env("authRealm"));
cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth"); });
});
}); });
Cypress.Commands.add("navigateToResources", (selector) => {
Cypress.Commands.add('navigateToResources', (selector) => { cy.get(selector).click();
cy.get(selector).click(); cy.location("pathname").should("equal", "/resources");
cy.location("pathname").should("equal", "/resources"); //sign in button should exist
//sign in button should exist cy.get(".btn").should("exist").click();
cy.get('.btn').should('exist').click(); //cy.get('nav-link').should('exist').click();
//cy.get('nav-link').should('exist').click(); //sign in button should redirect to auth form
cy.origin(Cypress.env("authURL"), () => {
//sign in button should redirect to auth form cy.location("pathname").should("equal", Cypress.env("authRealm"));
cy.origin('https://portal.openslice.eu/', () => { });
cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth");
});
})
Cypress.Commands.add('navigateToTesting', (selector) => {
cy.get(selector).click();
cy.location("pathname").should("equal", "/testing");
//sign in button should exist
cy.get('.btn').should('exist').click();
//cy.get('nav-link').should('exist').click();
//sign in button should redirect to auth form
cy.origin('https://portal.openslice.eu', () => {
cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth");
});
}); });
Cypress.Commands.add("navigateToTesting", (selector) => {
Cypress.Commands.add('navigateToProducts', (selector) => { cy.get(selector).click();
cy.get(selector).click(); cy.location("pathname").should("equal", "/testing");
cy.location("pathname").should("equal", "/products"); //sign in button should exist
cy.get('.btn').should("contain", "Sign In"); cy.get(".btn").should("exist").click();
cy.get(':nth-child(2) > .nav-item > .nav-link').should("exist"); //cy.get('nav-link').should('exist').click();
//sign in button should redirect to auth form
//marketplace button should exist and should redirect to products/marketplace cy.origin(Cypress.env("authURL"), () => {
cy.get('.mr-auto > .nav-item > .nav-link').click(); cy.location("pathname").should("equal", Cypress.env("authRealm"));
cy.get('.catalog-tree-header').should("exist"); });
cy.get('.mb-0').should("contain", "Product Catalog Explorer");
//sign in button should exist
cy.get(':nth-child(2) > .nav-item > .nav-link').click();
//sign in button should redirect to auth form
cy.origin('https://portal.openslice.eu', () => {
cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth");
});
}); });
Cypress.Commands.add("navigateToProducts", (selector) => {
Cypress.Commands.add('authUser', () => { cy.get(selector).click();
cy.get('.btn').should("contain", "Sign In").click(); cy.location("pathname").should("equal", "/products");
cy.get(".btn").should("contain", "Sign In");
cy.origin('https://portal.openslice.eu', () => { cy.get(":nth-child(2) > .nav-item > .nav-link").should("exist");
cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth"); //marketplace button should exist and should redirect to products/marketplace
cy.get('#username').type(Cypress.env('username')); cy.get(".mr-auto > .nav-item > .nav-link").click();
cy.get('#password').type(Cypress.env('password')); cy.get(".catalog-tree-header").should("exist");
cy.get('#kc-login').click(); cy.get(".mb-0").should("contain", "Product Catalog Explorer");
}); //sign in button should exist
//redirect page cy.get(":nth-child(2) > .nav-item > .nav-link").click();
cy.location("pathname").should("equal", "/redirect"); //sign in button should redirect to auth form
cy.origin(Cypress.env("authURL"), () => {
cy.location("pathname").should("equal", Cypress.env("authRealm"));
});
}); });
Cypress.Commands.add("authUser", () => {
Cypress.Commands.add('loginPath', (selector, path) => { cy.get(".btn").should("contain", "Sign In").click();
cy.get(selector).click(); cy.origin(Cypress.env("authURL"), () => {
cy.intercept(path); cy.location("pathname").should("equal", Cypress.env("authRealm"));
cy.location("pathname").should("equal", path); cy.get("#username").type(Cypress.env("username"));
cy.authUser(); cy.get("#password").type(Cypress.env("password"));
}) cy.get("#kc-login").click();
});
Cypress.Commands.add('manageEntities', (selector, button, scndIndx, numOfItems) => { cy.location("pathname").should("equal", "/redirect");
});
for(let i=1; i<=numOfItems; i++) { Cypress.Commands.add("loginPath", (selector, path) => {
cy.get(selector).click(); cy.get(selector).click();
if(i == 2 && scndIndx == 3){ cy.intercept(path);
cy.get(`.nav-item.show > .dropdown-menu > :nth-child(3) > .dropdown-item`).click(); cy.location("pathname").should("equal", path);
cy.go('back'); cy.authUser();
} });
Cypress.Commands.add(
else "manageEntities",
cy.get(`.nav-item.show > .dropdown-menu > :nth-child(${i}) > .dropdown-item`).click(); (selector, button, scndIndx, numOfItems) => {
cy.get(button).click(); for (let i = 1; i <= numOfItems; i++) {
cy.go('back'); cy.get(selector).click();
} if (i == 2 && scndIndx == 3) {
}) cy.get(
`.nav-item.show > .dropdown-menu > :nth-child(3) > .dropdown-item`
Cypress.Commands.add('checkProtectedRoutes', () => { ).click();
for(let route of Cypress.env('protectedRoutes')) { cy.go("back");
cy.intercept(route); } else
cy.log(route); cy.get(
cy.visit(route); `.nav-item.show > .dropdown-menu > :nth-child(${i}) > .dropdown-item`
cy.location("pathname").should("equal", "/"); ).click();
cy.get(button).click();
cy.go("back");
} }
}) }
\ No newline at end of file );
Cypress.Commands.add("checkProtectedRoutes", () => {
for (let route of Cypress.env("protectedRoutes")) {
cy.intercept(route);
cy.log(route);
cy.visit(route);
cy.location("pathname").should("equal", "/");
}
});
Source diff could not be displayed: it is too large. Options to address this: view the blob.