Skip to content

Commit

Permalink
fix lint and introduce a link checker workflow (#387)
Browse files Browse the repository at this point in the history
* fix lint

Signed-off-by: Tianle Huang <tianleh@amazon.com>

* run lint

Signed-off-by: Tianle Huang <tianleh@amazon.com>

* add .lycheeexclude

Signed-off-by: Tianle Huang <tianleh@amazon.com>

* update workflow

Signed-off-by: Tianle Huang <tianleh@amazon.com>

* fix

Signed-off-by: Tianle Huang <tianleh@amazon.com>

* test fail

Signed-off-by: Tianle Huang <tianleh@amazon.com>

* update

Signed-off-by: Tianle Huang <tianleh@amazon.com>

Signed-off-by: Tianle Huang <tianleh@amazon.com>
(cherry picked from commit 20bcdaf)
  • Loading branch information
tianleh authored and github-actions[bot] committed Nov 10, 2022
1 parent 770c2ca commit d18e15b
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 28 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/lint_checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0

name: Lint Checker
on:
pull_request:
branches:
- main
- dev-*
jobs:
tests:
name: Lint Checker
runs-on: ubuntu-latest
env:
# prevents extra Cypress installation progress messages
CI: 1
# avoid warnings like "tput: No value for $TERM and no -T specified"
TERM: xterm
steps:
- name: Checkout cypress-test
uses: actions/checkout@v2
with:
repository: ${{github.repository}}
path: cypress-test
- name: Run Lint
working-directory: cypress-test
run: |
echo "VERSION=$(yarn --silent pkg-version)" >> $GITHUB_ENV
npm install
yarn lint
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@
* SPDX-License-Identifier: Apache-2.0
*/

import {
SAVED_OBJECTS_PATH,
} from '../../../utils/dashboards/constants';
import { SAVED_OBJECTS_PATH } from '../../../utils/dashboards/constants';

import {
ADMIN_AUTH,
CURRENT_TENANT,
} from '../../../utils/commands';
import { ADMIN_AUTH, CURRENT_TENANT } from '../../../utils/commands';

import tenantDescription from '../../../fixtures/plugins/security-dashboards-plugin/tenants/testTenant';
import testUsersSetUp from '../../../fixtures/plugins/security-dashboards-plugin/users/testUser';
Expand All @@ -27,7 +22,7 @@ const userName2 = 'test2';
const password = 'password';
const roleName1 = 'roleWithTest';
const roleName2 = 'roleWithoutTest';
const kibanaRoleName = 'kibana_user'
const kibanaRoleName = 'kibana_user';

if (Cypress.env('SECURITY_ENABLED') && Cypress.env('AGGREGATION_VIEW')) {
describe('Saved objects table test', () => {
Expand All @@ -41,13 +36,15 @@ if (Cypress.env('SECURITY_ENABLED') && Cypress.env('AGGREGATION_VIEW')) {
title: 's*',
timeFieldName: 'timestamp',
});
cy.createIndexPattern('index-pattern2', {
title: 'se*',
timeFieldName: 'timestamp',
},
indexPatternTenantHeaderSetUp
cy.createIndexPattern(
'index-pattern2',
{
title: 'se*',
timeFieldName: 'timestamp',
},
indexPatternTenantHeaderSetUp
);

cy.createInternalUser(userName1, testUsersSetUp);
cy.createInternalUser(userName2, testUsersSetUp);

Expand All @@ -60,7 +57,7 @@ if (Cypress.env('SECURITY_ENABLED') && Cypress.env('AGGREGATION_VIEW')) {

cy.wait(300000);
});

it('should check the saved objects as global tenant', () => {
CURRENT_TENANT.newTenant = 'global';
cy.visit(SAVED_OBJECTS_PATH);
Expand All @@ -86,7 +83,7 @@ if (Cypress.env('SECURITY_ENABLED') && Cypress.env('AGGREGATION_VIEW')) {
cy.contains('a', 'se*');
});

it('should login as test1 and check saved object', () =>{
it('should login as test1 and check saved object', () => {
CURRENT_TENANT.newTenant = 'private';
ADMIN_AUTH.newUser = userName1;
ADMIN_AUTH.newPassword = password;
Expand All @@ -95,13 +92,13 @@ if (Cypress.env('SECURITY_ENABLED') && Cypress.env('AGGREGATION_VIEW')) {
cy.url().should((url) => {
expect(url).to.contain('/management');
});

cy.wait(5000);
cy.contains('a', 'se*');
cy.contains('a', 's*').should('not.exist');
});

it('should login as test2 and check saved object', () =>{
it('should login as test2 and check saved object', () => {
CURRENT_TENANT.newTenant = 'private';
ADMIN_AUTH.newUser = userName2;
ADMIN_AUTH.newPassword = password;
Expand Down
8 changes: 4 additions & 4 deletions cypress/utils/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ export const ADMIN_AUTH = {
username: Cypress.env('username'),
password: Cypress.env('password'),
set newUser(changedUsername) {
this.username = changedUsername
this.username = changedUsername;
},
set newPassword(changedPassword) {
this.password = changedPassword;
},
};

export const CURRENT_TENANT = {
defaultTenant:'private',
defaultTenant: 'private',
set newTenant(changedTenant) {
this.defaultTenant = changedTenant;
this.defaultTenant = changedTenant;
},
}
};

export const supressNoRequestOccurred = () => {
cy.on('fail', (err) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { SEC_API } from '../../constants';
*****************************
*/

Cypress.Commands.add('createTenant', (tenantID, tenantJson) => {
Cypress.Commands.add('createTenant', (tenantID, tenantJson) => {
cy.request(
'PUT',
`${Cypress.env('openSearchUrl')}${SEC_API.TENANTS_BASE}/${tenantID}`,
Expand Down
10 changes: 5 additions & 5 deletions cypress/utils/plugins/security-dashboards-plugin/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
//Security API Constants
export const SEC_API_PREFIX = '/_plugins/_security/api';
export const SEC_API = {
TENANTS_BASE: `${SEC_API_PREFIX}/tenants`,
INTERNALUSERS_BASE: `${SEC_API_PREFIX}/internalusers`,
ROLE_BASE: `${SEC_API_PREFIX}/roles`,
ROLE_MAPPING_BASE: `${SEC_API_PREFIX}/rolesmapping`,
}
TENANTS_BASE: `${SEC_API_PREFIX}/tenants`,
INTERNALUSERS_BASE: `${SEC_API_PREFIX}/internalusers`,
ROLE_BASE: `${SEC_API_PREFIX}/roles`,
ROLE_MAPPING_BASE: `${SEC_API_PREFIX}/rolesmapping`,
};

0 comments on commit d18e15b

Please sign in to comment.