Skip to content

Commit 76a38f1

Browse files
authored
fix(connection-form): include OIDC in $external auth mechanism list COMPASS-7512 (#5217)
1 parent c06727f commit 76a38f1

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

packages/compass-e2e-tests/tests/connection-form.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ describe('Connection form', function () {
665665

666666
await browser.setConnectFormState(expectedState);
667667
expect(await browser.getConnectFormConnectionString(true)).to.equal(
668-
connectionString
668+
`${connectionString}&authSource=%24external`
669669
);
670670
});
671671

packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-oidc.spec.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const openAuthOIDC = async () => {
5656
const openOptionsAccordion = () =>
5757
fireEvent.click(screen.getByText('OIDC Options'));
5858

59-
describe('AuthenticationOIDC Connection Form', function () {
59+
describe('Authentication OIDC Connection Form', function () {
6060
let expectToConnectWith;
6161
let connectSpy: sinon.SinonSpy;
6262

@@ -100,7 +100,7 @@ describe('AuthenticationOIDC Connection Form', function () {
100100

101101
await expectToConnectWith({
102102
connectionString:
103-
'mongodb://goodSandwich@localhost:27017/?authMechanism=MONGODB-OIDC',
103+
'mongodb://goodSandwich@localhost:27017/?authMechanism=MONGODB-OIDC&authSource=%24external',
104104
});
105105
});
106106

@@ -111,7 +111,7 @@ describe('AuthenticationOIDC Connection Form', function () {
111111

112112
await expectToConnectWith({
113113
connectionString:
114-
'mongodb://localhost:27017/?authMechanism=MONGODB-OIDC',
114+
'mongodb://localhost:27017/?authMechanism=MONGODB-OIDC&authSource=%24external',
115115
oidc: {
116116
redirectURI: 'goodSandwiches',
117117
},
@@ -122,7 +122,7 @@ describe('AuthenticationOIDC Connection Form', function () {
122122
fireEvent.click(screen.getByText('Consider Target Endpoint Trusted'));
123123
await expectToConnectWith({
124124
connectionString:
125-
'mongodb://localhost:27017/?authMechanism=MONGODB-OIDC',
125+
'mongodb://localhost:27017/?authMechanism=MONGODB-OIDC&authSource=%24external',
126126
oidc: {
127127
enableUntrustedEndpoints: true,
128128
},
@@ -134,7 +134,7 @@ describe('AuthenticationOIDC Connection Form', function () {
134134
fireEvent.click(screen.getByText('Consider Target Endpoint Trusted'));
135135
await expectToConnectWith({
136136
connectionString:
137-
'mongodb://localhost:27017/?authMechanism=MONGODB-OIDC',
137+
'mongodb://localhost:27017/?authMechanism=MONGODB-OIDC&authSource=%24external',
138138
oidc: {},
139139
});
140140
});
@@ -153,7 +153,7 @@ describe('AuthenticationOIDC Connection Form', function () {
153153
fireEvent.click(screen.getByText(deviceAuthFlowText));
154154
await expectToConnectWith({
155155
connectionString:
156-
'mongodb://localhost:27017/?authMechanism=MONGODB-OIDC',
156+
'mongodb://localhost:27017/?authMechanism=MONGODB-OIDC&authSource=%24external',
157157
oidc: {
158158
allowedFlows: ['auth-code', 'device-auth'],
159159
},
@@ -165,7 +165,7 @@ describe('AuthenticationOIDC Connection Form', function () {
165165
fireEvent.click(screen.getByText(deviceAuthFlowText));
166166
await expectToConnectWith({
167167
connectionString:
168-
'mongodb://localhost:27017/?authMechanism=MONGODB-OIDC',
168+
'mongodb://localhost:27017/?authMechanism=MONGODB-OIDC&authSource=%24external',
169169
oidc: {
170170
allowedFlows: ['auth-code'],
171171
},

packages/connection-form/src/utils/authentication-handler.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ describe('Authentication Handler', function () {
225225
'GSSAPI',
226226
'PLAIN',
227227
'MONGODB-X509',
228+
'MONGODB-OIDC',
228229
];
229230

230231
for (const authMechanism of externalAuthMechanisms) {

packages/connection-form/src/utils/authentication-handler.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,13 @@ export function handleUpdateAuthMechanism({
6666
if (action.authMechanism) {
6767
updatedSearchParams.set('authMechanism', action.authMechanism);
6868
if (
69-
['MONGODB-AWS', 'GSSAPI', 'PLAIN', 'MONGODB-X509'].includes(
70-
action.authMechanism
71-
)
69+
[
70+
'MONGODB-AWS',
71+
'GSSAPI',
72+
'PLAIN',
73+
'MONGODB-X509',
74+
'MONGODB-OIDC',
75+
].includes(action.authMechanism)
7276
) {
7377
updatedSearchParams.set('authSource', '$external');
7478
}

0 commit comments

Comments
 (0)