-
Notifications
You must be signed in to change notification settings - Fork 599
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client-s3): add useArnRegion config (#1420)
* feat(node-config-provider): add a loader for configs from config files and env * chore(node-config-provider): add preferred config file to load * chore(node-config-provider): env and config option can only be a getter function * feat(middleware-bucket-endppoint): add useArnRegion config to bucket endpoint middleware * chore: codegen s3 useArnRegion config * feat(client-s3): codegen S3 client with useArnAgent config
- Loading branch information
1 parent
f6f700d
commit 40e600e
Showing
24 changed files
with
898 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
packages/middleware-bucket-endpoint/src/configuration.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { | ||
NODE_USE_ARN_REGION_CONFIG_OPTIONS as loadOptions, | ||
NODE_USE_ARN_REGION_ENV_NAME, | ||
NODE_USE_ARN_REGION_INI_NAME, | ||
} from "./configurations"; | ||
describe("Node useArnRegion config loader", () => { | ||
describe("environment variable selector", () => { | ||
const env: { [NODE_USE_ARN_REGION_ENV_NAME]: any } = {} as any; | ||
|
||
beforeEach(() => { | ||
delete env[NODE_USE_ARN_REGION_ENV_NAME]; | ||
}); | ||
|
||
it(`should return undefined if the environment variable doesn't have ${NODE_USE_ARN_REGION_ENV_NAME}`, () => { | ||
expect(loadOptions.environmentVariableSelector(env)).toBeUndefined(); | ||
}); | ||
|
||
[ | ||
{ envValue: "true", parsed: true }, | ||
{ envValue: "false", parsed: false }, | ||
].forEach(({ envValue, parsed }) => { | ||
it(`should return boolean if the environment variable ${NODE_USE_ARN_REGION_ENV_NAME} is ${envValue}`, () => { | ||
env[NODE_USE_ARN_REGION_ENV_NAME] = envValue; | ||
expect(loadOptions.environmentVariableSelector(env)).toBe(parsed); | ||
}); | ||
}); | ||
|
||
["0", "1", "yes", "no", undefined, null, void 0, ""].forEach((envValue) => { | ||
it(`should throw if the environment variable ${NODE_USE_ARN_REGION_ENV_NAME} is ${envValue}`, () => { | ||
env[NODE_USE_ARN_REGION_ENV_NAME] = envValue as any; | ||
expect(() => loadOptions.environmentVariableSelector(env)).toThrow( | ||
`Cannot load env ${NODE_USE_ARN_REGION_ENV_NAME}. Expected "true" or "false", got ${envValue}.` | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("shared INI files selector", () => { | ||
const profileContent: { [NODE_USE_ARN_REGION_INI_NAME]: any } = {} as any; | ||
|
||
beforeEach(() => { | ||
delete profileContent[NODE_USE_ARN_REGION_INI_NAME]; | ||
}); | ||
|
||
it(`should return undefined if shared config profile doesn't have ${NODE_USE_ARN_REGION_INI_NAME}`, () => { | ||
expect(loadOptions.configFileSelector(profileContent)).toBeUndefined(); | ||
}); | ||
|
||
[ | ||
{ value: "true", parsed: true }, | ||
{ value: "false", parsed: false }, | ||
].forEach(({ value, parsed }) => { | ||
it(`should return boolean if the shared config profile ${NODE_USE_ARN_REGION_INI_NAME} is ${value}`, () => { | ||
profileContent[NODE_USE_ARN_REGION_INI_NAME] = value; | ||
expect(loadOptions.configFileSelector(profileContent)).toBe(parsed); | ||
}); | ||
}); | ||
|
||
["0", "1", "yes", "no", undefined, null, void 0, ""].forEach((value) => { | ||
it(`should throw if the shared config profile ${NODE_USE_ARN_REGION_INI_NAME} is ${value}`, () => { | ||
profileContent[NODE_USE_ARN_REGION_INI_NAME] = value as any; | ||
expect(() => loadOptions.configFileSelector(profileContent)).toThrow( | ||
`Cannot load shared config entry ${NODE_USE_ARN_REGION_INI_NAME}. Expected "true" or "false", got ${value}.` | ||
); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.