Skip to content

Conversation

@uroslates
Copy link
Contributor

@uroslates uroslates requested a review from a team as a code owner September 30, 2025 09:53
@github-actions github-actions bot marked this pull request as draft September 30, 2025 09:53
@uroslates
Copy link
Contributor Author

uroslates commented Sep 30, 2025

QA steps

Changing password expiration rules for testing purpose (can be tricky - since targets all system users).

Workaround for handing this can be following:

  1. Create mocked interceptor similar to below and provide it in your app module (as specified in class docs below):
import {
  HttpErrorResponse,
  HttpEvent,
  HttpHandler,
  HttpInterceptor,
  HttpRequest,
} from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable, throwError } from 'rxjs';

/**
 * This interceptor is used to mock HTTP responses for specific API endpoints.
 *
 * It intercepts HTTP requests and returns mock data for the defined endpoints,
 * while allowing other requests to pass through unmodified.
 *
 * To use this interceptor, provide it in your Angular module's providers array.
 * Example ([in app.module.ts](https://github.com/SAP/spartacus/blob/20b375201f22ecdff1ad850bccbae763969102a5/projects/storefrontapp/src/app/app.module.ts#L68)):
 * {
 *  provide: HTTP_INTERCEPTORS,
 *  useExisting: MockInterceptor,
 *  multi: true,
 * }
 */
@Injectable({ providedIn: 'root' })
export class MockInterceptor implements HttpInterceptor {
  intercept(
    req: HttpRequest<any>,
    next: HttpHandler
  ): Observable<HttpEvent<any>> {
    // Define the API endpoint you want to mock
    const OAUTH_ENDPOINT = '/authorizationserver/oauth/token';
    const mockUrl = OAUTH_ENDPOINT;

    if (req.url.endsWith(mockUrl)) {
      // Return mock data as an HTTP response
      const mockResponse = new HttpErrorResponse({
        status: 400,
        error: {
          error: 'invalid_grant',
          // error_description: "Bad credentials",
          error_description: 'Password expired for the user: John Doe',
        },
        url: req.url,
      });
      // Use throwError to simulate an error response
      return throwError(() => mockResponse);
    }

    // Pass through other requests unmodified
    return next.handle(req);
  }
}
  1. Trying to login will now trigger expected error.
  2. Verify tests are passing.

Alternatively you could follow the description of https://jira.tools.sap/browse/CXSPA-10815 to see how to change Password expiration rule in Backoffice (but that can affect others if done on shared system). So above is safer for me.

@uroslates uroslates marked this pull request as ready for review September 30, 2025 12:25
@github-actions
Copy link
Contributor

Merge Checks Failed

Please push a commit to re-trigger the build.
To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`

@github-actions github-actions bot marked this pull request as draft September 30, 2025 13:46
@uroslates uroslates marked this pull request as ready for review September 30, 2025 14:00
@cypress
Copy link

cypress bot commented Sep 30, 2025

spartacus    Run #50635

Run Properties:  status check passed Passed #50635  •  git commit b84f66da99 ℹ️: Merge 7629abbadb48a338af207ce424091cae96619de4 into 4712fa33e00eb6cf2a7c8a298c2f...
Project spartacus
Branch Review feature/CXSPA-10815
Run status status check passed Passed #50635
Run duration 03m 32s
Commit git commit b84f66da99 ℹ️: Merge 7629abbadb48a338af207ce424091cae96619de4 into 4712fa33e00eb6cf2a7c8a298c2f...
Committer Uros Lates
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 4
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 101
View all changes introduced in this branch ↗︎

rmch91
rmch91 previously approved these changes Nov 5, 2025
@github-actions github-actions bot marked this pull request as draft November 6, 2025 11:16
@uroslates uroslates marked this pull request as ready for review November 6, 2025 11:22
rmch91
rmch91 previously approved these changes Nov 6, 2025
@github-actions github-actions bot marked this pull request as draft November 6, 2025 15:23
@uroslates uroslates marked this pull request as ready for review November 6, 2025 15:29
@uroslates uroslates requested a review from rmch91 November 6, 2025 15:56
@uroslates uroslates merged commit d1a9b07 into develop Nov 7, 2025
40 checks passed
@uroslates uroslates deleted the feature/CXSPA-10815 branch November 7, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants