mirror of
https://github.com/docker/login-action.git
synced 2025-04-22 14:46:37 +02:00
refactor: use v3 sdk
Signed-off-by: Markus Maga <markus@maga.se>
This commit is contained in:
parent
d9927c4142
commit
58855695bb
5 changed files with 28595 additions and 39169 deletions
|
@ -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([
|
||||
|
@ -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
|
||||
}))
|
||||
|
@ -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 => {
|
||||
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue