Skip to content

Commit bc973c1

Browse files
Merge master into feature/model-selection
2 parents 0653e6c + 9083350 commit bc973c1

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

packages/core/src/sagemakerunifiedstudio/explorer/nodes/sageMakerUnifiedStudioRootNode.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,9 @@ export const smusSignOutCommand = Commands.declare(
394394
await SmusAuthenticationPreferencesManager.clearConnectionPreferences(context)
395395
}
396396

397+
// Dispose smusAuthProvider
398+
authProvider.dispose()
399+
397400
// Show success message
398401
void vscode.window.showInformationMessage('Successfully signed out from SageMaker Unified Studio.')
399402

packages/core/src/test/sagemakerunifiedstudio/explorer/nodes/sageMakerUnifiedStudioRootNode.test.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,3 +1113,62 @@ describe('selectSMUSProject - Error Handling', function () {
11131113
})
11141114
})
11151115
})
1116+
1117+
describe('smusSignOutCommand', function () {
1118+
let mockAuthProvider: sinon.SinonStubbedInstance<SmusAuthenticationProvider>
1119+
let executeCommandStub: sinon.SinonStub
1120+
let fromContextStub: sinon.SinonStub
1121+
1122+
beforeEach(function () {
1123+
const testDomainId = 'test-domain-123'
1124+
1125+
mockAuthProvider = {
1126+
dispose: sinon.stub(),
1127+
isConnected: sinon.stub().returns(true),
1128+
isConnectionValid: sinon.stub().returns(true),
1129+
signOut: sinon.stub().resolves(),
1130+
getDomainId: sinon.stub().returns(testDomainId),
1131+
getDomainRegion: sinon.stub().returns('us-west-2'),
1132+
activeConnection: {
1133+
type: 'sso',
1134+
domainId: testDomainId,
1135+
ssoRegion: 'us-west-2',
1136+
domainUrl: 'https://test-domain.datazone.aws.amazon.com',
1137+
scopes: ['datazone:domain:access'],
1138+
},
1139+
onDidChange: sinon.stub().returns({ dispose: sinon.stub() }),
1140+
} as any
1141+
1142+
// Stub SmusAuthenticationProvider.fromContext to return our mock
1143+
fromContextStub = sinon.stub(SmusAuthenticationProvider, 'fromContext').returns(mockAuthProvider as any)
1144+
1145+
// Stub executeCommand to avoid actually calling refresh
1146+
executeCommandStub = sinon.stub(vscode.commands, 'executeCommand')
1147+
executeCommandStub.withArgs('aws.smus.rootView.refresh').resolves()
1148+
executeCommandStub.withArgs('aws.smus.signOut').callThrough()
1149+
})
1150+
1151+
afterEach(function () {
1152+
sinon.restore()
1153+
})
1154+
1155+
it('disposes auth provider when signing out', async function () {
1156+
await vscode.commands.executeCommand('aws.smus.signOut')
1157+
1158+
assert.ok(fromContextStub.calledOnce, 'fromContext should be called once')
1159+
1160+
assert.ok(mockAuthProvider.signOut.calledOnce, 'signOut should be called once')
1161+
1162+
assert.ok(mockAuthProvider.dispose.calledOnce, 'dispose should be called once')
1163+
1164+
const testWindow = getTestWindow()
1165+
assert.ok(
1166+
testWindow.shownMessages.some((msg) =>
1167+
msg.message.includes('Successfully signed out from SageMaker Unified Studio.')
1168+
),
1169+
'success message should be shown'
1170+
)
1171+
1172+
assert.ok(executeCommandStub.calledWith('aws.smus.rootView.refresh'), 'refresh command should be called')
1173+
})
1174+
})

0 commit comments

Comments
 (0)