Skip to content

Commit

Permalink
Merge pull request #128 from Flydiverny/aws-sdk-v3
Browse files Browse the repository at this point in the history
fix(ecr): only set credentials if username & password if specified, refactor to use aws-sdk v3
  • Loading branch information
crazy-max authored Dec 20, 2021
2 parents d9927c4 + 5885569 commit 1d7d864
Show file tree
Hide file tree
Showing 5 changed files with 26,615 additions and 37,189 deletions.
32 changes: 14 additions & 18 deletions __tests__/aws.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {AuthorizationData} from '@aws-sdk/client-ecr';
import * as aws from '../src/aws';
import {AuthorizationData} from 'aws-sdk/clients/ecr';

describe('isECR', () => {
test.each([
Expand Down Expand Up @@ -55,11 +55,15 @@ describe('getAccountIDs', () => {

const mockEcrGetAuthToken = jest.fn();
const mockEcrPublicGetAuthToken = jest.fn();
jest.mock('aws-sdk', () => {
jest.mock('@aws-sdk/client-ecr', () => {
return {
ECR: jest.fn(() => ({
getAuthorizationToken: mockEcrGetAuthToken
})),
}))
};
});
jest.mock('@aws-sdk/client-ecr-public', () => {
return {
ECRPUBLIC: jest.fn(() => ({
getAuthorizationToken: mockEcrPublicGetAuthToken
}))
Expand Down Expand Up @@ -126,15 +130,11 @@ describe('getRegistriesData', () => {
const authData: AuthorizationData[] = [];
if (accountIDs.length == 0) {
mockEcrPublicGetAuthToken.mockImplementation(() => {
return {
promise() {
return Promise.resolve({
authorizationData: {
authorizationToken: Buffer.from(`AWS:world`).toString('base64'),
}
});
return Promise.resolve({
authorizationData: {
authorizationToken: Buffer.from(`AWS:world`).toString('base64'),
}
};
});
});
} else {
aws.getAccountIDs(registry).forEach(accountID => {
Expand All @@ -144,13 +144,9 @@ describe('getRegistriesData', () => {
});
});
mockEcrGetAuthToken.mockImplementation(() => {
return {
promise() {
return Promise.resolve({
authorizationData: authData
});
}
};
return Promise.resolve({
authorizationData: authData
});
});
}
const regData = await aws.getRegistriesData(registry);
Expand Down
Loading

0 comments on commit 1d7d864

Please sign in to comment.