Skip to content

Commit fa3f3a5

Browse files
kylebarrondplewis
authored andcommitted
Correctly use endpoint in s3overrides (#79)
* Correctly use endpoint in s3overrides * Add endpoint override test * Fix endpoint test Apparently the constructor function exists within the Endpoint object after calling AWS.Endpoint() but not once passed through S3Adapter, but this doesn't matter anyways.
1 parent 866073a commit fa3f3a5

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/optionsFromArguments.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const optionsFromArguments = function optionsFromArguments(args) {
6464
options.signatureVersion = otherOptions.signatureVersion;
6565
options.globalCacheControl = otherOptions.globalCacheControl;
6666
options.ServerSideEncryption = otherOptions.ServerSideEncryption;
67+
s3overrides = otherOptions.s3overrides;
6768
}
6869
} else if (args.length === 1) {
6970
Object.assign(options, stringOrOptions);

spec/test.spec.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const AWS = require('aws-sdk');
12
const config = require('config');
23
const filesAdapterTests = require('parse-server-conformance-tests').files;
34
const S3Adapter = require('../index.js');
@@ -133,6 +134,25 @@ describe('S3Adapter tests', () => {
133134
expect(s3._bucketPrefix).toEqual('test/');
134135
});
135136

137+
it('should accept endpoint as an override option in args', () => {
138+
const otherEndpoint = new AWS.Endpoint('nyc3.digitaloceanspaces.com');
139+
const confObj = {
140+
bucketPrefix: 'test/',
141+
bucket: 'bucket-1',
142+
secretKey: 'secret-1',
143+
accessKey: 'key-1',
144+
s3overrides: { endpoint: otherEndpoint },
145+
};
146+
const s3 = new S3Adapter(confObj);
147+
expect(s3._s3Client.endpoint.protocol).toEqual(otherEndpoint.protocol);
148+
expect(s3._s3Client.endpoint.host).toEqual(otherEndpoint.host);
149+
expect(s3._s3Client.endpoint.port).toEqual(otherEndpoint.port);
150+
expect(s3._s3Client.endpoint.hostname).toEqual(otherEndpoint.hostname);
151+
expect(s3._s3Client.endpoint.pathname).toEqual(otherEndpoint.pathname);
152+
expect(s3._s3Client.endpoint.path).toEqual(otherEndpoint.path);
153+
expect(s3._s3Client.endpoint.href).toEqual(otherEndpoint.href);
154+
});
155+
136156
it('should accept options and overrides as args', () => {
137157
const confObj = {
138158
bucketPrefix: 'test/', bucket: 'bucket-1', secretKey: 'secret-1', accessKey: 'key-1',

0 commit comments

Comments
 (0)