|
6 | 6 | const _ = require('lodash');
|
7 | 7 | // setup coretest first to prepare the env
|
8 | 8 | const coretest = require('./coretest');
|
9 |
| -coretest.setup({ pools_to_create: coretest.POOL_LIST }); |
| 9 | +coretest.setup({ pools_to_create: [coretest.POOL_LIST[1]] }); |
10 | 10 | const config = require('../../../config');
|
11 | 11 | const { S3 } = require('@aws-sdk/client-s3');
|
12 | 12 | const { NodeHttpHandler } = require("@smithy/node-http-handler");
|
@@ -509,17 +509,41 @@ mocha.describe('s3_ops', function() {
|
509 | 509 | assert.deepEqual(res.CORSRules, params.CORSConfiguration.CORSRules);
|
510 | 510 | });
|
511 | 511 |
|
| 512 | + mocha.it('should fail on unsupported AllowedMethods', async function() { |
| 513 | + const unsupported_method = "JACKY"; |
| 514 | + const params = { |
| 515 | + Bucket: "cors-bucket", |
| 516 | + CORSConfiguration: { |
| 517 | + CORSRules: [{ |
| 518 | + AllowedOrigins: ["http://www.example.com"], |
| 519 | + AllowedMethods: ["PUT", "POST", unsupported_method, "DELETE"], |
| 520 | + MaxAgeSeconds: 1500, |
| 521 | + }] |
| 522 | + } |
| 523 | + }; |
| 524 | + try { |
| 525 | + await s3.putBucketCors(params); |
| 526 | + assert.fail(`should reject put bucket cors with unsupported method ${unsupported_method}`); |
| 527 | + } catch (err) { |
| 528 | + assert.strictEqual(err.Code, 'InvalidRequest', |
| 529 | + `Found unsupported HTTP method in CORS config. Unsupported method is ${unsupported_method}` |
| 530 | + ); |
| 531 | + assert.strictEqual(err.$metadata.httpStatusCode, 400); |
| 532 | + } |
| 533 | + }); |
| 534 | + |
512 | 535 | mocha.after(async function() {
|
513 | 536 | await s3.deleteBucket({ Bucket: "cors-bucket" });
|
514 | 537 | });
|
515 | 538 | });
|
516 | 539 |
|
517 |
| - async function test_object_ops(bucket_name, bucket_type, caching, remote_endpoint_options) { |
| 540 | + async function test_object_ops(bucket_name, bucket_type, caching, remote_endpoint_options, skip) { |
518 | 541 |
|
519 | 542 | const is_azure_namespace = is_namespace_blob_bucket(bucket_type, remote_endpoint_options && remote_endpoint_options.endpoint_type);
|
520 | 543 | const is_azure_mock = is_namespace_blob_mock(bucket_type, remote_endpoint_options && remote_endpoint_options.endpoint_type);
|
521 | 544 |
|
522 | 545 | mocha.before(async function() {
|
| 546 | + if (skip) this.skip(); |
523 | 547 | this.timeout(100000);
|
524 | 548 | source_bucket = bucket_name + '-source';
|
525 | 549 | other_platform_bucket = bucket_name + '-other-platform';
|
@@ -1389,6 +1413,7 @@ mocha.describe('s3_ops', function() {
|
1389 | 1413 | });
|
1390 | 1414 |
|
1391 | 1415 | mocha.after(async function() {
|
| 1416 | + if (skip) return; |
1392 | 1417 | this.timeout(100000);
|
1393 | 1418 | if (bucket_type === "regular") {
|
1394 | 1419 | await s3.deleteBucket({ Bucket: source_bucket });
|
@@ -1429,24 +1454,25 @@ mocha.describe('s3_ops', function() {
|
1429 | 1454 | });
|
1430 | 1455 |
|
1431 | 1456 | mocha.describe('azure-namespace-bucket-object-ops', function() {
|
| 1457 | + const skip = !process.env.BLOB_HOST && (!process.env.NEWAZUREPROJKEY || !process.env.NEWAZUREPROJSECRET); |
1432 | 1458 | const options = {
|
1433 | 1459 | endpoint: process.env.NEWAZUREPROJKEY ? 'https://blob.core.windows.net' : azure_mock_endpoint,
|
1434 | 1460 | endpoint_type: 'AZURE',
|
1435 | 1461 | identity: process.env.NEWAZUREPROJKEY || azure_mock_account,
|
1436 | 1462 | secret: process.env.NEWAZUREPROJSECRET || azure_mock_key
|
1437 | 1463 | };
|
1438 |
| - test_object_ops(BKT6, 'namespace', undefined, options); |
| 1464 | + test_object_ops(BKT6, 'namespace', undefined, options, skip); |
1439 | 1465 | });
|
1440 | 1466 |
|
1441 | 1467 | mocha.describe('aws-namespace-bucket-object-ops', function() {
|
1442 |
| - if (!process.env.NEWAWSPROJKEY || !process.env.NEWAWSPROJSECRET) return; |
| 1468 | + const skip = !process.env.NEWAWSPROJKEY || !process.env.NEWAWSPROJSECRET; |
1443 | 1469 | const options = {
|
1444 | 1470 | endpoint: 'https://s3.amazonaws.com',
|
1445 | 1471 | endpoint_type: 'AWS',
|
1446 | 1472 | identity: process.env.NEWAWSPROJKEY,
|
1447 | 1473 | secret: process.env.NEWAWSPROJSECRET
|
1448 | 1474 | };
|
1449 |
| - test_object_ops(BKT7, 'namespace', undefined, options); |
| 1475 | + test_object_ops(BKT7, 'namespace', undefined, options, skip); |
1450 | 1476 | });
|
1451 | 1477 | });
|
1452 | 1478 |
|
|
0 commit comments