Skip to content

Commit 4645f60

Browse files
committed
update agent
1 parent 64c9e0f commit 4645f60

File tree

5 files changed

+6
-72
lines changed

5 files changed

+6
-72
lines changed

src/sdk/namespace_s3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ class NamespaceS3 {
331331
const request = {
332332
Bucket: this.bucket,
333333
Key: params.key,
334-
Body: await params.source_stream.pipe(count_stream),
334+
Body: params.source_stream.pipe(count_stream),
335335
ContentLength: params.size,
336336
ContentType: params.content_type,
337337
ContentMD5: params.md5_b64,

src/sdk/object_sdk.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ class ObjectSDK {
466466
endpoint: r.endpoint,
467467
aws_sts_arn: r.aws_sts_arn,
468468
credentials: {
469-
accessKeyId: r.access_key.unwrap(),
469+
accessKeyId: r.access_key.unwrap(),
470470
secretAccessKey: r.secret_key.unwrap(),
471471
},
472472
region: config.DEFAULT_REGION, // SDKv3 needs region

src/test/integration_tests/api/s3/test_namespace_auth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ mocha.describe('Namespace Auth', function() {
3737
forcePathStyle: true,
3838
region: config.DEFAULT_REGION,
3939
requestHandler: new NodeHttpHandler({
40-
httpAgent: http_utils.get_unsecured_agent(coretest.get_http_address())
40+
httpAgent: http_utils.get_unsecured_agent(coretest.get_http_address())
4141
}),
4242
});
4343
coretest.log('S3 CONFIG', s3.config);

src/test/integration_tests/api/s3/test_s3_ops.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const mocha = require('mocha');
1515
const assert = require('assert');
1616
const P = require('../../../../util/promise');
1717
const azure_storage = require('@azure/storage-blob');
18+
const noobaa_s3_client = require('../../../../sdk/noobaa_s3_client/noobaa_s3_client');
1819

1920
// If any of these variables are not defined,
2021
// use the noobaa endpoint to create buckets
@@ -71,7 +72,7 @@ mocha.describe('s3_ops', function() {
7172
mocha.before(async function() {
7273
const self = this;
7374
self.timeout(60000);
74-
75+
const agent = noobaa_s3_client.get_requestHandler_with_suitable_agent(coretest.get_http_address());
7576
const account_info = await rpc_client.account.read_account({ email: EMAIL, });
7677
s3_client_params = {
7778
endpoint: coretest.get_http_address(),
@@ -81,9 +82,7 @@ mocha.describe('s3_ops', function() {
8182
},
8283
forcePathStyle: true,
8384
region: config.DEFAULT_REGION,
84-
requestHandler: new NodeHttpHandler({
85-
httpAgent: http_utils.get_unsecured_agent(coretest.get_http_address()),
86-
}),
85+
requestHandler: { agent },
8786
};
8887
s3 = new S3(s3_client_params);
8988
coretest.log('S3 CONFIG', s3.config);

src/test/unit_tests/util_functions_tests/test_cloud_utils.js

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
const mocha = require('mocha');
55
const assert = require('assert');
66
const sinon = require('sinon');
7-
const AWS = require('aws-sdk');
87
const cloud_utils = require('../../../util/cloud_utils');
98
const dbg = require('../../../util/debug_module')(__filename);
109
const { STSClient } = require('@aws-sdk/client-sts');
@@ -15,71 +14,7 @@ const fakeAccessKeyId = "fakeAccessKeyId";
1514
const fakeSecretAccessKey = "fakeSecretAccessKey";
1615
const fakeSessionToken = "fakeSessionToken";
1716
const roleArn = "arn:aws:iam::261532230807:role/noobaa_s3_sts";
18-
const defaultSTSCredsValidity = 3600;
1917
const REGION = "us-east-1";
20-
const expectedParams = [{
21-
RoleArn: roleArn,
22-
RoleSessionName: 'testSession',
23-
WebIdentityToken: 'web-identity-token',
24-
DurationSeconds: defaultSTSCredsValidity,
25-
}];
26-
27-
mocha.describe('AWS STS tests', function() {
28-
let STSStub;
29-
let stsFake;
30-
mocha.before('Creating STS stub', function() {
31-
32-
sinon.stub(fs.promises, "readFile")
33-
.withArgs(projectedServiceAccountToken)
34-
.returns("web-identity-token");
35-
36-
stsFake = {
37-
assumeRoleWithWebIdentity: sinon.stub().returnsThis(),
38-
promise: sinon.stub()
39-
.resolves({
40-
Credentials: {
41-
AccessKeyId: fakeAccessKeyId,
42-
SecretAccessKey: fakeSecretAccessKey,
43-
SessionToken: fakeSessionToken
44-
}
45-
}),
46-
};
47-
STSStub = sinon.stub(AWS, 'STS')
48-
.callsFake(() => stsFake);
49-
});
50-
mocha.after('Restoring STS stub', function() {
51-
STSStub.restore();
52-
fs.promises.readFile.restore?.();
53-
});
54-
mocha.it('should generate aws sts creds', async function() {
55-
const params = {
56-
aws_sts_arn: roleArn
57-
};
58-
const roleSessionName = "testSession";
59-
const json = await cloud_utils.generate_aws_sts_creds(params, roleSessionName);
60-
sinon.assert.calledOnce(STSStub);
61-
sinon.assert.calledWith(stsFake.assumeRoleWithWebIdentity, ...expectedParams);
62-
assert.equal(json.accessKeyId, fakeAccessKeyId);
63-
assert.equal(json.secretAccessKey, fakeSecretAccessKey);
64-
assert.equal(json.sessionToken, fakeSessionToken);
65-
dbg.log0('test.aws.sts.assumeRoleWithWebIdentity: ', json);
66-
});
67-
mocha.it('should generate an STS S3 client', async function() {
68-
const params = {
69-
aws_sts_arn: roleArn,
70-
region: 'us-east-1'
71-
};
72-
const additionalParams = {
73-
RoleSessionName: 'testSession'
74-
};
75-
const s3 = await cloud_utils.createSTSS3Client(params, additionalParams);
76-
dbg.log0('test.aws.sts.createSTSS3Client: ', s3);
77-
assert.equal(s3.config.credentials.accessKeyId, fakeAccessKeyId);
78-
assert.equal(s3.config.credentials.secretAccessKey, fakeSecretAccessKey);
79-
assert.equal(s3.config.credentials.sessionToken, fakeSessionToken);
80-
assert.equal(s3.config.region, 'us-east-1');
81-
});
82-
});
8318

8419
mocha.describe('AWS STS SDK V3 tests', function() {
8520
let sts_v3_stub;

0 commit comments

Comments
 (0)