Skip to content

Commit

Permalink
Merge pull request #339 from opencomponents/require-accountname
Browse files Browse the repository at this point in the history
require accountname
  • Loading branch information
ricardo-devis-agullo authored Jun 18, 2024
2 parents a4a463b + 54d9782 commit 4bce902
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
24 changes: 17 additions & 7 deletions packages/oc-azure-storage-adapter/__test__/azure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ test('should expose the correct methods', () => {

test('validate valid conf without credentials', () => {
const options = {
accountName: 'name',
publicContainerName: 'pubcon',
privateContainerName: 'privcon',
path: 'path',
Expand All @@ -58,20 +59,29 @@ test('validate valid conf with credentials', () => {
});

test('validate missing public container', () => {
const options = {
privateContainerName: 'privcon'
};
// @ts-expect-error Bad config
const client = azure(options);
const client = azure({
accountName: 'name',
privateContainerName: 'privcon'
});
expect(client.isValid()).toBe(false);
});

test('validate missing private container', () => {
const options = {
// @ts-expect-error Bad config
const client = azure({
accountName: 'name',
publicContainerName: 'pubcon'
};
});
expect(client.isValid()).toBe(false);
});

test('validate missing name', () => {
// @ts-expect-error Bad config
const client = azure(options);
const client = azure({
publicContainerName: 'pubcon',
privateContainerName: 'privcon'
});
expect(client.isValid()).toBe(false);
});

Expand Down
8 changes: 6 additions & 2 deletions packages/oc-azure-storage-adapter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ async function streamToBuffer(readableStream: NodeJS.ReadableStream) {
export interface AzureConfig extends StorageAdapterBaseConfig {
publicContainerName: string;
privateContainerName: string;
accountName?: string;
accountName: string;
accountKey?: string;
}

export default function azureAdapter(conf: AzureConfig): StorageAdapter {
const isValid = () => {
if (!conf.publicContainerName || !conf.privateContainerName) {
if (
!conf.publicContainerName ||
!conf.privateContainerName ||
!conf.accountName
) {
return false;
}
return true;
Expand Down

0 comments on commit 4bce902

Please sign in to comment.