fix: 🐛 OIDC authentications not properly showing username (#2930)

* fix: 🐛 properly show username for oidc auth method in user menu

* test: 💍 fix admin ui tests

* test: 💍 fix desktop ui tests

* refactor: 💡 admin to not store username in authenticated object

* refactor: 💡 use getter in app controller

* test: 💍 POC for how we could update our tests to use auth account

* refactor: 💡 remove unused service

* test: 💍 fix all tests in ui/admin

* test: 💍 revert one change

* refactor: 💡 update ui/desktop w/ feedback + fix tests

* refactor: 💡 add in error handling

* refactor: 💡 cleanup unused service

* test: 💍 fix e2e test selector

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-17231
This commit is contained in:
Lisbet Alvarez authored and GitHub committed 2025-10-30 12:49:30 -07:00
1 parent 838bc37243
commit 72f7c8a92d
195 files changed
+720 -1112

No files matched your search

@@ -6,17 +6,14 @@
import { module, test } from 'qunit';
import { visit, currentURL, click, fillIn, select } from '@ember/test-helpers';
import { setupApplicationTest } from 'admin/tests/helpers';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { setupSqlite } from 'api/test-support/helpers/sqlite';
import { Response } from 'miragejs';
import { authenticateSession } from 'ember-simple-auth/test-support';
import * as commonSelectors from 'admin/tests/helpers/selectors';
import * as selectors from './selectors';
import { setRunOptions } from 'ember-a11y-testing/test-support';
module('Acceptance | auth-methods | create', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
setupSqlite(hooks);
let getAuthMethodsCount;
@@ -24,7 +21,6 @@ module('Acceptance | auth-methods | create', function (hooks) {
const instances = {
scopes: {
global: null,
org: null,
project: null,
},
@@ -41,7 +37,6 @@ module('Acceptance | auth-methods | create', function (hooks) {
};
hooks.beforeEach(async function () {
await authenticateSession({});
instances.orgScope = this.server.create(
'scope',
{
@@ -6,10 +6,8 @@
import { module, test } from 'qunit';
import { visit, click, currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'admin/tests/helpers';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { setupSqlite } from 'api/test-support/helpers/sqlite';
import { Response } from 'miragejs';
import { authenticateSession } from 'ember-simple-auth/test-support';
import { TYPE_AUTH_METHOD_LDAP } from 'api/models/auth-method';
import * as commonSelectors from 'admin/tests/helpers/selectors';
import * as selectors from './selectors';
@@ -17,7 +15,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support';
module('Acceptance | auth-methods | delete', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
setupSqlite(hooks);
let featuresService;
@@ -25,7 +22,6 @@ module('Acceptance | auth-methods | delete', function (hooks) {
const instances = {
scopes: {
global: null,
org: null,
},
authMethod: null,
@@ -40,8 +36,6 @@ module('Acceptance | auth-methods | delete', function (hooks) {
hooks.beforeEach(async function () {
// Setup Mirage mock resources for this test
await authenticateSession({ username: 'admin' });
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create('scope', {
type: 'org',
scope: { id: 'global', type: 'global' },
@@ -6,9 +6,7 @@
import { module, test } from 'qunit';
import { visit, click, waitFor, fillIn, currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'admin/tests/helpers';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { setupSqlite } from 'api/test-support/helpers/sqlite';
import { authenticateSession } from 'ember-simple-auth/test-support';
import { faker } from '@faker-js/faker';
import {
TYPE_AUTH_METHOD_PASSWORD,
@@ -20,12 +18,10 @@ import { setRunOptions } from 'ember-a11y-testing/test-support';
module('Acceptance | auth-methods | list', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
setupSqlite(hooks);
const instances = {
scopes: {
global: null,
org: null,
},
passwordAuthMethod: null,
@@ -41,7 +37,6 @@ module('Acceptance | auth-methods | list', function (hooks) {
};
hooks.beforeEach(async function () {
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create(
'scope',
{
@@ -63,8 +58,6 @@ module('Acceptance | auth-methods | list', function (hooks) {
urls.authMethods = `/scopes/${instances.scopes.org.id}/auth-methods`;
urls.passwordAuthMethod = `${urls.authMethods}/${instances.passwordAuthMethod.id}`;
urls.oidcAuthMethod = `${urls.authMethods}/${instances.oidcAuthMethod.id}`;
await authenticateSession({});
});
test('users can navigate to auth methods with proper authorization', async function (assert) {
@@ -6,19 +6,15 @@
import { module, test } from 'qunit';
import { visit, currentURL, click } from '@ember/test-helpers';
import { setupApplicationTest } from 'admin/tests/helpers';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { authenticateSession } from 'ember-simple-auth/test-support';
import { TYPE_AUTH_METHOD_OIDC } from 'api/models/auth-method';
import * as commonSelectors from 'admin/tests/helpers/selectors';
import * as selectors from './selectors';
module('Acceptance | auth-methods | oidc', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
const instances = {
scopes: {
global: null,
org: null,
},
authMethod: null,
@@ -30,8 +26,6 @@ module('Acceptance | auth-methods | oidc', function (hooks) {
};
hooks.beforeEach(async function () {
await authenticateSession({ username: 'admin' });
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create('scope', {
type: 'org',
scope: { id: 'global', type: 'global' },
@@ -6,9 +6,7 @@
import { module, test } from 'qunit';
import { visit, currentURL, click } from '@ember/test-helpers';
import { setupApplicationTest } from 'admin/tests/helpers';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { setupSqlite } from 'api/test-support/helpers/sqlite';
import { authenticateSession } from 'ember-simple-auth/test-support';
import {
TYPE_AUTH_METHOD_LDAP,
TYPE_AUTH_METHOD_OIDC,
@@ -20,7 +18,6 @@ import { setRunOptions } from 'ember-a11y-testing/test-support';
module('Acceptance | auth-methods | read', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
setupSqlite(hooks);
const instances = {
@@ -44,8 +41,7 @@ module('Acceptance | auth-methods | read', function (hooks) {
hooks.beforeEach(async function () {
// Setup Mirage mock resources for this test
await authenticateSession({ username: 'admin' });
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.global = this.server.schema.scopes.find('global');
instances.scopes.org = this.server.create('scope', {
type: 'org',
scope: { id: 'global', type: 'global' },
@@ -6,10 +6,8 @@
import { module, test } from 'qunit';
import { visit, click, fillIn, select, findAll } from '@ember/test-helpers';
import { setupApplicationTest } from 'admin/tests/helpers';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { setupSqlite } from 'api/test-support/helpers/sqlite';
import { Response } from 'miragejs';
import { authenticateSession } from 'ember-simple-auth/test-support';
import {
TYPE_AUTH_METHOD_OIDC,
TYPE_AUTH_METHOD_LDAP,
@@ -20,14 +18,12 @@ import { setRunOptions } from 'ember-a11y-testing/test-support';
module('Acceptance | auth-methods | update', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
setupSqlite(hooks);
let featuresService;
const instances = {
scopes: {
global: null,
org: null,
},
authMethod: null,
@@ -43,8 +39,6 @@ module('Acceptance | auth-methods | update', function (hooks) {
hooks.beforeEach(async function () {
// Setup Mirage mock resources for this test
await authenticateSession({ username: 'admin' });
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.scopes.org = this.server.create('scope', {
type: 'org',
scope: { id: 'global', type: 'global' },
@@ -89,7 +83,7 @@ module('Acceptance | auth-methods | update', function (hooks) {
await click(commonSelectors.SAVE_BTN);
assert.strictEqual(
this.server.schema.authMethods.first().name,
this.server.schema.authMethods.find(instances.authMethod.id).name,
commonSelectors.FIELD_NAME_VALUE,
);
});