Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/integration-tests/protractor.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const htmlReporter = new HtmlScreenshotReporter({ dest: './gui_test_screenshots'
const junitReporter = new JUnitXmlReporter({ savePath: './gui_test_screenshots', consolidateAll: true });
const browserLogs: logging.Entry[] = [];

const suite = (tests: string[]) => (!_.isNil(process.env.BRIDGE_KUBEADMIN_PASSWORD) ? ['tests/login.scenario.ts'] : []).concat(['tests/base.scenario.ts', ...tests]);
const suite = (tests: string[]) => (!_.isNil(process.env.BRIDGE_KUBEADMIN_PASSWORD) ? ['tests/auth.scenario.ts'] : []).concat(['tests/base.scenario.ts', ...tests]);

export const config: Config = {
framework: 'jasmine',
Expand Down
22 changes: 22 additions & 0 deletions frontend/integration-tests/tests/auth.scenario.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { browser } from 'protractor';

import { appHost } from '../protractor.conf';
import * as loginView from '../views/login.view';

const KUBEADMIN_IDP = 'kube:admin';
const KUBEADMIN_USERNAME = 'kubeadmin';
const {
BRIDGE_KUBEADMIN_PASSWORD,
} = process.env;

describe('Authentication', () => {
beforeAll(async() => {
await browser.get(appHost);
await browser.sleep(3000); // Wait long enough for the login redirect to complete
});

it('logs in as kubeadmin user', async() => {
await loginView.login(KUBEADMIN_IDP, KUBEADMIN_USERNAME, BRIDGE_KUBEADMIN_PASSWORD);
expect(loginView.userDropdown.getText()).toContain('kube:admin');
});
});
5 changes: 3 additions & 2 deletions frontend/integration-tests/views/login.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const passwordInput = $('#inputPassword');
export const submitButton = $('button[type=submit]');
export const logOutLink = element(by.linkText('Log out'));
export const userDropdown = $('[data-test=user-dropdown] .pf-c-app-launcher__toggle');
export const loginPF = $('.login-pf');

export const selectProvider = async(provider: string) => {
const idpLink = element(by.cssContainingText('.idp', provider));
Expand All @@ -17,7 +18,7 @@ export const selectProvider = async(provider: string) => {
};

export const login = async(providerName: string, username: string, password: string) => {
if (providerName) {
if (await $('a.idp').isPresent()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break our current login test. If the IDP that we create is still in flight when the login scenario runs, this condition will be false, meaning the IDP selection will be skipped, and we will attempt to login using test user credentials against the kubeadmin idp.

await selectProvider(providerName);
}
await browser.wait(until.visibilityOf(nameInput));
Expand All @@ -32,5 +33,5 @@ export const logout = async() => {
await userDropdown.click();
await browser.wait(until.presenceOf(logOutLink));
await logOutLink.click();
await browser.wait(until.presenceOf($('.login-pf')));
await browser.wait(until.presenceOf(loginPF));
};