Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/library/__tests__/credentials.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ describe('credentials', () => {
expect(result).toBeNull();
});

it('should return null and clear storage when credentials are expired', async () => {
it('should return expired credentials to let AWS reject them', async () => {
const getSpy = chrome.storage.local.get as jest.Mock;
getSpy.mockImplementationOnce(() => Promise.resolve({ awsCredentials: expiredCredentials }));

const result = await getValidCredentials();
expect(result).toBeNull();
expect(chrome.storage.local.remove).toHaveBeenCalledWith('awsCredentials');
expect(result).toEqual(expiredCredentials);
expect(chrome.storage.local.remove).not.toHaveBeenCalled();
});

it('should return null when credentials are incomplete', async () => {
Expand Down
8 changes: 1 addition & 7 deletions src/library/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,14 @@
return null;
}

if (

Check failure on line 24 in src/library/credentials.ts

View workflow job for this annotation

GitHub Actions / build

Replace `⏎····!credentials.accessKeyId·||⏎····!credentials.secretAccessKey·||⏎····!credentials.sessionToken⏎··` with `!credentials.accessKeyId·||·!credentials.secretAccessKey·||·!credentials.sessionToken`
!credentials.accessKeyId ||
!credentials.secretAccessKey ||
!credentials.sessionToken ||
!credentials.expiration
!credentials.sessionToken
) {
return null;
}

if (areCredentialsExpired(credentials.expiration)) {
await chrome.storage.local.remove('awsCredentials');
return null;
}

return credentials;
}

Expand Down
2 changes: 1 addition & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ document.addEventListener('DOMContentLoaded', async () => {

const awsCredentials = await getValidCredentials();
if (!awsCredentials) {
showToastMessage('warning', 'Session expired — please sign in to AWS again.');
showToastMessage('warning', 'No AWS credentials found. Please sign in to AWS first.');
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function setupEventListeners(): void {
const awsCredentials = await getValidCredentials();

if (!awsCredentials) {
showToastMessage('warning', 'Session expired — please sign in to AWS again.');
showToastMessage('warning', 'No AWS credentials found. Please sign in to AWS first.');
return;
}

Expand Down
Loading