Skip to content

Conversation

@brunto
Copy link
Collaborator

@brunto brunto commented May 19, 2025

This pull request introduces several changes across the codebase, primarily focusing on enhancing Single Sign-On (SSO) functionality, improving Cypress test configurations, and adding minor fixes and enhancements. Below is a categorized summary of the most significant changes:

SSO Implementation and Authentication Enhancements:

  • Added support for SSO in the AuthService, including methods to handle SSO login (loginSSO) and logout, and a new ssoEnabled property to track SSO availability. The clearCurrentUser method was introduced to centralize user cleanup logic. [1] [2] [3] [4]
  • Updated the SignInComponent to display an SSO login option when SSO is enabled and to handle SSO login via a new loginSSO method. [1] [2] [3]
  • Modified several components (PiaComponent, StructureComponent, ExampleComponent, etc.) to subscribe to AuthService.currentUser for initializing data after authentication. [1] [2] [3]

Cypress Test Improvements:

  • Disabled test isolation in cypress.config.ts to allow shared state between tests.
  • Adjusted Cypress tests to include forced clicks for certain elements and added a wait time for navigation in custom commands. [1] [2]

Codebase Enhancements and Refactoring:

  • Replaced redundant logout calls with the new clearCurrentUser method in AuthService for consistency.
  • Removed unused imports, such as Lodash from home.component.ts, to clean up the codebase.

Minor Fixes and UI Updates:

  • Updated the header component to check for access_type when rendering technical access elements.
  • Added an import for AuthService in multiple components to support the new SSO-related functionality. [1] [2] [3]

These changes improve the authentication flow, enhance test stability, and clean up the codebase for better maintainability.

@brunto brunto requested review from Copilot and kevin-atnos May 19, 2025 20:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request implements SSO functionality and related authentication enhancements along with updates to test configurations and minor code refactoring for better maintainability.

  • Introduces SSO support in AuthService, including new methods (loginSSO, clearCurrentUser) and state management.
  • Updates various components (SignIn, Pia, Users, Structure, Example, URL) to use the new SSO and authentication flows.
  • Adjusts Cypress tests and commands to improve stability and remove unused imports.

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/app/shared/components/header/header.component.html Added check for the access_type property in rendering technical elements.
src/app/services/pia.service.ts Subscribes to currentUser for conditional loading of example Pia data.
src/app/services/auth.service.ts Enhanced SSO support and refactored logout logic using clearCurrentUser.
src/app/modules/users/users.component.ts Subscribes to currentUser to trigger user loading logic.
src/app/modules/structure/structure.component.ts Injected AuthService and added a subscription; contains an empty ngOnInit.
src/app/modules/settings/url/url.component.ts Updates ssoEnabled flag from introspection response.
src/app/modules/pia/pia.component.ts Uses a subscription to currentUser to conditionally load Pia data.
src/app/modules/pia/example/example.component.ts Injected AuthService and updated subscription logic.
src/app/modules/home/home.component.ts Removed an unused lodash import.
src/app/modules/home/forms/sign-in/sign-in.component.ts Added SSO login function and updated dependency injection for AuthService.
src/app/modules/home/forms/sign-in/sign-in.component.html Added a link to trigger SSO login when enabled.
src/app/modules/entries/forms/new-pia/new-pia.component.ts Updated subscription to currentUser for structure list loading.
src/app/modules/base/base.component.ts Added import for AuthService to support SSO-related functionality.
cypress/support/commands.js Introduced an explicit wait in navigation command.
cypress/e2e/pia-angular/entries/entries_table.spec.js Adjusted forced click usage for more robust test interactions.
cypress/e2e/pia-angular/dpo/dpo_and_pia_validation.spec.js Minor update; removal of an unused variable from test logic.
cypress.config.ts Disabled test isolation to allow shared state between tests.

if (!examples) {
await this.importData(piaExample, 'EXAMPLE', false, true);
this.authService.currentUser.subscribe({
complete: () => {
Copy link

Copilot AI May 19, 2025

Choose a reason for hiding this comment

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

Using the 'complete' callback on the subscription to currentUser may not trigger if the observable never completes; consider using the 'next' callback or an operator like 'first' to ensure the initialization logic runs.

Suggested change
complete: () => {
next: () => {

Copilot uses AI. Check for mistakes.
) {
this.loadUsers();
this.authService.currentUser.subscribe({
complete: () => {
Copy link

Copilot AI May 19, 2025

Choose a reason for hiding this comment

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

The use of the 'complete' callback here might not execute if the observable remains open; consider switching to the 'next' callback to ensure loadUsers() is called as expected.

Suggested change
complete: () => {
next: () => {

Copilot uses AI. Check for mistakes.
private authService: AuthService
) {
this.authService.currentUser.subscribe({
complete: () => {
Copy link

Copilot AI May 19, 2025

Choose a reason for hiding this comment

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

Relying on the 'complete' callback for executing initialization logic may not work as intended with a BehaviorSubject; consider using the 'next' callback or appropriate operators to ensure the code is executed.

Suggested change
complete: () => {
next: () => {

Copilot uses AI. Check for mistakes.
}

this.authService.currentUser.subscribe({
complete: () => {
Copy link

Copilot AI May 19, 2025

Choose a reason for hiding this comment

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

Using 'complete' in the subscription may never invoke the contained logic; using the 'next' callback or 'first' operator would provide more reliable initialization of Pia data.

Suggested change
complete: () => {
next: () => {

Copilot uses AI. Check for mistakes.
public piaService: PiaService
) {
this.authService.currentUser.subscribe({
complete: () => {
Copy link

Copilot AI May 19, 2025

Choose a reason for hiding this comment

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

The subscription uses a 'complete' callback which might not be triggered; consider using the 'next' callback to ensure that the Pia retrieval code executes as expected.

Suggested change
complete: () => {
next: () => {

Copilot uses AI. Check for mistakes.
console.error(err);
});
this.authService.currentUser.subscribe({
complete: () => {
Copy link

Copilot AI May 19, 2025

Choose a reason for hiding this comment

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

Relying on the 'complete' callback could lead to missed initialization if the observable stays active; switching to the 'next' callback would ensure that the structure list is loaded reliably.

Suggested change
complete: () => {
next: () => {

Copilot uses AI. Check for mistakes.
Comment on lines +68 to +79
this.subscription = this.measureService.behaviorSubject.subscribe(
val => {
this.measureToRemoveFromTags = val;
}
);
}
});
}

async ngOnInit(): Promise<void> {}

Copy link

Copilot AI May 19, 2025

Choose a reason for hiding this comment

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

[nitpick] An empty ngOnInit method may indicate that initialization logic is split between the constructor and lifecycle hooks; consider consolidating the logic in ngOnInit for clarity and standard Angular practice.

Suggested change
this.subscription = this.measureService.behaviorSubject.subscribe(
val => {
this.measureToRemoveFromTags = val;
}
);
}
});
}
async ngOnInit(): Promise<void> {}
this.subscription = this.measureService.behaviorSubject.subscribe(
val => {
this.measureToRemoveFromTags = val;
}
);
}
});
}

Copilot uses AI. Check for mistakes.
@brunto brunto force-pushed the sso branch 2 times, most recently from 5532130 to 10cca94 Compare December 15, 2025 15:22
# Conflicts:
#	src/app/modules/pia/example/example.component.ts
#	src/app/services/auth.service.ts
#	src/app/shared/components/header/header.component.html
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.

3 participants