Skip to content

Commit a933f76

Browse files
Merge pull request #746 from etmurasaki/etmura-ou-915
OU-915: create dashboards and rbac
2 parents edce6c4 + 59e526a commit a933f76

37 files changed

Lines changed: 2752 additions & 256 deletions

web/cypress.config.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,20 @@ export default defineConfig({
1717
},
1818
env: {
1919
grepFilterSpecs: true,
20-
HOST_API: process.env.CYPRESS_BASE_URL.replace(/console-openshift-console.apps/, 'api').concat(
20+
HOST_API: (process.env.CYPRESS_BASE_URL || '').replace(/console-openshift-console.apps/, 'api').concat(
2121
':6443',
2222
),
23-
LOGIN_USERNAME: process.env.CYPRESS_LOGIN_USERS.split(',')[0].split(':')[0],
24-
LOGIN_PASSWORD: process.env.CYPRESS_LOGIN_USERS.split(',')[0].split(':')[1],
23+
// User 0 credentials - as kubeadmin or even non-admin user
24+
// specifically for perses e2e tests, user0 is considered as console admin user to install COO and create RBAC roles and bindings
25+
LOGIN_USERNAME: (process.env.CYPRESS_LOGIN_USERS || '').split(',')[0]?.split(':')[0] || '',
26+
LOGIN_PASSWORD: (process.env.CYPRESS_LOGIN_USERS || '').split(',')[0]?.split(':')[1] || '',
27+
// User 1 credentials
28+
// User 2 credentials
29+
// specifically for perses e2e tests, user1 and user2 are considered as perses e2e users to test RBAC access to dashboards
30+
LOGIN_USERNAME1: (process.env.CYPRESS_LOGIN_USERS || '').split(',')[1]?.split(':')[0] || '',
31+
LOGIN_PASSWORD1: (process.env.CYPRESS_LOGIN_USERS || '').split(',')[1]?.split(':')[1] || '',
32+
LOGIN_USERNAME2: (process.env.CYPRESS_LOGIN_USERS || '').split(',')[2]?.split(':')[0] || '',
33+
LOGIN_PASSWORD2: (process.env.CYPRESS_LOGIN_USERS || '').split(',')[2]?.split(':')[1] || '',
2534
TIMEZONE: process.env.CYPRESS_TIMEZONE || 'UTC',
2635
MOCK_NEW_METRICS: process.env.CYPRESS_MOCK_NEW_METRICS || 'false',
2736
COO_NAMESPACE: process.env.CYPRESS_COO_NAMESPACE || 'openshift-cluster-observability-operator',

web/cypress/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ Creates `export-env.sh` that you can source later: `source export-env.sh`
6666
|----------|-------------|---------|
6767
| `CYPRESS_BASE_URL` | OpenShift Console URL | `https://console-openshift-console.apps...` |
6868
| `CYPRESS_LOGIN_IDP` | Identity provider name | `flexy-htpasswd-provider` or `kube:admin` |
69-
| `CYPRESS_LOGIN_USERS` | Login credentials | `username:password` or `kubeadmin:password` |
69+
| `CYPRESS_LOGIN_IDP_DEV_USER`| Identity provider name for devuser | `flexy-htpasswd-provider` or `my_htpasswd_provider`|
70+
| `CYPRESS_LOGIN_USERS` | Login credentials | `username:password` or `kubeadmin:password` or `kubeadmin:password,user1:password,user2:password` |
7071
| `CYPRESS_KUBECONFIG_PATH` | Path to kubeconfig file | `~/Downloads/kubeconfig` |
7172

7273
### Plugin Image Configuration

web/cypress/configure-env.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ print_current_config() {
186186
print_var "CYPRESS_KONFLUX_KBV_BUNDLE_IMAGE" "${CYPRESS_KONFLUX_KBV_BUNDLE_IMAGE-}"
187187
print_var "CYPRESS_CUSTOM_KBV_BUNDLE_IMAGE" "${CYPRESS_CUSTOM_KBV_BUNDLE_IMAGE-}"
188188
print_var "CYPRESS_FBC_STAGE_KBV_IMAGE" "${CYPRESS_FBC_STAGE_KBV_IMAGE-}"
189+
print_var "CYPRESS_LOGIN_IDP_DEV_USER" "${CYPRESS_LOGIN_IDP_DEV_USER-}"
189190
}
190191

191192
main() {
@@ -238,6 +239,7 @@ main() {
238239
local def_konflux_kbv_bundle=${CYPRESS_KONFLUX_KBV_BUNDLE_IMAGE-}
239240
local def_custom_kbv_bundle=${CYPRESS_CUSTOM_KBV_BUNDLE_IMAGE-}
240241
local def_fbc_stage_kbv_image=${CYPRESS_FBC_STAGE_KBV_IMAGE-}
242+
local def_login_idp_dev_user=${CYPRESS_LOGIN_IDP_DEV_USER-}
241243
# Required basics
242244
local base_url
243245
while true; do
@@ -481,7 +483,9 @@ main() {
481483
local fbc_stage_kbv_image
482484
fbc_stage_kbv_image=$(ask "KBV FBC image (CYPRESS_FBC_STAGE_KBV_IMAGE)" "$def_fbc_stage_kbv_image")
483485

484-
486+
local login_idp_dev_user
487+
login_idp_dev_user=$(ask "Login identity provider dev user (CYPRESS_LOGIN_IDP_DEV_USER)" "$def_login_idp_dev_user")
488+
485489
# Build export lines with safe quoting
486490
local -a export_lines
487491
export_lines+=("export CYPRESS_BASE_URL='$(printf %s "$base_url" | escape_for_single_quotes)'" )
@@ -531,7 +535,9 @@ main() {
531535
if [[ -n "$fbc_stage_kbv_image" ]]; then
532536
export_lines+=("export CYPRESS_FBC_STAGE_KBV_IMAGE='$(printf %s "$fbc_stage_kbv_image" | escape_for_single_quotes)'" )
533537
fi
534-
538+
if [[ -n "$login_idp_dev_user" ]]; then
539+
export_lines+=("export CYPRESS_LOGIN_IDP_DEV_USER='$(printf %s "$login_idp_dev_user" | escape_for_single_quotes)'" )
540+
fi
535541
echo ""
536542
if is_sourced; then
537543
# Export directly into current shell
@@ -553,6 +559,7 @@ main() {
553559
echo " CYPRESS_BASE_URL=$base_url"
554560
echo " CYPRESS_LOGIN_IDP=$login_idp"
555561
echo " CYPRESS_LOGIN_USERS=$login_users"
562+
echo " CYPRESS_LOGIN_IDP_DEV_USER=$login_idp_dev_user"
556563
echo " CYPRESS_KUBECONFIG_PATH=$kubeconfig"
557564
[[ -n "$mp_image" ]] && echo " CYPRESS_MP_IMAGE=$mp_image"
558565
[[ -n "$coo_namespace" ]] && echo " CYPRESS_COO_NAMESPACE=$coo_namespace"
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { nav } from '../../views/nav';
2+
import { runCOOCreatePersesTests } from '../../support/perses/03.coo_create_perses_admin.cy';
3+
4+
// Set constants for the operators that need to be installed for tests.
5+
const MCP = {
6+
namespace: 'openshift-cluster-observability-operator',
7+
packageName: 'cluster-observability-operator',
8+
operatorName: 'Cluster Observability Operator',
9+
config: {
10+
kind: 'UIPlugin',
11+
name: 'monitoring',
12+
},
13+
};
14+
15+
const MP = {
16+
namespace: 'openshift-monitoring',
17+
operatorName: 'Cluster Monitoring Operator',
18+
};
19+
20+
//TODO: change tag to @dashboards when customizable-dashboards gets merged
21+
describe('COO - Dashboards (Perses) - Create perses dashboard', { tags: ['@perses', '@dashboards-'] }, () => {
22+
23+
before(() => {
24+
cy.beforeBlockCOO(MCP, MP);
25+
cy.setupPersesRBACandExtraDashboards();
26+
});
27+
28+
beforeEach(() => {
29+
nav.sidenav.clickNavLink(['Observe', 'Dashboards (Perses)']);
30+
cy.wait(5000);
31+
cy.changeNamespace('All Projects');
32+
});
33+
34+
after(() => {
35+
cy.cleanupExtraDashboards();
36+
});
37+
38+
runCOOCreatePersesTests({
39+
name: 'Administrator',
40+
});
41+
42+
});
43+
44+
45+
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { nav } from '../../views/nav';
2+
import { runCOORBACPersesTestsDevUser1 } from '../../support/perses/99.coo_rbac_perses_user1.cy';
3+
4+
5+
// Set constants for the operators that need to be installed for tests.
6+
const MCP = {
7+
namespace: 'openshift-cluster-observability-operator',
8+
packageName: 'cluster-observability-operator',
9+
operatorName: 'Cluster Observability Operator',
10+
config: {
11+
kind: 'UIPlugin',
12+
name: 'monitoring',
13+
},
14+
};
15+
16+
const MP = {
17+
namespace: 'openshift-monitoring',
18+
operatorName: 'Cluster Monitoring Operator',
19+
};
20+
21+
//TODO: change tag to @smoke, @dashboards, @perses when customizable-dashboards gets merged
22+
describe('BVT: COO - Dashboards (Perses) - Administrator perspective', { tags: ['@smoke-', '@dashboards-', '@perses-dev'] }, () => {
23+
24+
before(() => {
25+
//TODO: https://issues.redhat.com/browse/OCPBUGS-58468 - when it gets fixed, installation can be don using non-admin user
26+
// Step 1: Grant temporary cluster-admin role to dev user for COO/Perses installation
27+
// cy.log('Granting temporary cluster-admin role to dev user for setup');
28+
// cy.adminCLI(
29+
// `oc adm policy add-cluster-role-to-user cluster-admin ${Cypress.env('LOGIN_USERNAME')}`,
30+
// );
31+
32+
// Step 2: Setup COO and Perses dashboards (requires admin privileges)
33+
cy.beforeBlockCOO(MCP, MP);
34+
cy.setupPersesRBACandExtraDashboards();
35+
36+
//TODO: https://issues.redhat.com/browse/OCPBUGS-58468 - when it gets fixed, installation can be don using non-admin user
37+
// Step 3: Remove cluster-admin role - dev user now has limited permissions
38+
// cy.log('Removing cluster-admin role from dev user');
39+
// cy.adminCLI(
40+
// `oc adm policy remove-cluster-role-from-user cluster-admin ${Cypress.env('LOGIN_USERNAME')}`,
41+
// );
42+
43+
// Step 4: Clear Cypress session cache and logout
44+
// This is critical because beforeBlockCOO uses cy.session() which caches the login state
45+
cy.log('Clearing Cypress session cache to ensure fresh login');
46+
Cypress.session.clearAllSavedSessions();
47+
48+
// Clear all cookies and storage to fully reset browser state
49+
cy.clearAllCookies();
50+
cy.clearAllLocalStorage();
51+
cy.clearAllSessionStorage();
52+
53+
// Step 5: Re-login as dev user (now without cluster-admin role)
54+
// Using cy.relogin() because it doesn't require oauthurl and handles the login page directly
55+
cy.log('Re-logging in as dev user with limited permissions');
56+
cy.relogin(
57+
Cypress.env('LOGIN_IDP_DEV_USER'),
58+
Cypress.env('LOGIN_USERNAME1'),
59+
Cypress.env('LOGIN_PASSWORD1'),
60+
);
61+
cy.validateLogin();
62+
cy.closeOnboardingModalIfPresent();
63+
});
64+
65+
beforeEach(() => {
66+
nav.sidenav.clickNavLink(['Observe', 'Dashboards (Perses)']);
67+
});
68+
69+
after(() => {
70+
cy.cleanupExtraDashboards();
71+
});
72+
73+
//TODO: rename after customizable-dashboards gets merged
74+
runCOORBACPersesTestsDevUser1({
75+
name: 'Administrator',
76+
});
77+
78+
});
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { nav } from '../../views/nav';
2+
import { runCOORBACPersesTestsDevUser2 } from '../../support/perses/99.coo_rbac_perses_user2.cy';
3+
4+
5+
// Set constants for the operators that need to be installed for tests.
6+
const MCP = {
7+
namespace: 'openshift-cluster-observability-operator',
8+
packageName: 'cluster-observability-operator',
9+
operatorName: 'Cluster Observability Operator',
10+
config: {
11+
kind: 'UIPlugin',
12+
name: 'monitoring',
13+
},
14+
};
15+
16+
const MP = {
17+
namespace: 'openshift-monitoring',
18+
operatorName: 'Cluster Monitoring Operator',
19+
};
20+
21+
//TODO: change tag to @smoke, @dashboards, @perses when customizable-dashboards gets merged
22+
describe('BVT: COO - Dashboards (Perses) - Administrator perspective', { tags: ['@smoke-', '@dashboards-', '@perses-dev'] }, () => {
23+
24+
before(() => {
25+
//TODO: https://issues.redhat.com/browse/OCPBUGS-58468 - when it gets fixed, installation can be don using non-admin user
26+
// Step 1: Grant temporary cluster-admin role to dev user for COO/Perses installation
27+
// cy.log('Granting temporary cluster-admin role to dev user for setup');
28+
// cy.adminCLI(
29+
// `oc adm policy add-cluster-role-to-user cluster-admin ${Cypress.env('LOGIN_USERNAME')}`,
30+
// );
31+
32+
// Step 2: Setup COO and Perses dashboards (requires admin privileges)
33+
cy.beforeBlockCOO(MCP, MP);
34+
cy.setupPersesRBACandExtraDashboards();
35+
36+
//TODO: https://issues.redhat.com/browse/OCPBUGS-58468 - when it gets fixed, installation can be don using non-admin user
37+
// Step 3: Remove cluster-admin role - dev user now has limited permissions
38+
// cy.log('Removing cluster-admin role from dev user');
39+
// cy.adminCLI(
40+
// `oc adm policy remove-cluster-role-from-user cluster-admin ${Cypress.env('LOGIN_USERNAME')}`,
41+
// );
42+
43+
// Step 4: Clear Cypress session cache and logout
44+
// This is critical because beforeBlockCOO uses cy.session() which caches the login state
45+
cy.log('Clearing Cypress session cache to ensure fresh login');
46+
Cypress.session.clearAllSavedSessions();
47+
48+
// Clear all cookies and storage to fully reset browser state
49+
cy.clearAllCookies();
50+
cy.clearAllLocalStorage();
51+
cy.clearAllSessionStorage();
52+
53+
// Step 5: Re-login as dev user (now without cluster-admin role)
54+
// Using cy.relogin() because it doesn't require oauthurl and handles the login page directly
55+
cy.log('Re-logging in as dev user with limited permissions');
56+
cy.relogin(
57+
Cypress.env('LOGIN_IDP_DEV_USER'),
58+
Cypress.env('LOGIN_USERNAME2'),
59+
Cypress.env('LOGIN_PASSWORD2'),
60+
);
61+
cy.validateLogin();
62+
cy.closeOnboardingModalIfPresent();
63+
});
64+
65+
beforeEach(() => {
66+
nav.sidenav.clickNavLink(['Observe', 'Dashboards (Perses)']);
67+
});
68+
69+
after(() => {
70+
cy.cleanupExtraDashboards();
71+
});
72+
73+
//TODO: rename after customizable-dashboards gets merged
74+
runCOORBACPersesTestsDevUser2({
75+
name: 'Administrator',
76+
});
77+
78+
});

web/cypress/e2e/virtualization/04.coo_ivt_perses.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { nav } from '../../views/nav';
2-
import { runBVTCOOPersesTests } from '../../support/perses/00.coo_bvt_perses.cy';
2+
import { runBVTCOOPersesTests } from '../../support/perses/00.coo_bvt_perses_admin.cy';
33
import { guidedTour } from '../../views/tour';
44
import { commonPages } from '../../views/common';
55

@@ -56,7 +56,7 @@ describe('Installation: Virtualization', { tags: ['@virtualization', '@slow'] },
5656
});
5757
});
5858

59-
describe('IVT: COO - Dashboards (Perses) - Virtualization perspective', { tags: ['@virtualization', '@dashboards'] }, () => {
59+
describe('IVT: COO - Dashboards (Perses) - Virtualization perspective', { tags: ['@virtualization', '@perses'] }, () => {
6060

6161
beforeEach(() => {
6262
cy.visit('/');

web/cypress/fixtures/coo/coo121_perses_dashboards/openshift-cluster-sample-dashboard.yaml renamed to web/cypress/fixtures/coo/coo121_perses/dashboards/openshift-cluster-sample-dashboard.yaml

File renamed without changes.

web/cypress/fixtures/coo/coo121_perses_dashboards/perses-dashboard-sample.yaml renamed to web/cypress/fixtures/coo/coo121_perses/dashboards/perses-dashboard-sample.yaml

File renamed without changes.

web/cypress/fixtures/coo/coo121_perses_dashboards/prometheus-overview-variables.yaml renamed to web/cypress/fixtures/coo/coo121_perses/dashboards/prometheus-overview-variables.yaml

File renamed without changes.

0 commit comments

Comments
 (0)