@red-hat-developer-hub/e2e-test-utils 1.1.29 → 1.1.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -105,9 +105,9 @@ log::success() {
105
105
  # Operator subscription and status
106
106
  # ---------------------------------------------------------------------------
107
107
  install_subscription() {
108
- local name=$1 namespace=$2 channel=$3 package=$4 source_name=$5 source_namespace=$6
109
- oc apply -f - << EOD
110
- apiVersion: operators.coreos.com/v1alpha1
108
+ local name=$1 namespace=$2 channel=$3 package=$4 source_name=$5 source_namespace=$6 starting_csv=${7:-}
109
+ local yaml
110
+ yaml="apiVersion: operators.coreos.com/v1alpha1
111
111
  kind: Subscription
112
112
  metadata:
113
113
  name: $name
@@ -117,30 +117,38 @@ spec:
117
117
  installPlanApproval: Automatic
118
118
  name: $package
119
119
  source: $source_name
120
- sourceNamespace: $source_namespace
121
- EOD
120
+ sourceNamespace: $source_namespace"
121
+ if [[ -n "$starting_csv" ]]; then
122
+ yaml+="
123
+ startingCSV: $starting_csv"
124
+ fi
125
+ echo "$yaml" | oc apply -f -
122
126
  return 0
123
127
  }
124
128
 
125
- check_operator_status() {
126
- local timeout=${1:-300} namespace=$2 operator_name=$3 expected_status=${4:-Succeeded}
127
- log::info "Checking operator '${operator_name}' in '${namespace}' (timeout ${timeout}s, expected: ${expected_status})"
129
+ # Wait for an operator CSV to reach a status phase.
130
+ # Uses OLM label selector (operators.coreos.com/<package>.<namespace>) which is
131
+ # deterministic, unlike spec.displayName which varies across channels/versions.
132
+ wait_for_operator() {
133
+ local timeout=${1:-300} namespace=$2 package=$3 expected_status=${4:-Succeeded}
134
+ local label="operators.coreos.com/${package}.${namespace}"
135
+ log::info "Waiting for operator '${package}' in '${namespace}' (label=${label}, timeout ${timeout}s, expected: ${expected_status})"
128
136
  timeout "${timeout}" bash -c "
129
137
  while true; do
130
- CURRENT_PHASE=\$(oc get csv -n '${namespace}' -o jsonpath='{.items[?(@.spec.displayName==\"${operator_name}\")].status.phase}')
131
- echo \"[check_operator_status] Phase: \${CURRENT_PHASE}\" >&2
132
- [[ \"\${CURRENT_PHASE}\" == \"${expected_status}\" ]] && echo \"[check_operator_status] Operator reached ${expected_status}\" >&2 && break
138
+ CURRENT_PHASE=\$(oc get csv -n '${namespace}' -l '${label}' -o jsonpath='{.items[0].status.phase}' 2>/dev/null)
139
+ echo \"[wait_for_operator] Phase: \${CURRENT_PHASE}\" >&2
140
+ [[ \"\${CURRENT_PHASE}\" == \"${expected_status}\" ]] && echo \"[wait_for_operator] Operator reached ${expected_status}\" >&2 && break
133
141
  sleep 10
134
142
  done
135
- " || { log::error "Operator did not reach ${expected_status} in time."; return 1; }
143
+ " || { log::error "Operator '${package}' did not reach ${expected_status} in time."; return 1; }
136
144
  }
137
145
 
138
146
  install_serverless_logic_ocp_operator() {
139
- install_subscription logic-operator openshift-operators stable logic-operator redhat-operators openshift-marketplace
147
+ install_subscription logic-operator openshift-operators stable logic-operator redhat-operators openshift-marketplace logic-operator.v1.37.2
140
148
  return 0
141
149
  }
142
150
  waitfor_serverless_logic_ocp_operator() {
143
- check_operator_status 500 openshift-operators "Red Hat OpenShift Serverless Logic" Succeeded
151
+ wait_for_operator 500 openshift-operators logic-operator Succeeded
144
152
  return 0
145
153
  }
146
154
 
@@ -149,7 +157,7 @@ install_serverless_ocp_operator() {
149
157
  return 0
150
158
  }
151
159
  waitfor_serverless_ocp_operator() {
152
- check_operator_status 300 openshift-operators "Red Hat OpenShift Serverless" Succeeded
160
+ wait_for_operator 300 openshift-operators serverless-operator Succeeded
153
161
  return 0
154
162
  }
155
163
 
@@ -1,5 +1,5 @@
1
1
  import { UIhelper } from "./ui-helper.js";
2
- import { generateSync } from "otplib";
2
+ import { authenticator } from "otplib";
3
3
  import { test, expect } from "@playwright/test";
4
4
  import { SETTINGS_PAGE_COMPONENTS } from "../page-objects/page-obj.js";
5
5
  import { UI_HELPER_ELEMENTS } from "../page-objects/global-obj.js";
@@ -177,11 +177,11 @@ export class LoginHelper {
177
177
  if (!secret) {
178
178
  throw new Error("Invalid User ID");
179
179
  }
180
- return generateSync({ secret });
180
+ return authenticator.generate(secret);
181
181
  }
182
182
  getGoogle2FAOTP() {
183
183
  const secret = process.env.GOOGLE_2FA_SECRET;
184
- return generateSync({ secret });
184
+ return authenticator.generate(secret);
185
185
  }
186
186
  async keycloakLogin(username, password) {
187
187
  await this.page.goto("/");
@@ -247,7 +247,7 @@ export class LoginHelper {
247
247
  .locator("[type='submit'][value='Sign in']:not(webauthn-status *)")
248
248
  .first()
249
249
  .click({ timeout: 5000 });
250
- const twofactorcode = generateSync({ secret: twofactor });
250
+ const twofactorcode = authenticator.generate(twofactor);
251
251
  await popup.locator("#app_totp").click({ timeout: 5000 });
252
252
  await popup.locator("#app_totp").fill(twofactorcode, { timeout: 5000 });
253
253
  await popup.waitForEvent("close", { timeout: 20000 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@red-hat-developer-hub/e2e-test-utils",
3
- "version": "1.1.29",
3
+ "version": "1.1.31",
4
4
  "description": "Test utilities for RHDH E2E tests",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -114,7 +114,7 @@
114
114
  "js-yaml": "4.1.1",
115
115
  "lodash.clonedeepwith": "4.5.0",
116
116
  "lodash.mergewith": "4.6.2",
117
- "otplib": "13.4.0",
117
+ "otplib": "12.0.1",
118
118
  "prettier": "3.8.1",
119
119
  "proper-lockfile": "4.1.2",
120
120
  "typescript": "6.0.2",