techdocs: moar config tests

Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
Vincenzo Scamporlino
2025-12-04 10:19:34 +01:00
parent b5914dfe6d
commit 09af448338
@@ -270,6 +270,59 @@ describe('AwsS3Publish', () => {
expect(getCredProviderMock).toHaveBeenCalledTimes(1);
});
it('should use aws.accounts over integrations.awsS3 if both are provided', async () => {
await jest.isolateModulesAsync(async () => {
jest.doMock('@aws-sdk/client-s3', () => ({
...jest.requireActual('@aws-sdk/client-s3'),
S3Client: jest.fn(),
}));
const { S3Client: MockS3Client } = require('@aws-sdk/client-s3');
const { AwsS3Publish: IsolatedAwsS3Publish } = require('./awsS3');
const mockConfig = new ConfigReader({
techdocs: {
publisher: {
type: 'awsS3',
awsS3: {
accountId: '111111111111',
bucketName: 'bucketName',
bucketRootPath: '/',
},
},
},
integrations: {
awsS3: [
{
accessKeyId: 'access-key-from-integrations',
secretAccessKey: 'secret-access-key-from-integrations',
},
],
},
aws: {
accounts: [
{
accountId: '111111111111',
accessKeyId: 'access-key-from-aws',
secretAccessKey: 'secret-access-key-from-aws',
},
],
},
});
await IsolatedAwsS3Publish.fromConfig(mockConfig, logger);
expect(getCredProviderMock).toHaveBeenCalledTimes(0);
expect(MockS3Client).toHaveBeenCalledTimes(1);
await expect(
MockS3Client.mock.calls[0][0]!.credentialDefaultProvider!(
undefined!,
)(),
).resolves.toEqual({
accessKeyId: 'access-key-from-aws',
secretAccessKey: 'secret-access-key-from-aws',
});
});
});
it('should use awsS3.credentials if they are provided', async () => {
await jest.isolateModulesAsync(async () => {
jest.doMock('@aws-sdk/client-s3', () => ({