diff --git a/features/acm/step_definitions/acm.js b/features/acm/step_definitions/acm.js index 89e29cecaebe..8190aa37f8af 100644 --- a/features/acm/step_definitions/acm.js +++ b/features/acm/step_definitions/acm.js @@ -1,7 +1,7 @@ -var { ACM } = require('../../../clients/node/client-acm-node'); +var { ACM } = require("../../../clients/node/client-acm-node"); module.exports = function() { - this.Before("@acm", function (callback) { + this.Before("@acm", function(callback) { this.service = new ACM({}); callback(); }); diff --git a/features/apigateway/step_definitions/apigateway.js b/features/apigateway/step_definitions/apigateway.js index 16ea9943a73a..73e311881ca1 100644 --- a/features/apigateway/step_definitions/apigateway.js +++ b/features/apigateway/step_definitions/apigateway.js @@ -1,5 +1,5 @@ module.exports = function() { - this.Before("@apigateway", function (callback) { + this.Before("@apigateway", function(callback) { this.service = new this.AWS.APIGateway(); callback(); }); diff --git a/features/autoscaling/step_definitions/autoscaling.js b/features/autoscaling/step_definitions/autoscaling.js index b8b80dacecae..8f5741b7102c 100644 --- a/features/autoscaling/step_definitions/autoscaling.js +++ b/features/autoscaling/step_definitions/autoscaling.js @@ -1,33 +1,44 @@ -var { AutoScaling } = require('../../../clients/node/client-auto-scaling-node'); +var { AutoScaling } = require("../../../clients/node/client-auto-scaling-node"); module.exports = function() { - this.Before('@autoscaling', function (callback) { - this.service = new AutoScaling({region: 'us-east-1'}); + this.Before("@autoscaling", function(callback) { + this.service = new AutoScaling({ region: "us-east-1" }); callback(); }); - this.Given(/^I create a launch configuration with name "([^"]*)"$/, function(name, callback) { + this.Given(/^I create a launch configuration with name "([^"]*)"$/, function( + name, + callback + ) { var params = { - ImageId: 'ami-1624987f', - InstanceType: 'm1.small', + ImageId: "ami-1624987f", + InstanceType: "m1.small", LaunchConfigurationName: name }; - this.request(null, 'createLaunchConfiguration', params, callback, false); + this.request(null, "createLaunchConfiguration", params, callback, false); }); this.Given(/^I describe launch configurations$/, function(callback) { - this.request(null, 'describeLaunchConfigurations', {}, callback); + this.request(null, "describeLaunchConfigurations", {}, callback); }); - this.Then(/^the list should contain the launch configuration "([^"]*)"$/, function(name, callback) { - this.assert.contains(this.data.LaunchConfigurations, function(configuration) { - return configuration.LaunchConfigurationName === name; - }); - callback(); - }); + this.Then( + /^the list should contain the launch configuration "([^"]*)"$/, + function(name, callback) { + this.assert.contains(this.data.LaunchConfigurations, function( + configuration + ) { + return configuration.LaunchConfigurationName === name; + }); + callback(); + } + ); - this.Then(/^I delete the launch configuration "([^"]*)"$/, function(name, callback) { - var params = {LaunchConfigurationName: name}; - this.request(null, 'deleteLaunchConfiguration', params, callback); + this.Then(/^I delete the launch configuration "([^"]*)"$/, function( + name, + callback + ) { + var params = { LaunchConfigurationName: name }; + this.request(null, "deleteLaunchConfiguration", params, callback); }); }; diff --git a/features/cloudformation/step_definitions/cloudformation.js b/features/cloudformation/step_definitions/cloudformation.js index e8a9baa3082d..57228486e245 100644 --- a/features/cloudformation/step_definitions/cloudformation.js +++ b/features/cloudformation/step_definitions/cloudformation.js @@ -1,15 +1,23 @@ -var { CloudFormation } = require('../../../clients/node/client-cloudformation-node'); +var { + CloudFormation +} = require("../../../clients/node/client-cloudformation-node"); module.exports = function() { - this.Before("@cloudformation", function (callback) { + this.Before("@cloudformation", function(callback) { this.service = new CloudFormation({}); callback(); }); - this.Given(/^I create a CloudFormation stack with name prefix "([^"]*)"$/, function(prefix, callback) { - this.stackName = this.uniqueName(prefix); - this.templateBody = '{"Resources":{"member":{"Type":"AWS::SQS::Queue"}}}'; - var params = { TemplateBody: this.templateBody, StackName: this.stackName }; - this.request(null, 'createStack', params, callback, false); - }); + this.Given( + /^I create a CloudFormation stack with name prefix "([^"]*)"$/, + function(prefix, callback) { + this.stackName = this.uniqueName(prefix); + this.templateBody = '{"Resources":{"member":{"Type":"AWS::SQS::Queue"}}}'; + var params = { + TemplateBody: this.templateBody, + StackName: this.stackName + }; + this.request(null, "createStack", params, callback, false); + } + ); }; diff --git a/features/cloudfront/step_definitions/cloudfront-latest.js b/features/cloudfront/step_definitions/cloudfront-latest.js index b6f8db670a55..d47f1f587bc7 100644 --- a/features/cloudfront/step_definitions/cloudfront-latest.js +++ b/features/cloudfront/step_definitions/cloudfront-latest.js @@ -1,52 +1,54 @@ module.exports = function() { var createParams = { - CallerReference: '', + CallerReference: "", Aliases: { Quantity: 0 }, - DefaultRootObject: '', + DefaultRootObject: "", Origins: { - Items: [{ - Id: 'origin', - DomainName: 'example.com', - CustomOriginConfig: { - HTTPPort: 80, - HTTPSPort: 443, - OriginProtocolPolicy: 'match-viewer' + Items: [ + { + Id: "origin", + DomainName: "example.com", + CustomOriginConfig: { + HTTPPort: 80, + HTTPSPort: 443, + OriginProtocolPolicy: "match-viewer" + } } - }], + ], Quantity: 1 }, DefaultCacheBehavior: { - TargetOriginId: 'origin', + TargetOriginId: "origin", ForwardedValues: { QueryString: false, - Cookies: { Forward: 'all' } + Cookies: { Forward: "all" } }, TrustedSigners: { Items: [], Enabled: false, Quantity: 0 }, - ViewerProtocolPolicy: 'allow-all', + ViewerProtocolPolicy: "allow-all", MinTTL: 0 }, CacheBehaviors: { Items: [], Quantity: 0 }, - Comment: '', + Comment: "", Logging: { Enabled: false, - Bucket: 'invalidbucket.s3.amazonaws.com', - Prefix: 'prefix', + Bucket: "invalidbucket.s3.amazonaws.com", + Prefix: "prefix", IncludeCookies: false }, - PriceClass: 'PriceClass_All', + PriceClass: "PriceClass_All", Enabled: false }; - this.Before("@cloudfront", function (callback) { + this.Before("@cloudfront", function(callback) { this.service = new this.AWS.CloudFront(); this.cfCreateParams = createParams; callback(); diff --git a/features/cloudfront/step_definitions/cloudfront.js b/features/cloudfront/step_definitions/cloudfront.js index f5e6507182ab..366308ef5a58 100644 --- a/features/cloudfront/step_definitions/cloudfront.js +++ b/features/cloudfront/step_definitions/cloudfront.js @@ -1,13 +1,22 @@ module.exports = function() { - this.Given(/^I create a CloudFront distribution with name prefix "([^"]*)"$/, function(prefix, callback) { - this.cfName = this.uniqueName(prefix); - this.cfCreateParams.CallerReference = this.cfName; - this.cfCreateParams.Origins.Items[0].Id = (this.cfName === '' ? 'origin' : 'InvalidOrigin'); - this.request(null, 'createDistribution', { DistributionConfig: this.cfCreateParams }, callback, false); - }); + this.Given( + /^I create a CloudFront distribution with name prefix "([^"]*)"$/, + function(prefix, callback) { + this.cfName = this.uniqueName(prefix); + this.cfCreateParams.CallerReference = this.cfName; + this.cfCreateParams.Origins.Items[0].Id = + this.cfName === "" ? "origin" : "InvalidOrigin"; + this.request( + null, + "createDistribution", + { DistributionConfig: this.cfCreateParams }, + callback, + false + ); + } + ); this.Given(/^I list CloudFront distributions$/, function(callback) { - this.request(null, 'listDistributions', {}, callback); + this.request(null, "listDistributions", {}, callback); }); - }; diff --git a/features/cloudsearch/step_definitions/cloudsearch.js b/features/cloudsearch/step_definitions/cloudsearch.js index a7a386ed5a4a..b6a3ae00d0d6 100644 --- a/features/cloudsearch/step_definitions/cloudsearch.js +++ b/features/cloudsearch/step_definitions/cloudsearch.js @@ -1,13 +1,22 @@ -var { CloudSearch } = require('../../../clients/node/client-cloudsearch-node'); +var { CloudSearch } = require("../../../clients/node/client-cloudsearch-node"); module.exports = function() { - this.Before("@cloudsearch", function (callback) { + this.Before("@cloudsearch", function(callback) { this.service = new CloudSearch({}); callback(); }); - this.Given(/^I create a domain with name prefix "([^"]*)"$/, function(prefix, callback) { + this.Given(/^I create a domain with name prefix "([^"]*)"$/, function( + prefix, + callback + ) { this.domainName = this.uniqueName(prefix); - this.request(null, 'createDomain', {DomainName: this.domainName}, callback, false); + this.request( + null, + "createDomain", + { DomainName: this.domainName }, + callback, + false + ); }); }; diff --git a/features/cloudtrail/step_definitions/cloudtrail.js b/features/cloudtrail/step_definitions/cloudtrail.js index e115bc6aef98..dd4a0b61c2f9 100644 --- a/features/cloudtrail/step_definitions/cloudtrail.js +++ b/features/cloudtrail/step_definitions/cloudtrail.js @@ -1,16 +1,22 @@ -var { CloudTrail } = require('../../../clients/node/client-cloudtrail-node'); +var { CloudTrail } = require("../../../clients/node/client-cloudtrail-node"); module.exports = function() { - this.Before("@cloudtrail", function (callback) { + this.Before("@cloudtrail", function(callback) { this.service = new CloudTrail({}); callback(); }); this.Given(/^I describe trails$/, function(callback) { - this.request(null, 'describeTrails', {}, callback); + this.request(null, "describeTrails", {}, callback); }); this.Given(/^I create a trail with an invalid name$/, function(callback) { - this.request(null, 'createTrail', {Name: '', S3BucketName: ''}, callback, false); + this.request( + null, + "createTrail", + { Name: "", S3BucketName: "" }, + callback, + false + ); }); }; diff --git a/features/cloudwatch/step_definitions/cloudwatch.js b/features/cloudwatch/step_definitions/cloudwatch.js index f2a12ed9aec5..c4177705108c 100644 --- a/features/cloudwatch/step_definitions/cloudwatch.js +++ b/features/cloudwatch/step_definitions/cloudwatch.js @@ -1,41 +1,51 @@ -var { CloudWatch } = require('../../../clients/node/client-cloudwatch-node'); +var { CloudWatch } = require("../../../clients/node/client-cloudwatch-node"); module.exports = function() { - this.Before("@cloudwatch", function (callback) { + this.Before("@cloudwatch", function(callback) { this.service = new CloudWatch({}); callback(); }); - this.Given(/^I create a CloudWatch alarm with (prefix|name) "([^"]*)"$/, function(prefix, name, callback) { - var timestamp = new Date().getTime(); - this.cloudWatchAlarm = { - AlarmName: name, - MetricName: 'aws-sdk-js-metric-' + timestamp, - Namespace: 'aws-sdk-js-namespace' + timestamp, - ComparisonOperator: 'GreaterThanThreshold', - EvaluationPeriods: 5, - Period: 60, - Statistic: 'Average', - Threshold: 50.0 - }; + this.Given( + /^I create a CloudWatch alarm with (prefix|name) "([^"]*)"$/, + function(prefix, name, callback) { + var timestamp = new Date().getTime(); + this.cloudWatchAlarm = { + AlarmName: name, + MetricName: "aws-sdk-js-metric-" + timestamp, + Namespace: "aws-sdk-js-namespace" + timestamp, + ComparisonOperator: "GreaterThanThreshold", + EvaluationPeriods: 5, + Period: 60, + Statistic: "Average", + Threshold: 50.0 + }; - if (prefix === 'prefix') { - this.cloudWatchAlarm.AlarmName += '-' + timestamp; - } + if (prefix === "prefix") { + this.cloudWatchAlarm.AlarmName += "-" + timestamp; + } - this.request(null, 'putMetricAlarm', this.cloudWatchAlarm, - callback, prefix === 'name' ? false : undefined); - }); + this.request( + null, + "putMetricAlarm", + this.cloudWatchAlarm, + callback, + prefix === "name" ? false : undefined + ); + } + ); this.Given(/^I list the CloudWatch alarms$/, function(callback) { var params = { MetricName: this.cloudWatchAlarm.MetricName, Namespace: this.cloudWatchAlarm.Namespace }; - this.request(null, 'describeAlarmsForMetric', params, callback); + this.request(null, "describeAlarmsForMetric", params, callback); }); - this.Then(/^the list should contain the CloudWatch alarm$/, function(callback) { + this.Then(/^the list should contain the CloudWatch alarm$/, function( + callback + ) { var name = this.cloudWatchAlarm.AlarmName; this.assert.contains(this.data.MetricAlarms, function(alarm) { return alarm.AlarmName === name; @@ -44,7 +54,11 @@ module.exports = function() { }); this.Then(/^I delete the CloudWatch alarm$/, function(callback) { - this.request(null, 'deleteAlarms', - {AlarmNames: [this.cloudWatchAlarm.AlarmName]}, callback); + this.request( + null, + "deleteAlarms", + { AlarmNames: [this.cloudWatchAlarm.AlarmName] }, + callback + ); }); }; diff --git a/features/cloudwatchevents/step_definitions/cloudwatchevents.js b/features/cloudwatchevents/step_definitions/cloudwatchevents.js index 1c55082aff4b..1737798dd9db 100644 --- a/features/cloudwatchevents/step_definitions/cloudwatchevents.js +++ b/features/cloudwatchevents/step_definitions/cloudwatchevents.js @@ -1,7 +1,9 @@ -var { CloudWatchEvents } = require('../../../clients/node/client-cloudwatch-events-node'); +var { + CloudWatchEvents +} = require("../../../clients/node/client-cloudwatch-events-node"); module.exports = function() { - this.Before("@cloudwatchevents", function (callback) { + this.Before("@cloudwatchevents", function(callback) { this.service = new CloudWatchEvents({}); callback(); }); diff --git a/features/cloudwatchlogs/step_definitions/cloudwatchlogs.js b/features/cloudwatchlogs/step_definitions/cloudwatchlogs.js index 6b0f6a90f4da..f21d19f01961 100644 --- a/features/cloudwatchlogs/step_definitions/cloudwatchlogs.js +++ b/features/cloudwatchlogs/step_definitions/cloudwatchlogs.js @@ -1,22 +1,35 @@ -var { CloudWatchLogs } = require('../../../clients/node/client-cloudwatch-logs-node'); +var { + CloudWatchLogs +} = require("../../../clients/node/client-cloudwatch-logs-node"); module.exports = function() { - this.Before("@cloudwatchlogs", function (callback) { + this.Before("@cloudwatchlogs", function(callback) { this.service = new CloudWatchLogs({}); callback(); }); - this.Given(/^I create a CloudWatch logGroup with prefix "([^"]*)"$/, function (prefix, callback) { + this.Given(/^I create a CloudWatch logGroup with prefix "([^"]*)"$/, function( + prefix, + callback + ) { var expectErr = prefix === "" ? false : undefined; this.logGroupName = this.uniqueName(prefix); - this.request(null, 'createLogGroup', {logGroupName: this.logGroupName}, callback, expectErr); + this.request( + null, + "createLogGroup", + { logGroupName: this.logGroupName }, + callback, + expectErr + ); }); - this.Given(/^I list the CloudWatch logGroups$/, function (callback) { - this.request(null, 'describeLogGroups', {}, callback); + this.Given(/^I list the CloudWatch logGroups$/, function(callback) { + this.request(null, "describeLogGroups", {}, callback); }); - this.Then(/^the list should contain the CloudWatch logGroup$/, function (callback) { + this.Then(/^the list should contain the CloudWatch logGroup$/, function( + callback + ) { var name = this.logGroupName; this.assert.contains(this.data.logGroups, function(alarm) { return alarm.logGroupName === name; @@ -24,7 +37,12 @@ module.exports = function() { callback(); }); - this.Then(/^I delete the CloudWatch logGroup$/, function (callback) { - this.request(null, 'deleteLogGroup', {logGroupName: this.logGroupName}, callback); + this.Then(/^I delete the CloudWatch logGroup$/, function(callback) { + this.request( + null, + "deleteLogGroup", + { logGroupName: this.logGroupName }, + callback + ); }); }; diff --git a/features/codecommit/step_definitions/codecommit.js b/features/codecommit/step_definitions/codecommit.js index 6dfa4ad469a8..8dfcd0cebaab 100644 --- a/features/codecommit/step_definitions/codecommit.js +++ b/features/codecommit/step_definitions/codecommit.js @@ -1,8 +1,8 @@ -var { CodeCommit } = require('../../../clients/node/client-codecommit-node'); +var { CodeCommit } = require("../../../clients/node/client-codecommit-node"); module.exports = function() { - this.Before('@codecommit', function (callback) { - this.service = new CodeCommit({region: 'us-east-1'}); + this.Before("@codecommit", function(callback) { + this.service = new CodeCommit({ region: "us-east-1" }); callback(); }); diff --git a/features/codedeploy/step_definitions/codedeploy.js b/features/codedeploy/step_definitions/codedeploy.js index b96bc988c3ff..a2d1e7ad800c 100644 --- a/features/codedeploy/step_definitions/codedeploy.js +++ b/features/codedeploy/step_definitions/codedeploy.js @@ -1,7 +1,7 @@ -var { CodeDeploy } = require('../../../clients/node/client-codedeploy-node'); +var { CodeDeploy } = require("../../../clients/node/client-codedeploy-node"); module.exports = function() { - this.Before("@codedeploy", function (callback) { + this.Before("@codedeploy", function(callback) { this.service = new CodeDeploy({}); callback(); }); diff --git a/features/codepipeline/step_definitions/codepipeline.js b/features/codepipeline/step_definitions/codepipeline.js index b5834bef54ce..b83e13773717 100644 --- a/features/codepipeline/step_definitions/codepipeline.js +++ b/features/codepipeline/step_definitions/codepipeline.js @@ -1,8 +1,10 @@ -var { CodePipeline } = require('../../../clients/node/client-codepipeline-node'); +var { + CodePipeline +} = require("../../../clients/node/client-codepipeline-node"); module.exports = function() { - this.Before('@codepipeline', function (callback) { - this.service = new CodePipeline({region: 'us-east-1'}); + this.Before("@codepipeline", function(callback) { + this.service = new CodePipeline({ region: "us-east-1" }); callback(); }); diff --git a/features/cognitoidentity/step_definitions/cognitoidentity.js b/features/cognitoidentity/step_definitions/cognitoidentity.js index a2b7c73ac227..2f6ae685b709 100644 --- a/features/cognitoidentity/step_definitions/cognitoidentity.js +++ b/features/cognitoidentity/step_definitions/cognitoidentity.js @@ -1,23 +1,41 @@ -var { CognitoIdentity } = require('../../../clients/node/client-cognito-identity-node'); +var { + CognitoIdentity +} = require("../../../clients/node/client-cognito-identity-node"); module.exports = function() { - this.Before("@cognitoidentity", function (callback) { + this.Before("@cognitoidentity", function(callback) { this.service = new CognitoIdentity({}); callback(); }); - this.Given(/^I create a Cognito identity pool with prefix "([^"]*)"$/, function (prefix, callback) { - var expectError = prefix === "" ? false : undefined; - var params = {IdentityPoolName: this.uniqueName(prefix, ''), AllowUnauthenticatedIdentities: true}; - this.request(null, 'createIdentityPool', params, callback, expectError); - }); + this.Given( + /^I create a Cognito identity pool with prefix "([^"]*)"$/, + function(prefix, callback) { + var expectError = prefix === "" ? false : undefined; + var params = { + IdentityPoolName: this.uniqueName(prefix, ""), + AllowUnauthenticatedIdentities: true + }; + this.request(null, "createIdentityPool", params, callback, expectError); + } + ); - this.Given(/^I describe the Cognito identity pool ID$/, function (callback) { + this.Given(/^I describe the Cognito identity pool ID$/, function(callback) { this.identityPoolId = this.data.IdentityPoolId; - this.request(null, 'describeIdentityPool', {IdentityPoolId: this.data.IdentityPoolId}, callback); + this.request( + null, + "describeIdentityPool", + { IdentityPoolId: this.data.IdentityPoolId }, + callback + ); }); - this.Then(/^I delete the Cognito identity pool$/, function (callback) { - this.request(null, 'deleteIdentityPool', {IdentityPoolId: this.identityPoolId}, callback); + this.Then(/^I delete the Cognito identity pool$/, function(callback) { + this.request( + null, + "deleteIdentityPool", + { IdentityPoolId: this.identityPoolId }, + callback + ); }); }; diff --git a/features/cognitosync/step_definitions/cognitosync.js b/features/cognitosync/step_definitions/cognitosync.js index b9bdb149eb37..e1b4b592ceaf 100644 --- a/features/cognitosync/step_definitions/cognitosync.js +++ b/features/cognitosync/step_definitions/cognitosync.js @@ -1,17 +1,20 @@ -var { CognitoSync } = require('../../../clients/node/client-cognito-sync-node'); +var { CognitoSync } = require("../../../clients/node/client-cognito-sync-node"); module.exports = function() { - this.Before("@cognitosync", function (callback) { + this.Before("@cognitosync", function(callback) { this.service = new CognitoSync({}); callback(); }); - this.Given(/^I list Cognito identity pool usage$/, function (callback) { - this.request(null, 'listIdentityPoolUsage', {}, callback); + this.Given(/^I list Cognito identity pool usage$/, function(callback) { + this.request(null, "listIdentityPoolUsage", {}, callback); }); - this.Given(/^I list Cognito data sets with identity pool id "([^"]*)" and identity id "([^"]*)"$/, function (idpid, idid, callback) { - var params = {IdentityPoolId: idpid, IdentityId: idid}; - this.request(null, 'listDatasets', params, callback, false); - }); + this.Given( + /^I list Cognito data sets with identity pool id "([^"]*)" and identity id "([^"]*)"$/, + function(idpid, idid, callback) { + var params = { IdentityPoolId: idpid, IdentityId: idid }; + this.request(null, "listDatasets", params, callback, false); + } + ); }; diff --git a/features/configservice/step_definitions/configservice.js b/features/configservice/step_definitions/configservice.js index 826bcac64fa0..89ca0ad40128 100644 --- a/features/configservice/step_definitions/configservice.js +++ b/features/configservice/step_definitions/configservice.js @@ -1,7 +1,9 @@ -var { ConfigService } = require('../../../clients/node/client-config-service-node'); +var { + ConfigService +} = require("../../../clients/node/client-config-service-node"); module.exports = function() { - this.Before("@configservice", function (callback) { + this.Before("@configservice", function(callback) { this.service = new ConfigService({}); callback(); }); diff --git a/features/datapipeline/step_definitions/datapipeline.js b/features/datapipeline/step_definitions/datapipeline.js index fbd9e19b1c13..3f63b3683e5a 100644 --- a/features/datapipeline/step_definitions/datapipeline.js +++ b/features/datapipeline/step_definitions/datapipeline.js @@ -1,15 +1,21 @@ -var { DataPipeline } = require('../../../clients/node/client-data-pipeline-node'); +var { + DataPipeline +} = require("../../../clients/node/client-data-pipeline-node"); module.exports = function() { - this.Before("@datapipeline", function (callback) { + this.Before("@datapipeline", function(callback) { this.service = new DataPipeline({}); callback(); }); - this.Given(/^I create a Data Pipeline with name prefix "([^"]*)"$/, function(prefix, callback) { + this.Given(/^I create a Data Pipeline with name prefix "([^"]*)"$/, function( + prefix, + callback + ) { var params = { - name: this.uniqueName(prefix), uniqueId: this.uniqueName('aws-js-sdk') + name: this.uniqueName(prefix), + uniqueId: this.uniqueName("aws-js-sdk") }; - this.request(null, 'createPipeline', params, callback, false); + this.request(null, "createPipeline", params, callback, false); }); }; diff --git a/features/devicefarm/step_definitions/devicefarm.js b/features/devicefarm/step_definitions/devicefarm.js index 99cf97b25d9a..6b86420ba8a8 100644 --- a/features/devicefarm/step_definitions/devicefarm.js +++ b/features/devicefarm/step_definitions/devicefarm.js @@ -1,8 +1,8 @@ -var { DeviceFarm } = require('../../../clients/node/client-device-farm-node'); +var { DeviceFarm } = require("../../../clients/node/client-device-farm-node"); module.exports = function() { - this.Before('@devicefarm', function (callback) { - this.service = new DeviceFarm({region: 'us-west-2'}); + this.Before("@devicefarm", function(callback) { + this.service = new DeviceFarm({ region: "us-west-2" }); callback(); }); diff --git a/features/directconnect/step_definitions/directconnect.js b/features/directconnect/step_definitions/directconnect.js index e0f993ba0b7b..b8b3665be764 100644 --- a/features/directconnect/step_definitions/directconnect.js +++ b/features/directconnect/step_definitions/directconnect.js @@ -1,17 +1,22 @@ -var { DirectConnect } = require('../../../clients/node/client-direct-connect-node'); +var { + DirectConnect +} = require("../../../clients/node/client-direct-connect-node"); module.exports = function() { - this.Before("@directconnect", function (callback) { + this.Before("@directconnect", function(callback) { this.service = new DirectConnect({}); callback(); }); - this.Given(/^I create a Direct Connect connection with an invalid location$/, function(callback) { - var params = { - bandwidth: '1Gbps', - location: 'INVALID_LOCATION', - connectionName: this.uniqueName('aws-sdk-js') - }; - this.request(null, 'createConnection', params, callback, false); - }); + this.Given( + /^I create a Direct Connect connection with an invalid location$/, + function(callback) { + var params = { + bandwidth: "1Gbps", + location: "INVALID_LOCATION", + connectionName: this.uniqueName("aws-sdk-js") + }; + this.request(null, "createConnection", params, callback, false); + } + ); }; diff --git a/features/directoryservice/step_definitions/directoryservice.js b/features/directoryservice/step_definitions/directoryservice.js index 0e3567a39b95..d93a2fd36e59 100644 --- a/features/directoryservice/step_definitions/directoryservice.js +++ b/features/directoryservice/step_definitions/directoryservice.js @@ -1,7 +1,9 @@ -var { DirectoryService } = require('../../../clients/node/client-directory-service-node'); +var { + DirectoryService +} = require("../../../clients/node/client-directory-service-node"); module.exports = function() { - this.Before("@directoryservice", function (callback) { + this.Before("@directoryservice", function(callback) { this.service = new DirectoryService({}); callback(); }); diff --git a/features/dms/step_definitions/dms.js b/features/dms/step_definitions/dms.js index 30c34e37e78e..73a593116bf7 100644 --- a/features/dms/step_definitions/dms.js +++ b/features/dms/step_definitions/dms.js @@ -1,7 +1,9 @@ -var { DatabaseMigrationService } = require('../../../clients/node/client-database-migration-service-node'); +var { + DatabaseMigrationService +} = require("../../../clients/node/client-database-migration-service-node"); module.exports = function() { - this.Before("@dms", function (callback) { + this.Before("@dms", function(callback) { this.service = new DatabaseMigrationService({}); callback(); }); diff --git a/features/dynamodb/step_definitions/dynamodb.js b/features/dynamodb/step_definitions/dynamodb.js index 066373429ac4..2c59570cafa3 100644 --- a/features/dynamodb/step_definitions/dynamodb.js +++ b/features/dynamodb/step_definitions/dynamodb.js @@ -1,5 +1,5 @@ -var jmespath = require('jmespath'); -var { DynamoDB } = require('../../../clients/node/client-dynamodb-node'); +var jmespath = require("jmespath"); +var { DynamoDB } = require("../../../clients/node/client-dynamodb-node"); function waitForTableExists(tableName, callback) { const db = new DynamoDB({}); @@ -34,9 +34,9 @@ function waitForTableExists(tableName, callback) { } } }); - } + }; checkForTableExists(params, callback); -}; +} function waitForTableNotExists(tableName, callback) { const db = new DynamoDB({}); @@ -71,12 +71,12 @@ function waitForTableNotExists(tableName, callback) { } }); checkForTableNotExists(params, callback); - } + }; checkForTableNotExists(params, callback); -}; +} module.exports = function() { - this.Before("@dynamodb", function (next) { + this.Before("@dynamodb", function(next) { this.service = new DynamoDB({ maxRetries: 2 }); @@ -88,15 +88,11 @@ module.exports = function() { var params = { TableName: world.tableName, - AttributeDefinitions: [ - { AttributeName: 'id', AttributeType: 'S' } - ], - KeySchema: [ - { AttributeName: 'id', KeyType: 'HASH' } - ], + AttributeDefinitions: [{ AttributeName: "id", AttributeType: "S" }], + KeySchema: [{ AttributeName: "id", KeyType: "HASH" }], ProvisionedThroughput: { ReadCapacityUnits: 10, - WriteCapacityUnits: 5, + WriteCapacityUnits: 5 } }; @@ -111,7 +107,7 @@ module.exports = function() { this.Given(/^I have a table$/, function(callback) { var world = this; - this.tableName = 'aws-sdk-js-integration-test'; + this.tableName = "aws-sdk-js-integration-test"; this.service.listTables({}, function(err, data) { for (var i = 0; i < data.TableNames.length; i++) { if (data.TableNames[i] == world.tableName) { @@ -124,89 +120,115 @@ module.exports = function() { }); this.When(/^I put the item:$/, function(string, next) { - var params = {TableName: this.tableName, Item: JSON.parse(string)}; - this.request(null, 'putItem', params, next); + var params = { TableName: this.tableName, Item: JSON.parse(string) }; + this.request(null, "putItem", params, next); }); this.Then(/^the item with id "([^"]*)" should exist$/, function(key, next) { - var params = {TableName: this.tableName, Key: {id: {S: key}}}; - this.request(null, 'getItem', params, next); + var params = { TableName: this.tableName, Key: { id: { S: key } } }; + this.request(null, "getItem", params, next); }); - this.Then(/^it should have attribute "([^"]*)" containing "([^"]*)"$/, function(attr, value, next) { - this.assert.equal(jmespath.search(this.data.Item, attr), value); - next(); - }); + this.Then( + /^it should have attribute "([^"]*)" containing "([^"]*)"$/, + function(attr, value, next) { + this.assert.equal(jmespath.search(this.data.Item, attr), value); + next(); + } + ); this.When(/^I delete the table$/, function(next) { - var params = {TableName: this.tableName}; - this.request(null, 'deleteTable', params, next); + var params = { TableName: this.tableName }; + this.request(null, "deleteTable", params, next); }); this.Then(/^the table should eventually not exist$/, function(callback) { waitForTableNotExists(this.tableName, calback); }); - this.Given(/^my first request is corrupted with CRC checking (ON|OFF)$/, function(toggle, callback) { - var world = this; - this.service.config.dynamoDbCrc32 = toggle == 'ON' ? true : false; - var req = this.service.listTables(); - this.service.config.dynamoDbCrc32 = true; - req.removeAllListeners('httpData'); - req.on('httpData', function(chunk, resp) { - if (resp.retryCount == 0) { - resp.httpResponse.body = Buffer.from('{"invalid":"response"}'); - } else { - world.AWS.EventListeners.Core.HTTP_DATA.call(this, chunk, resp); - } - }); - req.on('complete', function(resp) { - world.error = resp.error; - world.response = resp; - if (resp.error) callback.fail(resp.error); - else callback(); - }); - req.send(); - }); - - this.Then(/^the request should( not)? be retried$/, function(retry, callback) { - if (retry && this.response.retryCount > 0) callback.fail('Request was incorrectly retried'); - if (!retry && this.response.retryCount == 0) callback.fail('Request was incorrectly retried'); - callback(); - }); - - this.Given(/^all of my requests are corrupted with CRC checking ON$/, function(callback) { - var world = this; - var req = this.service.listTables(); - req.removeAllListeners('httpData'); - req.on('httpData', function(chunk, resp) { - resp.httpResponse.body = Buffer.from('{"invalid":"response"}'); - }); - req.on('complete', function(resp) { - world.error = resp.error; - world.response = resp; - callback(); - }); - req.send(); - }); - - this.When(/^the request is retried the maximum number of times$/, function(callback) { - if (this.response.retryCount != 2) callback.fail('Incorrect retry count'); + this.Given( + /^my first request is corrupted with CRC checking (ON|OFF)$/, + function(toggle, callback) { + var world = this; + this.service.config.dynamoDbCrc32 = toggle == "ON" ? true : false; + var req = this.service.listTables(); + this.service.config.dynamoDbCrc32 = true; + req.removeAllListeners("httpData"); + req.on("httpData", function(chunk, resp) { + if (resp.retryCount == 0) { + resp.httpResponse.body = Buffer.from('{"invalid":"response"}'); + } else { + world.AWS.EventListeners.Core.HTTP_DATA.call(this, chunk, resp); + } + }); + req.on("complete", function(resp) { + world.error = resp.error; + world.response = resp; + if (resp.error) callback.fail(resp.error); + else callback(); + }); + req.send(); + } + ); + + this.Then(/^the request should( not)? be retried$/, function( + retry, + callback + ) { + if (retry && this.response.retryCount > 0) + callback.fail("Request was incorrectly retried"); + if (!retry && this.response.retryCount == 0) + callback.fail("Request was incorrectly retried"); callback(); }); - this.Then(/^the request should( not)? fail with a CRC checking error$/, function(failed, callback) { - if (failed && this.error) callback.fail(this.error); - if (!failed && !this.error) callback.fail('Did not fail when should have'); + this.Given( + /^all of my requests are corrupted with CRC checking ON$/, + function(callback) { + var world = this; + var req = this.service.listTables(); + req.removeAllListeners("httpData"); + req.on("httpData", function(chunk, resp) { + resp.httpResponse.body = Buffer.from('{"invalid":"response"}'); + }); + req.on("complete", function(resp) { + world.error = resp.error; + world.response = resp; + callback(); + }); + req.send(); + } + ); + + this.When(/^the request is retried the maximum number of times$/, function( + callback + ) { + if (this.response.retryCount != 2) callback.fail("Incorrect retry count"); callback(); }); - this.Given(/^I try to delete an item with key "([^"]*)" from table "([^"]*)"$/, function(key, table, callback) { - var params = {TableName: table, Key: {id: {S: key}}}; - this.request(null, 'deleteItem', params, callback, false); - }); - - this.Given(/^I try to delete a table with an empty table parameter$/, function(callback) { - this.request(null, 'deleteTable', {TableName: ''}, callback, false); - }); + this.Then( + /^the request should( not)? fail with a CRC checking error$/, + function(failed, callback) { + if (failed && this.error) callback.fail(this.error); + if (!failed && !this.error) + callback.fail("Did not fail when should have"); + callback(); + } + ); + + this.Given( + /^I try to delete an item with key "([^"]*)" from table "([^"]*)"$/, + function(key, table, callback) { + var params = { TableName: table, Key: { id: { S: key } } }; + this.request(null, "deleteItem", params, callback, false); + } + ); + + this.Given( + /^I try to delete a table with an empty table parameter$/, + function(callback) { + this.request(null, "deleteTable", { TableName: "" }, callback, false); + } + ); }; diff --git a/features/dynamodbstreams/step_definitions/dynamodbstreams.js b/features/dynamodbstreams/step_definitions/dynamodbstreams.js index e8fad4b5ac9f..d8b31f5a009f 100644 --- a/features/dynamodbstreams/step_definitions/dynamodbstreams.js +++ b/features/dynamodbstreams/step_definitions/dynamodbstreams.js @@ -1,7 +1,9 @@ -var { DynamoDBStreams } = require('../../../clients/node/client-dynamodb-streams-node'); +var { + DynamoDBStreams +} = require("../../../clients/node/client-dynamodb-streams-node"); module.exports = function() { - this.Before("@dynamodbstreams", function (callback) { + this.Before("@dynamodbstreams", function(callback) { this.service = new DynamoDBStreams({}); callback(); }); diff --git a/features/ec2/step_definitions/ec2.js b/features/ec2/step_definitions/ec2.js index 56fa930e61e7..ee0777261a24 100644 --- a/features/ec2/step_definitions/ec2.js +++ b/features/ec2/step_definitions/ec2.js @@ -1,4 +1,4 @@ -var { EC2 } = require('../../../clients/node/client-ec2-node'); +var { EC2 } = require("../../../clients/node/client-ec2-node"); const waitForVolumeAvailable = (ec2, params, callback) => { // Iterate totalTries times @@ -20,10 +20,14 @@ const waitForVolumeAvailable = (ec2, params, callback) => { if (data.Volumes) { // iterate through array and check for success and failure let isSuccess = true; - for (let i=0; i { }); }; checkForVolumeAvailable(params, callback); -} +}; module.exports = function() { - this.Before("@ec2", function (callback) { + this.Before("@ec2", function(callback) { this.service = new EC2({}); callback(); }); this.Given(/^I describe EC2 regions "([^"]*)"$/, function(regions, callback) { regions = regions.split(/\s*,\s*/); - this.request(null, 'describeRegions', {RegionNames: regions}, callback); + this.request(null, "describeRegions", { RegionNames: regions }, callback); }); - this.Then(/^the EC2 endpoint for "([^"]*)" should be "([^"]*)"$/, function(region, endpoint, callback) { + this.Then(/^the EC2 endpoint for "([^"]*)" should be "([^"]*)"$/, function( + region, + endpoint, + callback + ) { this.assert.contains(this.data.Regions, function(region) { return region.Endpoint === endpoint; }); callback(); }); - this.Given(/^I describe the EC2 instance "([^"]*)"$/, function(instanceId, callback) { - this.request(null, 'describeInstances', {InstanceIds: [instanceId]}, callback, false); + this.Given(/^I describe the EC2 instance "([^"]*)"$/, function( + instanceId, + callback + ) { + this.request( + null, + "describeInstances", + { InstanceIds: [instanceId] }, + callback, + false + ); }); - this.Given(/^I attempt to copy an encrypted snapshot across regions$/, function (callback) { - var self = this; - var volId, srcSnapId, dstSnapId, params; - var sourceRegion = 'us-west-2'; - var destRegion = 'us-east-1'; - var srcEc2 = new EC2({region: sourceRegion}); - var dstEc2 = new EC2({region: destRegion}); - - function teardown() { - if (volId) srcEc2.deleteVolume({VolumeId: volId}).send(); - if (srcSnapId) srcEc2.deleteSnapshot({SnapshotId: srcSnapId}).send(); - if (dstSnapId) dstEc2.deleteSnapshot({SnapshotId: dstSnapId}).send(); - } + this.Given( + /^I attempt to copy an encrypted snapshot across regions$/, + function(callback) { + var self = this; + var volId, srcSnapId, dstSnapId, params; + var sourceRegion = "us-west-2"; + var destRegion = "us-east-1"; + var srcEc2 = new EC2({ region: sourceRegion }); + var dstEc2 = new EC2({ region: destRegion }); - params = {AvailabilityZone:sourceRegion+'a',Size:10,Encrypted:true}; - srcEc2.createVolume(params, function(err, data) { - if (err) { teardown(); return callback(err); } - volId = data.VolumeId; + function teardown() { + if (volId) srcEc2.deleteVolume({ VolumeId: volId }).send(); + if (srcSnapId) srcEc2.deleteSnapshot({ SnapshotId: srcSnapId }).send(); + if (dstSnapId) dstEc2.deleteSnapshot({ SnapshotId: dstSnapId }).send(); + } - waitForVolumeAvailable(srcEc2, {VolumeIds: [volId]}, function(err) { - if (err) { teardown(); return callback(err); } + params = { + AvailabilityZone: sourceRegion + "a", + Size: 10, + Encrypted: true + }; + srcEc2.createVolume(params, function(err, data) { + if (err) { + teardown(); + return callback(err); + } + volId = data.VolumeId; - srcEc2.createSnapshot({VolumeId: volId}, function(err, data) { - if (err) { teardown(); return callback(err); } - srcSnapId = data.SnapshotId; + waitForVolumeAvailable(srcEc2, { VolumeIds: [volId] }, function(err) { + if (err) { + teardown(); + return callback(err); + } - setTimeout(function() { - params = {SourceRegion: sourceRegion, SourceSnapshotId: srcSnapId}; - dstEc2.copySnapshot(params, function(err, data) { - if (data) dstSnapId = data.SnapshotId; - self.success = true; - callback(); + srcEc2.createSnapshot({ VolumeId: volId }, function(err, data) { + if (err) { teardown(); - }); - }, 5000); + return callback(err); + } + srcSnapId = data.SnapshotId; + + setTimeout(function() { + params = { + SourceRegion: sourceRegion, + SourceSnapshotId: srcSnapId + }; + dstEc2.copySnapshot(params, function(err, data) { + if (data) dstSnapId = data.SnapshotId; + self.success = true; + callback(); + teardown(); + }); + }, 5000); + }); }); }); - }); - }); + } + ); - this.Then(/^the copy snapshot attempt should be successful$/, function (callback) { + this.Then(/^the copy snapshot attempt should be successful$/, function( + callback + ) { this.assert.equal(this.success, true); callback(); }); diff --git a/features/ecr/step_definitions/ecr.js b/features/ecr/step_definitions/ecr.js index 62c3d9e10e10..4a1fd17db83e 100644 --- a/features/ecr/step_definitions/ecr.js +++ b/features/ecr/step_definitions/ecr.js @@ -1,7 +1,7 @@ -var { ECR } = require('../../../clients/node/client-ecr-node'); +var { ECR } = require("../../../clients/node/client-ecr-node"); module.exports = function() { - this.Before("@ecr", function (callback) { + this.Before("@ecr", function(callback) { this.service = new ECR({}); callback(); }); diff --git a/features/ecs/step_definitions/ecs.js b/features/ecs/step_definitions/ecs.js index bfd2eb0bf157..a44579d4f896 100644 --- a/features/ecs/step_definitions/ecs.js +++ b/features/ecs/step_definitions/ecs.js @@ -1,7 +1,7 @@ -var { ECS } = require('../../../clients/node/client-ecs-node'); +var { ECS } = require("../../../clients/node/client-ecs-node"); module.exports = function() { - this.Before("@ecs", function (callback) { + this.Before("@ecs", function(callback) { this.service = new ECS({}); callback(); }); diff --git a/features/efs/step_definitions/efs.js b/features/efs/step_definitions/efs.js index 1b56cce8bb89..fa57c7933308 100644 --- a/features/efs/step_definitions/efs.js +++ b/features/efs/step_definitions/efs.js @@ -1,8 +1,8 @@ -var { EFS } = require('../../../clients/node/client-efs-node'); +var { EFS } = require("../../../clients/node/client-efs-node"); module.exports = function() { - this.Before('@efs', function (callback) { - this.service = new EFS({region: 'us-west-2'}); + this.Before("@efs", function(callback) { + this.service = new EFS({ region: "us-west-2" }); callback(); }); }; diff --git a/features/elasticache/step_definitions/elasticache.js b/features/elasticache/step_definitions/elasticache.js index 7b67ce720524..3c1afbbf543b 100644 --- a/features/elasticache/step_definitions/elasticache.js +++ b/features/elasticache/step_definitions/elasticache.js @@ -1,40 +1,47 @@ -var { ElastiCache } = require('../../../clients/node/client-elasticache-node'); +var { ElastiCache } = require("../../../clients/node/client-elasticache-node"); module.exports = function() { - this.Before("@elasticache", function (callback) { + this.Before("@elasticache", function(callback) { this.service = new ElastiCache({}); callback(); }); - this.Given(/^I create a cache parameter group with name prefix "([^"]*)"$/, function(prefix, callback) { - this.cacheGroupName = this.uniqueName(prefix); - var params = { - Description: 'Description', - CacheParameterGroupName: this.cacheGroupName, - CacheParameterGroupFamily: 'memcached1.4' - }; - this.request(null, 'createCacheParameterGroup', params, callback, false); - }); + this.Given( + /^I create a cache parameter group with name prefix "([^"]*)"$/, + function(prefix, callback) { + this.cacheGroupName = this.uniqueName(prefix); + var params = { + Description: "Description", + CacheParameterGroupName: this.cacheGroupName, + CacheParameterGroupFamily: "memcached1.4" + }; + this.request(null, "createCacheParameterGroup", params, callback, false); + } + ); - this.Given(/^the cache parameter group name is in the result$/, function(callback) { + this.Given(/^the cache parameter group name is in the result$/, function( + callback + ) { var name = this.data.CacheParameterGroup.CacheParameterGroupName; this.assert.equal(name, this.cacheGroupName); callback(); }); this.Given(/^I describe the cache parameter groups$/, function(callback) { - var params = {CacheParameterGroupName: this.cacheGroupName}; - this.request(null, 'describeCacheParameterGroups', params, callback); + var params = { CacheParameterGroupName: this.cacheGroupName }; + this.request(null, "describeCacheParameterGroups", params, callback); }); - this.Then(/^the cache parameter group should be described$/, function(callback) { + this.Then(/^the cache parameter group should be described$/, function( + callback + ) { var item = this.data.CacheParameterGroups[0]; this.assert.equal(item.CacheParameterGroupName, this.cacheGroupName); callback(); }); this.Then(/^I delete the cache parameter group$/, function(callback) { - var params = {CacheParameterGroupName: this.cacheGroupName}; - this.request(null, 'deleteCacheParameterGroup', params, callback); + var params = { CacheParameterGroupName: this.cacheGroupName }; + this.request(null, "deleteCacheParameterGroup", params, callback); }); }; diff --git a/features/elasticbeanstalk/step_definitions/elasticbeanstalk.js b/features/elasticbeanstalk/step_definitions/elasticbeanstalk.js index effa9e9f31b5..3c5d2df3b35b 100644 --- a/features/elasticbeanstalk/step_definitions/elasticbeanstalk.js +++ b/features/elasticbeanstalk/step_definitions/elasticbeanstalk.js @@ -1,40 +1,64 @@ -var { ElasticBeanstalk } = require('../../../clients/node/client-elastic-beanstalk-node'); +var { + ElasticBeanstalk +} = require("../../../clients/node/client-elastic-beanstalk-node"); module.exports = function() { - this.Before("@elasticbeanstalk", function (callback) { + this.Before("@elasticbeanstalk", function(callback) { this.service = new ElasticBeanstalk({}); callback(); }); - this.Given(/^I create an Elastic Beanstalk application with name prefix "([^"]*)"$/, function(prefix, callback) { - this.appName = this.uniqueName(prefix); - var params = { ApplicationName: this.appName }; - this.request(null, 'createApplication', params, callback, false); - }); + this.Given( + /^I create an Elastic Beanstalk application with name prefix "([^"]*)"$/, + function(prefix, callback) { + this.appName = this.uniqueName(prefix); + var params = { ApplicationName: this.appName }; + this.request(null, "createApplication", params, callback, false); + } + ); - this.Given(/^I create an Elastic Beanstalk application version with label "([^"]*)"$/, function(label, callback) { - this.appVersion = label; - var params = { ApplicationName: this.appName, VersionLabel: this.appVersion }; - this.request(null, 'createApplicationVersion', params, callback); - }); + this.Given( + /^I create an Elastic Beanstalk application version with label "([^"]*)"$/, + function(label, callback) { + this.appVersion = label; + var params = { + ApplicationName: this.appName, + VersionLabel: this.appVersion + }; + this.request(null, "createApplicationVersion", params, callback); + } + ); - this.Given(/^I describe the Elastic Beanstalk application$/, function(callback) { + this.Given(/^I describe the Elastic Beanstalk application$/, function( + callback + ) { var params = { ApplicationNames: [this.appName] }; - this.request(null, 'describeApplications', params, callback); + this.request(null, "describeApplications", params, callback); }); - this.Then(/^the result should contain the Elastic Beanstalk application version$/, function(callback) { - this.assert.deepEqual(this.data.Applications[0].Versions, [this.appVersion]); - callback(); - }); + this.Then( + /^the result should contain the Elastic Beanstalk application version$/, + function(callback) { + this.assert.deepEqual(this.data.Applications[0].Versions, [ + this.appVersion + ]); + callback(); + } + ); - this.Then(/^the result should contain the Elastic Beanstalk application name$/, function(callback) { - this.assert.equal(this.data.Applications[0].ApplicationName, this.appName); - callback(); - }); + this.Then( + /^the result should contain the Elastic Beanstalk application name$/, + function(callback) { + this.assert.equal( + this.data.Applications[0].ApplicationName, + this.appName + ); + callback(); + } + ); this.Then(/^I delete the Elastic Beanstalk application$/, function(callback) { var params = { ApplicationName: this.appName }; - this.request(null, 'deleteApplication', params, callback); + this.request(null, "deleteApplication", params, callback); }); }; diff --git a/features/elastictranscoder/step_definitions/elastictranscoder.js b/features/elastictranscoder/step_definitions/elastictranscoder.js index 8aacdce8ffa4..8b312769a346 100644 --- a/features/elastictranscoder/step_definitions/elastictranscoder.js +++ b/features/elastictranscoder/step_definitions/elastictranscoder.js @@ -1,56 +1,72 @@ module.exports = function() { - this.Before("@elastictranscoder", function (callback) { + this.Before("@elastictranscoder", function(callback) { this.iam = new this.AWS.IAM(); this.s3 = new this.AWS.S3(); this.service = new this.AWS.ElasticTranscoder(); callback(); }); - this.Given(/^I create an Elastic Transcoder pipeline with name prefix "([^"]*)"$/, function(prefix, callback) { - this.pipelineName = this.uniqueName(prefix); - var params = { - Name: this.pipelineName, - InputBucket: this.bucket, - OutputBucket: this.bucket, - Role: this.iamRoleArn, - Notifications: {"Progressing":"","Completed":"","Warning":"","Error":""} - }; - - var world = this; - var next = function() { - if (world.data) world.pipelineId = world.data.Pipeline.Id; - callback(); - } + this.Given( + /^I create an Elastic Transcoder pipeline with name prefix "([^"]*)"$/, + function(prefix, callback) { + this.pipelineName = this.uniqueName(prefix); + var params = { + Name: this.pipelineName, + InputBucket: this.bucket, + OutputBucket: this.bucket, + Role: this.iamRoleArn, + Notifications: { + Progressing: "", + Completed: "", + Warning: "", + Error: "" + } + }; - this.request(null, 'createPipeline', params, next, false); - }); + var world = this; + var next = function() { + if (world.data) world.pipelineId = world.data.Pipeline.Id; + callback(); + }; + + this.request(null, "createPipeline", params, next, false); + } + ); this.Given(/^I list pipelines$/, function(callback) { - this.request(null, 'listPipelines', {}, callback); + this.request(null, "listPipelines", {}, callback); }); this.Then(/^the list should contain the pipeline$/, function(callback) { var id = this.pipelineId; - this.assert.contains(this.data.Pipelines, function (pipeline) { + this.assert.contains(this.data.Pipelines, function(pipeline) { return pipeline.Id === id; }); callback(); }); this.Then(/^I pause the pipeline$/, function(callback) { - this.request(null, 'updatePipelineStatus', {Id:this.pipelineId, Status: 'Paused'}, callback); + this.request( + null, + "updatePipelineStatus", + { Id: this.pipelineId, Status: "Paused" }, + callback + ); }); this.Then(/^I read the pipeline$/, function(callback) { - this.request(null, 'readPipeline', {Id: this.pipelineId}, callback); + this.request(null, "readPipeline", { Id: this.pipelineId }, callback); }); - this.Then(/^the pipeline status should be "([^"]*)"$/, function(status, callback) { + this.Then(/^the pipeline status should be "([^"]*)"$/, function( + status, + callback + ) { this.assert.equal(this.data.Pipeline.Status, status); callback(); }); this.Then(/^I delete the pipeline$/, function(callback) { - this.request(null, 'deletePipeline', {Id: this.pipelineId}, callback); + this.request(null, "deletePipeline", { Id: this.pipelineId }, callback); }); }; diff --git a/features/elb/step_definitions/elb.js b/features/elb/step_definitions/elb.js index 4656bada2be0..5230abf069f1 100644 --- a/features/elb/step_definitions/elb.js +++ b/features/elb/step_definitions/elb.js @@ -1,26 +1,34 @@ -var { ElasticLoadBalancing } = require('../../../clients/node/client-elastic-load-balancing-node'); +var { + ElasticLoadBalancing +} = require("../../../clients/node/client-elastic-load-balancing-node"); module.exports = function() { - this.Before("@elb", function (callback) { + this.Before("@elb", function(callback) { this.service = new ElasticLoadBalancing({}); callback(); }); - this.Given(/^I create a load balancer with name prefix "([^"]*)"$/, function(prefix, callback) { - this.loadBalancerName = prefix + '-' + new Date().getTime(); + this.Given(/^I create a load balancer with name prefix "([^"]*)"$/, function( + prefix, + callback + ) { + this.loadBalancerName = prefix + "-" + new Date().getTime(); var params = { LoadBalancerName: this.loadBalancerName, - Listeners: [{Protocol: 'TCP', LoadBalancerPort: 80, InstancePort: 80}], - AvailabilityZones: ['us-east-1a'] + Listeners: [{ Protocol: "TCP", LoadBalancerPort: 80, InstancePort: 80 }], + AvailabilityZones: ["us-east-1a"] }; - this.request(null, 'createLoadBalancer', params, callback, false); + this.request(null, "createLoadBalancer", params, callback, false); }); - this.Given(/^I describe load balancers with the load balancer name$/, function(callback) { - var params = {LoadBalancerNames: [this.loadBalancerName]}; - this.request(null, 'describeLoadBalancers', params, callback); - }); + this.Given( + /^I describe load balancers with the load balancer name$/, + function(callback) { + var params = { LoadBalancerNames: [this.loadBalancerName] }; + this.request(null, "describeLoadBalancers", params, callback); + } + ); this.Then(/^the load balancer should be in the list$/, function(callback) { var name = this.data.LoadBalancerDescriptions[0].LoadBalancerName; @@ -29,11 +37,13 @@ module.exports = function() { }); this.Then(/^I delete the load balancer$/, function(callback) { - var params = {LoadBalancerName: this.loadBalancerName}; - this.request(null, 'deleteLoadBalancer', params, callback); + var params = { LoadBalancerName: this.loadBalancerName }; + this.request(null, "deleteLoadBalancer", params, callback); }); - this.Given(/^I try to create a load balancer with no name$/, function(callback) { - this.request(null, 'createLoadBalancer', {}, callback); + this.Given(/^I try to create a load balancer with no name$/, function( + callback + ) { + this.request(null, "createLoadBalancer", {}, callback); }); }; diff --git a/features/elbv2/step_definitions/elbv2.js b/features/elbv2/step_definitions/elbv2.js index 8c6b0c3f9ae5..a76207bb0fe3 100644 --- a/features/elbv2/step_definitions/elbv2.js +++ b/features/elbv2/step_definitions/elbv2.js @@ -1,7 +1,9 @@ -var { ElasticLoadBalancingv2 } = require('../../../clients/node/client-elastic-load-balancing-v2-node'); +var { + ElasticLoadBalancingv2 +} = require("../../../clients/node/client-elastic-load-balancing-v2-node"); module.exports = function() { - this.Before("@elbv2", function (callback) { + this.Before("@elbv2", function(callback) { this.service = new ElasticLoadBalancingv2({}); callback(); }); diff --git a/features/emr/step_definitions/emr.js b/features/emr/step_definitions/emr.js index 697299944e69..cf80e3d550e6 100644 --- a/features/emr/step_definitions/emr.js +++ b/features/emr/step_definitions/emr.js @@ -1,14 +1,16 @@ -var { EMR } = require('../../../clients/node/client-emr-node'); +var { EMR } = require("../../../clients/node/client-emr-node"); module.exports = function() { - this.Before("@emr", function (callback) { + this.Before("@emr", function(callback) { this.service = new EMR({}); callback(); }); - this.Given(/^I run an EMR job flow with invalid parameters$/, function(callback) { + this.Given(/^I run an EMR job flow with invalid parameters$/, function( + callback + ) { this.service = new EMR({}); - var params = {Name: '', Instances: {MasterInstanceType: 'invalid'}}; - this.request(null, 'runJobFlow', params, callback, false); + var params = { Name: "", Instances: { MasterInstanceType: "invalid" } }; + this.request(null, "runJobFlow", params, callback, false); }); }; diff --git a/features/es/step_definitions/es.js b/features/es/step_definitions/es.js index a4f46eb08a02..2b36a77e5960 100644 --- a/features/es/step_definitions/es.js +++ b/features/es/step_definitions/es.js @@ -1,7 +1,9 @@ -var { ElasticsearchService } = require('../../../clients/node/client-elasticsearch-service-node'); +var { + ElasticsearchService +} = require("../../../clients/node/client-elasticsearch-service-node"); module.exports = function() { - this.Before("@es", function (callback) { + this.Before("@es", function(callback) { this.service = new ElasticsearchService({}); callback(); }); diff --git a/features/extra/assertions.js b/features/extra/assertions.js index 2b47a9025dd9..4ce7a7e7724f 100644 --- a/features/extra/assertions.js +++ b/features/extra/assertions.js @@ -1,26 +1,33 @@ -var assert = require('assert'); +var assert = require("assert"); assert.match = function assertMatches(string, matcher, message) { - assert.ok(string.match(matcher), message || - 'Expected ' + string + ' to match ' + matcher); + assert.ok( + string.match(matcher), + message || "Expected " + string + " to match " + matcher + ); }; assert.contains = function assertContains(list, matcher, message) { var found = false; for (var i in list) { if (!list.hasOwnProperty(i)) continue; - if (typeof matcher === 'function') { + if (typeof matcher === "function") { found = matcher(list[i]); } else { - found = (list[i] === matcher); + found = list[i] === matcher; } if (found) return; } - assert.fail(list, matcher, message, 'does not contain'); + assert.fail(list, matcher, message, "does not contain"); }; -assert.compare = function assertComparison(actual, operator, expected, message) { - var compare = actual + ' ' + operator + ' ' + expected; +assert.compare = function assertComparison( + actual, + operator, + expected, + message +) { + var compare = actual + " " + operator + " " + expected; assert.ok(eval(compare), message || compare); }; diff --git a/features/extra/cleanup.js b/features/extra/cleanup.js index f2686b69d148..d42b3f4b1ffe 100644 --- a/features/extra/cleanup.js +++ b/features/extra/cleanup.js @@ -1,13 +1,12 @@ module.exports = function() { - /** * Cleanup fixtures and resources. The world does not exist when * this handler is executed. Only resource cleanup and shutdown * should happen here. */ - this.registerHandler('AfterFeatures', function(event, callback) { - var path = require('path'); - var fs = require('fs'); + this.registerHandler("AfterFeatures", function(event, callback) { + var path = require("path"); + var fs = require("fs"); // Reintroduce when writing S3 integration tests // try { @@ -33,9 +32,9 @@ module.exports = function() { * Delete fixtures */ var deleteFixtures = function() { - var fs = require('fs'); - var path = require('path'); - var fixturePath = path.resolve('./features/extra/fixtures/tmp'); + var fs = require("fs"); + var path = require("path"); + var fixturePath = path.resolve("./features/extra/fixtures/tmp"); if (fs.existsSync(fixturePath)) { fs.readdirSync(fixturePath).forEach(function(file) { fs.unlinkSync(path.join(fixturePath, file)); @@ -73,8 +72,8 @@ module.exports = function() { * Delete bucket */ var deleteBucket = function(bucket, callback) { - var s3 = new AWS.S3({maxRetries: 100}); - s3.deleteBucket({Bucket: bucket}, function(err, data) { + var s3 = new AWS.S3({ maxRetries: 100 }); + s3.deleteBucket({ Bucket: bucket }, function(err, data) { callback(err); }); }; @@ -83,17 +82,17 @@ module.exports = function() { * Delete objects. */ var deleteObjects = function(bucket, callback) { - var s3 = new AWS.S3({maxRetries: 100}); + var s3 = new AWS.S3({ maxRetries: 100 }); var params = { Bucket: bucket }; - s3.listObjects(params, function (err, data) { + s3.listObjects(params, function(err, data) { if (err) return callback(err); if (data.Contents.length > 0) { params.Delete = { Objects: [] }; - data.Contents.forEach(function (item) { - params.Delete.Objects.push({Key: item.Key}); + data.Contents.forEach(function(item) { + params.Delete.Objects.push({ Key: item.Key }); }); s3.deleteObjects(params, callback); } else { diff --git a/features/extra/helpers.js b/features/extra/helpers.js index c5533e34c738..37fa42cb9f6d 100644 --- a/features/extra/helpers.js +++ b/features/extra/helpers.js @@ -1,10 +1,9 @@ module.exports = { - - assert: require('./assertions').assert, + assert: require("./assertions").assert, uniqueName: function uniqueName(base, sep) { - if (sep === undefined) sep = '-'; - if (base === '') return ''; + if (sep === undefined) sep = "-"; + if (base === "") return ""; return base + sep + new Date().getTime(); }, @@ -31,7 +30,6 @@ module.exports = { * maxTime: Maximum duration of milliseconds to wait for success. */ eventually: function eventually(callback, block, options) { - if (!options) options = {}; if (!options.delay) options.delay = 0; if (!options.backoff) options.backoff = 500; @@ -41,21 +39,22 @@ module.exports = { var started = this.AWS.util.date.getDate(); var self = this; - var retry = function() { callback(); }; + var retry = function() { + callback(); + }; retry.fail = function(err) { var now = self.AWS.util.date.getDate(); if (now - started < options.maxTime * 1000) { - setTimeout(function () { + setTimeout(function() { delay += options.backoff; block.call(self, retry); }, delay); } else { - callback.fail(err || new Error('Eventually block timed out')); + callback.fail(err || new Error("Eventually block timed out")); } }; block.call(this, retry); - }, /** @@ -66,7 +65,7 @@ module.exports = { var world = this; if (!svc) svc = this.service; - if (typeof svc === 'string') svc = this[svc]; + if (typeof svc === "string") svc = this[svc]; svc[operation](params, function(err, data) { world.response = this; @@ -74,10 +73,10 @@ module.exports = { world.data = data; try { - if (typeof next.condition === 'function') { + if (typeof next.condition === "function") { var condition = next.condition.call(world, world); if (!condition) { - next.fail(new Error('Request success condition failed')); + next.fail(new Error("Request success condition failed")); return; } } @@ -85,8 +84,7 @@ module.exports = { if (extra) { extra.call(world, world.data); next.call(world); - } - else if (extra !== false && err) { + } else if (extra !== false && err) { world.unexpectedError( svc.config.signingName, operation, @@ -109,18 +107,18 @@ module.exports = { * operation failed. */ unexpectedError: function unexpectedError(svc, op, name, msg, next) { - next.fail(new Error( - `Received unexpected error from ${svc}.${op}, ${name}: ${msg}` - )); + next.fail( + new Error(`Received unexpected error from ${svc}.${op}, ${name}: ${msg}`) + ); }, /** * Cache bucket names used for cleanup after all features have run. */ cacheBucketName: function(bucket) { - var fs = require('fs'); - var path = require('path'); - var filePath = path.resolve('integ.buckets.json'); + var fs = require("fs"); + var path = require("path"); + var filePath = path.resolve("integ.buckets.json"); var cache; if (fs.existsSync(filePath)) { try { @@ -141,22 +139,28 @@ module.exports = { * Creates a fixture file of given size and returns the path. */ createFile: function(size, name) { - var fs = require('fs'); - var path = require('path'); + var fs = require("fs"); + var path = require("path"); name = this.uniqueName(name); // Cannot set this as a world property because the world // is cleaned up before the AfterFeatures hook is fired. - var fixturePath = path.resolve('./features/extra/fixtures/tmp'); + var fixturePath = path.resolve("./features/extra/fixtures/tmp"); if (!fs.existsSync(fixturePath)) fs.mkdirSync(fixturePath); var filename = path.join(fixturePath, name); var body; - if (typeof size === 'string') { + if (typeof size === "string") { switch (size) { - case 'empty': body = Buffer.alloc(0); break; - case 'small': body = Buffer.alloc(1024 * 1024); break; - case 'large': body = Buffer.alloc(1024 * 1024 * 20); break; + case "empty": + body = Buffer.alloc(0); + break; + case "small": + body = Buffer.alloc(1024 * 1024); + break; + case "large": + body = Buffer.alloc(1024 * 1024 * 20); + break; } - } else if (typeof size === 'number') { + } else if (typeof size === "number") { body = Buffer.alloc(size); } @@ -170,20 +174,26 @@ module.exports = { createBuffer: function(size) { var match; var buffer; - if (match = size.match(/(\d+)KB/)) { + if ((match = size.match(/(\d+)KB/))) { buffer = Buffer.alloc(parseInt(match[1]) * 1024); - } else if (match = size.match(/(\d+)MB/)) { + } else if ((match = size.match(/(\d+)MB/))) { buffer = Buffer.alloc(parseInt(match[1]) * 1024 * 1024); } else { switch (size) { - case 'empty': buffer = Buffer.alloc(0); break; - case 'small': buffer = Buffer.alloc(1024 * 1024); break; - case 'large': buffer = Buffer.alloc(1024 * 1024 * 20); break; - default: return Buffer.alloc(1024 * 1024); + case "empty": + buffer = Buffer.alloc(0); + break; + case "small": + buffer = Buffer.alloc(1024 * 1024); + break; + case "large": + buffer = Buffer.alloc(1024 * 1024 * 20); + break; + default: + return Buffer.alloc(1024 * 1024); } } - buffer.fill('x'); + buffer.fill("x"); return buffer; } - }; diff --git a/features/extra/hooks.js b/features/extra/hooks.js index c82260f873fb..d0198b706efe 100644 --- a/features/extra/hooks.js +++ b/features/extra/hooks.js @@ -1,8 +1,8 @@ -var util = require('util'); -var jmespath = require('jmespath'); +var util = require("util"); +var jmespath = require("jmespath"); -module.exports = function () { - this.World = require('./world.js').World; +module.exports = function() { + this.World = require("./world.js").World; this.Before(function(callback) { this.params = {}; @@ -13,8 +13,12 @@ module.exports = function () { this.Given(/^I create a shared bucket$/, function(callback) { if (this.sharedBucket) return callback(); - var bucket = this.sharedBucket = this.uniqueName('aws-sdk-js-shared-integration'); - this.request('s3', 'createBucket', {Bucket: this.sharedBucket}, function(err) { + var bucket = (this.sharedBucket = this.uniqueName( + "aws-sdk-js-shared-integration" + )); + this.request("s3", "createBucket", { Bucket: this.sharedBucket }, function( + err + ) { this.cacheBucketName(this.sharedBucket); if (err) { callback.fail(err); @@ -22,76 +26,105 @@ module.exports = function () { if (err) { return callback(err); } - this.s3.waitFor('bucketExists', {Bucket: bucket}, callback); + this.s3.waitFor("bucketExists", { Bucket: bucket }, callback); } }); }); this.Given(/^I create a bucket$/, function(callback) { - var bucket = this.bucket = this.uniqueName('aws-sdk-js-integration'); - this.request('s3', 'createBucket', {Bucket: this.bucket}, function(err, data) { + var bucket = (this.bucket = this.uniqueName("aws-sdk-js-integration")); + this.request("s3", "createBucket", { Bucket: this.bucket }, function( + err, + data + ) { if (err) { return callback(err); } - this.s3.waitFor('bucketExists', {Bucket: bucket}, callback); + this.s3.waitFor("bucketExists", { Bucket: bucket }, callback); }); }); this.When(/^I delete the bucket$/, function(callback) { - this.request('s3', 'deleteBucket', {Bucket: this.bucket}, callback); + this.request("s3", "deleteBucket", { Bucket: this.bucket }, callback); }); this.Then(/^the bucket should exist$/, function(next) { - this.s3.waitFor('bucketExists', {Bucket: this.bucket}, next); + this.s3.waitFor("bucketExists", { Bucket: this.bucket }, next); }); this.Then(/^the bucket should not exist$/, function(callback) { - this.s3.waitFor('bucketNotExists', {Bucket: this.bucket}, callback); + this.s3.waitFor("bucketNotExists", { Bucket: this.bucket }, callback); }); /* Global error code steps */ - this.Given(/^I run the "([^"]*)" operation$/, function (operation, callback) { + this.Given(/^I run the "([^"]*)" operation$/, function(operation, callback) { this.request(null, operation, {}, callback, false); }); - this.Given(/^I run the "([^"]*)" operation with params:$/, function (operation, params, callback) { + this.Given(/^I run the "([^"]*)" operation with params:$/, function( + operation, + params, + callback + ) { this.request(null, operation, JSON.parse(params), callback, false); }); - this.Then(/^the request should be successful$/, function (callback) { - this.assert.ok(!this.error, 'Response was not successful'); + this.Then(/^the request should be successful$/, function(callback) { + this.assert.ok(!this.error, "Response was not successful"); callback(); }); - this.Then(/^the value at "([^"]*)" should be a list$/, function (path, callback) { + this.Then(/^the value at "([^"]*)" should be a list$/, function( + path, + callback + ) { var value = jmespath.search(this.data, path); - this.assert.ok(Array.isArray(value), 'expected ' + util.inspect(value) + ' to be a list'); + this.assert.ok( + Array.isArray(value), + "expected " + util.inspect(value) + " to be a list" + ); callback(); }); - this.Then(/^the value at "([^"]*)" should be a number$/, function (path, callback) { + this.Then(/^the value at "([^"]*)" should be a number$/, function( + path, + callback + ) { var value = jmespath.search(this.data, path); - this.assert.ok(typeof value === 'number', 'expected ' + util.inspect(value) + ' to be a number'); + this.assert.ok( + typeof value === "number", + "expected " + util.inspect(value) + " to be a number" + ); callback(); }); - this.Then(/^the value at "([^"]*)" should be a string$/, function (path, callback) { + this.Then(/^the value at "([^"]*)" should be a string$/, function( + path, + callback + ) { var value = jmespath.search(this.data, path); - this.assert.ok(typeof value === 'string', 'expected ' + util.inspect(value) + ' to be a string'); + this.assert.ok( + typeof value === "string", + "expected " + util.inspect(value) + " to be a string" + ); callback(); }); this.Then(/^the error code should be "([^"]*)"$/, function(code, callback) { - this.assert.ok(this.error, 'Response does not contain an error'); + this.assert.ok(this.error, "Response does not contain an error"); this.assert.equal(this.error.name, code); callback(); }); - this.Then(/^the error message should (be|equal|match|contain):$/, function(matcher, message, callback) { - if (matcher === 'be') matcher = 'equal'; - if (matcher === 'contain') matcher = 'match'; - this.assert.ok(this.error, 'Response does not contain an error'); + this.Then(/^the error message should (be|equal|match|contain):$/, function( + matcher, + message, + callback + ) { + if (matcher === "be") matcher = "equal"; + if (matcher === "contain") matcher = "match"; + this.assert.ok(this.error, "Response does not contain an error"); this.assert[matcher](this.error.message, message); callback(); }); @@ -106,7 +139,10 @@ module.exports = function () { callback(); }); - this.Then(/^the error status code should be (\d+)$/, function(status, callback) { + this.Then(/^the error status code should be (\d+)$/, function( + status, + callback + ) { this.assert.equal(this.error.$metadata.httpStatusCode, parseInt(status)); callback(); }); @@ -118,48 +154,54 @@ module.exports = function () { callback(); }); - this.Given(/^I have a "([^"]*)" service in the "([^"]*)" region$/, function(svc, region, callback) { + this.Given(/^I have a "([^"]*)" service in the "([^"]*)" region$/, function( + svc, + region, + callback + ) { this.service = new this.AWS[svc]({ region: region }); callback(); }); - this.Given(/^I paginate the "([^"]*)" operation(?: with limit (\d+))?(?: and max pages (\d+))?$/, function(operation, limit, maxPages, callback) { - limit = parseInt(limit); - if (maxPages) maxPages = parseInt(maxPages); + this.Given( + /^I paginate the "([^"]*)" operation(?: with limit (\d+))?(?: and max pages (\d+))?$/, + function(operation, limit, maxPages, callback) { + limit = parseInt(limit); + if (maxPages) maxPages = parseInt(maxPages); - var world = this; - this.numPages = 0; - this.numMarkers = 0; - this.operation = operation; - this.paginationConfig = this.service.paginationConfig(operation); - this.params = this.params || {}; + var world = this; + this.numPages = 0; + this.numMarkers = 0; + this.operation = operation; + this.paginationConfig = this.service.paginationConfig(operation); + this.params = this.params || {}; - var marker = this.paginationConfig.outputToken; - if (this.paginationConfig.limitKey) { - this.params[this.paginationConfig.limitKey] = limit; - } - this.service[operation](this.params).eachPage(function (err, data) { - if (err) callback.fail(err); - else if (data === null) callback(); - else if (maxPages && world.numPages === maxPages) { - callback(); - return false; - } - else { - if (data[marker]) world.numMarkers++; - world.numPages++; - world.data = data; + var marker = this.paginationConfig.outputToken; + if (this.paginationConfig.limitKey) { + this.params[this.paginationConfig.limitKey] = limit; } - }); - }); + this.service[operation](this.params).eachPage(function(err, data) { + if (err) callback.fail(err); + else if (data === null) callback(); + else if (maxPages && world.numPages === maxPages) { + callback(); + return false; + } else { + if (data[marker]) world.numMarkers++; + world.numPages++; + world.data = data; + } + }); + } + ); this.Then(/^I should get more than one page$/, function(callback) { - this.assert.compare(this.numPages, '>', 1); + this.assert.compare(this.numPages, ">", 1); callback(); }); this.Then(/^I should get at least one page$/, function(callback) { - this.assert.compare(this.numPages, '>=', 1); + this.assert.compare(this.numPages, ">=", 1); callback(); }); @@ -179,23 +221,33 @@ module.exports = function () { callback(); }); - - this.Then(/^the result at (\w+) should contain a property (\w+) with an? (\w+)$/, function(wrapper, property, type, callback) { - if (type === 'Array' || type === 'Date') { - this.assert.equal(this.AWS.util.isType(this.data[wrapper][property], type), true); - } else { - this.assert.equal(typeof this.data[wrapper][property], type); + this.Then( + /^the result at (\w+) should contain a property (\w+) with an? (\w+)$/, + function(wrapper, property, type, callback) { + if (type === "Array" || type === "Date") { + this.assert.equal( + this.AWS.util.isType(this.data[wrapper][property], type), + true + ); + } else { + this.assert.equal(typeof this.data[wrapper][property], type); + } + callback(); } - callback(); - }); - - this.Then(/^the result should contain a property (\w+) with an? (\w+)$/, function(property, type, callback) { - if (type === 'Array' || type === 'Date') { - this.assert.equal(this.AWS.util.isType(this.data[property], type), true); - } else { - this.assert.equal(typeof this.data[property], type); + ); + + this.Then( + /^the result should contain a property (\w+) with an? (\w+)$/, + function(property, type, callback) { + if (type === "Array" || type === "Date") { + this.assert.equal( + this.AWS.util.isType(this.data[property], type), + true + ); + } else { + this.assert.equal(typeof this.data[property], type); + } + callback(); } - callback(); - }); - + ); }; diff --git a/features/extra/world.js b/features/extra/world.js index d3d7f3034ee5..bc1cfec0ede3 100644 --- a/features/extra/world.js +++ b/features/extra/world.js @@ -1,13 +1,12 @@ -var world = require('./helpers'); -var fs = require('fs'); -var path = require('path'); +var world = require("./helpers"); +var fs = require("fs"); +var path = require("path"); try { - world.config = JSON.parse( - fs.readFileSync(path.resolve('./configuration')) - ); -} catch (e) {} finally { - process.env['CONFIGURED_REGION'] = 'us-west-2'; + world.config = JSON.parse(fs.readFileSync(path.resolve("./configuration"))); +} catch (e) { +} finally { + process.env["CONFIGURED_REGION"] = "us-west-2"; } var WorldConstructor = function WorldConstructor(callback) { diff --git a/features/gamelift/step_definitions/gamelift.js b/features/gamelift/step_definitions/gamelift.js index 3c7771ef0d86..cde37a701f00 100644 --- a/features/gamelift/step_definitions/gamelift.js +++ b/features/gamelift/step_definitions/gamelift.js @@ -1,7 +1,7 @@ -var { GameLift } = require('../../../clients/node/client-gamelift-node'); +var { GameLift } = require("../../../clients/node/client-gamelift-node"); module.exports = function() { - this.Before("@gamelift", function (callback) { + this.Before("@gamelift", function(callback) { this.service = new GameLift({}); callback(); }); diff --git a/features/glacier/step_definitions/glacier.js b/features/glacier/step_definitions/glacier.js index d86162e6e0ed..0884b5f10893 100644 --- a/features/glacier/step_definitions/glacier.js +++ b/features/glacier/step_definitions/glacier.js @@ -1,83 +1,101 @@ module.exports = function() { - this.Before("@glacier", function (callback) { + this.Before("@glacier", function(callback) { this.service = new this.AWS.Glacier(); callback(); }); this.Given(/^I have a Glacier vault$/, function(callback) { - this.vaultName = 'aws-sdk-js-integration'; - var params = {vaultName: this.vaultName}; - this.request(null, 'createVault', params, callback, false); + this.vaultName = "aws-sdk-js-integration"; + var params = { vaultName: this.vaultName }; + this.request(null, "createVault", params, callback, false); }); - this.Given(/^I upload a (\d+(?:\.\d+)?)MB Glacier archive to the vault( with (?:invalid|incorrect) checksum)?$/, function(size, invalid, callback) { - var data = Buffer.alloc(parseFloat(size) * 1024 * 1024); - data.fill('0'); - var params = {vaultName: this.vaultName, body: data}; - if (invalid) { - if (invalid.match("invalid")) params.checksum = '000'; - else params.checksum = '00000000000000000000000000000000'; + this.Given( + /^I upload a (\d+(?:\.\d+)?)MB Glacier archive to the vault( with (?:invalid|incorrect) checksum)?$/, + function(size, invalid, callback) { + var data = Buffer.alloc(parseFloat(size) * 1024 * 1024); + data.fill("0"); + var params = { vaultName: this.vaultName, body: data }; + if (invalid) { + if (invalid.match("invalid")) params.checksum = "000"; + else params.checksum = "00000000000000000000000000000000"; + } + this.request(null, "uploadArchive", params, callback, false); } - this.request(null, 'uploadArchive', params, callback, false); - }); + ); - this.Then(/^the result should contain the Glacier archive ID$/, function(callback) { + this.Then(/^the result should contain the Glacier archive ID$/, function( + callback + ) { this.archiveId = this.data.archiveId; callback(); }); - this.Then(/^the result should contain the same tree hash checksum$/, function(callback) { - var hash = this.response.request.httpRequest.headers['x-amz-sha256-tree-hash']; + this.Then(/^the result should contain the same tree hash checksum$/, function( + callback + ) { + var hash = this.response.request.httpRequest.headers[ + "x-amz-sha256-tree-hash" + ]; this.assert.equal(this.data.checksum, hash); callback(); }); this.When(/^I describe the Glacier vault$/, function(callback) { - var params = {vaultName: this.vaultName}; - this.request(null, 'describeVault', params, callback); + var params = { vaultName: this.vaultName }; + this.request(null, "describeVault", params, callback); }); this.Then(/^I delete the Glacier archive$/, function(callback) { - var params = {vaultName: this.vaultName, archiveId: this.archiveId}; - this.request(null, 'deleteArchive', params, callback); + var params = { vaultName: this.vaultName, archiveId: this.archiveId }; + this.request(null, "deleteArchive", params, callback); }); this.Then(/^I delete the Glacier vault$/, function(callback) { - var params = {vaultName: this.vaultName}; + var params = { vaultName: this.vaultName }; this.eventually(callback, function(next) { - this.request(null, 'deleteVault', params, next); + this.request(null, "deleteVault", params, next); }); }); - this.When(/^I initiate a Glacier multi-part upload on a (\d+(?:\.\d+)?)MB archive in (\d+)MB chunks$/, function(totalSize, partSize, callback) { - // setup multi-part upload - this.uploadData = Buffer.alloc(totalSize * 1024 * 1024); - this.uploadData.fill('0'); - this.checksums = this.service.computeChecksums(this.uploadData); - this.partCounter = 0; - this.partSize = partSize * 1024 * 1024; + this.When( + /^I initiate a Glacier multi-part upload on a (\d+(?:\.\d+)?)MB archive in (\d+)MB chunks$/, + function(totalSize, partSize, callback) { + // setup multi-part upload + this.uploadData = Buffer.alloc(totalSize * 1024 * 1024); + this.uploadData.fill("0"); + this.checksums = this.service.computeChecksums(this.uploadData); + this.partCounter = 0; + this.partSize = partSize * 1024 * 1024; - var params = {vaultName: this.vaultName, partSize: this.partSize.toString()}; - this.request(null, 'initiateMultipartUpload', params, callback); - }); + var params = { + vaultName: this.vaultName, + partSize: this.partSize.toString() + }; + this.request(null, "initiateMultipartUpload", params, callback); + } + ); - this.Then(/^the result should contain the Glacier multi-part upload ID$/, function(callback) { - this.uploadId = this.data.uploadId; - callback(); - }); + this.Then( + /^the result should contain the Glacier multi-part upload ID$/, + function(callback) { + this.uploadId = this.data.uploadId; + callback(); + } + ); this.Then(/^I send the next part$/, function(callback) { var start = this.partCounter; var end = Math.min(start + this.partSize, this.uploadData.length); var buf = this.uploadData.slice(start, end); - var range = 'bytes ' + start + '-' + (end - 1) + '/*'; + var range = "bytes " + start + "-" + (end - 1) + "/*"; var params = { vaultName: this.vaultName, uploadId: this.uploadId, range: range, body: buf }; - this.request(null, 'uploadMultipartPart', params, callback); + this.request(null, "uploadMultipartPart", params, callback); this.partCounter += this.partSize; }); @@ -86,7 +104,7 @@ module.exports = function() { for (var i = 0; i < this.uploadData.length; i += this.partSize) { var end = Math.min(i + this.partSize, this.uploadData.length); var buf = this.uploadData.slice(i, end); - var range = 'bytes ' + i + '-' + (end - 1) + '/*'; + var range = "bytes " + i + "-" + (end - 1) + "/*"; var params = { vaultName: this.vaultName, uploadId: this.uploadId, @@ -106,7 +124,6 @@ module.exports = function() { archiveSize: this.uploadData.length.toString(), checksum: this.checksums.treeHash }; - this.request(null, 'completeMultipartUpload', params, callback); + this.request(null, "completeMultipartUpload", params, callback); }); - }; diff --git a/features/iam/step_definitions/iam.js b/features/iam/step_definitions/iam.js index 4a296221bddd..3b92e80c0f24 100644 --- a/features/iam/step_definitions/iam.js +++ b/features/iam/step_definitions/iam.js @@ -1,11 +1,11 @@ module.exports = function() { - this.Before("@iam", function (callback) { + this.Before("@iam", function(callback) { this.iam = new this.AWS.IAM(); callback(); }); this.Given(/^I have an IAM username "([^"]*)"$/, function(name, callback) { - this.iamUserArn = ''; + this.iamUserArn = ""; this.iamUser = this.uniqueName(name); callback(); }); @@ -18,11 +18,11 @@ module.exports = function() { callback(); }; next.fail = callback.fail; - this.request('iam', 'createUser', {UserName: this.iamUser}, next, false); + this.request("iam", "createUser", { UserName: this.iamUser }, next, false); }); this.Given(/^I list the IAM users$/, function(callback) { - this.request('iam', 'listUsers', {}, callback); + this.request("iam", "listUsers", {}, callback); }); this.Then(/^the list should contain the user$/, function(callback) { @@ -34,33 +34,39 @@ module.exports = function() { }); this.Then(/^I delete the IAM user$/, function(callback) { - this.request('iam', 'deleteUser', {UserName: this.iamUser}, callback); + this.request("iam", "deleteUser", { UserName: this.iamUser }, callback); }); - this.Given(/^I create an IAM role with name prefix "([^"]*)"$/, function(name, callback) { + this.Given(/^I create an IAM role with name prefix "([^"]*)"$/, function( + name, + callback + ) { this.iamRoleName = this.uniqueName(name); var world = this; - var assumeRolePolicyDocument = '{"Version":"2008-10-17","Statement":[' + + var assumeRolePolicyDocument = + '{"Version":"2008-10-17","Statement":[' + '{"Effect":"Allow","Principal":{"Service":["ec2.amazonaws.com"]},' + '"Action":["sts:AssumeRole"]}]}'; - var params = {RoleName: this.iamRoleName, - AssumeRolePolicyDocument: assumeRolePolicyDocument}; + var params = { + RoleName: this.iamRoleName, + AssumeRolePolicyDocument: assumeRolePolicyDocument + }; var next = function() { world.iamRoleArn = world.data.Role.Arn; callback(); - } + }; next.fail = callback.fail; - this.request('iam', 'createRole', params, next); + this.request("iam", "createRole", params, next); }); this.Then(/^the IAM role should exist$/, function(callback) { - this.assert.compare(this.iamRoleArn.length, '>', 0); + this.assert.compare(this.iamRoleArn.length, ">", 0); callback(); }); this.Then(/^I delete the IAM role$/, function(callback) { - this.request('iam', 'deleteRole', {RoleName: this.iamRoleName}, callback); + this.request("iam", "deleteRole", { RoleName: this.iamRoleName }, callback); }); }; diff --git a/features/inspector/step_definitions/inspector.js b/features/inspector/step_definitions/inspector.js index 192c01e540da..7d527ff23bfe 100644 --- a/features/inspector/step_definitions/inspector.js +++ b/features/inspector/step_definitions/inspector.js @@ -1,8 +1,8 @@ -var { Inspector } = require('../../../clients/node/client-inspector-node'); +var { Inspector } = require("../../../clients/node/client-inspector-node"); module.exports = function() { - this.Before("@inspector", function (callback) { - this.service = new Inspector({region: 'us-west-2'}); + this.Before("@inspector", function(callback) { + this.service = new Inspector({ region: "us-west-2" }); callback(); }); diff --git a/features/iot/step_definitions/iot.js b/features/iot/step_definitions/iot.js index d4e917464b66..f57b829fd4ec 100644 --- a/features/iot/step_definitions/iot.js +++ b/features/iot/step_definitions/iot.js @@ -1,7 +1,7 @@ -var { IoT } = require('../../../clients/node/client-iot-node'); +var { IoT } = require("../../../clients/node/client-iot-node"); module.exports = function() { - this.Before("@iot", function (callback) { + this.Before("@iot", function(callback) { this.service = new IoT({}); callback(); }); diff --git a/features/kinesis/step_definitions/kinesis.js b/features/kinesis/step_definitions/kinesis.js index bffae288ffab..451d415063e3 100644 --- a/features/kinesis/step_definitions/kinesis.js +++ b/features/kinesis/step_definitions/kinesis.js @@ -1,12 +1,18 @@ -var { Kinesis } = require('../../../clients/node/client-kinesis-node'); +var { Kinesis } = require("../../../clients/node/client-kinesis-node"); module.exports = function() { - this.Before("@kinesis", function (callback) { + this.Before("@kinesis", function(callback) { this.service = new Kinesis({}); callback(); }); this.Given(/^I try to describe a stream in Kinesis$/, function(callback) { - this.request(null, 'describeStream', {StreamName: 'XXINVALIDXX'}, callback, false); + this.request( + null, + "describeStream", + { StreamName: "XXINVALIDXX" }, + callback, + false + ); }); }; diff --git a/features/kms/step_definitions/kms.js b/features/kms/step_definitions/kms.js index df8189b7f261..65f5f9c0a3f8 100644 --- a/features/kms/step_definitions/kms.js +++ b/features/kms/step_definitions/kms.js @@ -1,7 +1,7 @@ -var { KMS } = require('../../../clients/node/client-kms-node'); +var { KMS } = require("../../../clients/node/client-kms-node"); module.exports = function() { - this.Before("@kms", function (callback) { + this.Before("@kms", function(callback) { this.service = new KMS({}); callback(); }); diff --git a/features/lambda/step_definitions/lambda.js b/features/lambda/step_definitions/lambda.js index 400d89f9e91f..fb1e7a5f8301 100644 --- a/features/lambda/step_definitions/lambda.js +++ b/features/lambda/step_definitions/lambda.js @@ -1,7 +1,7 @@ -var { Lambda } = require('../../../clients/node/client-lambda-node'); +var { Lambda } = require("../../../clients/node/client-lambda-node"); module.exports = function() { - this.Before("@lambda", function (callback) { + this.Before("@lambda", function(callback) { this.service = new Lambda({}); callback(); }); diff --git a/features/machinelearning/step_definitions/machinelearning.js b/features/machinelearning/step_definitions/machinelearning.js index b24391037101..5ef8c8657b39 100644 --- a/features/machinelearning/step_definitions/machinelearning.js +++ b/features/machinelearning/step_definitions/machinelearning.js @@ -1,5 +1,5 @@ module.exports = function() { - this.Before("@machinelearning", function (callback) { + this.Before("@machinelearning", function(callback) { this.service = new this.AWS.MachineLearning(); callback(); }); diff --git a/features/mobileanalytics/step_definitions/mobileanalytics.js b/features/mobileanalytics/step_definitions/mobileanalytics.js index b017c808d0ac..dc02eba789e2 100644 --- a/features/mobileanalytics/step_definitions/mobileanalytics.js +++ b/features/mobileanalytics/step_definitions/mobileanalytics.js @@ -1,5 +1,5 @@ module.exports = function() { - this.Before("@mobileanalytics", function (callback) { + this.Before("@mobileanalytics", function(callback) { this.service = new this.AWS.MobileAnalytics(); callback(); }); diff --git a/features/opsworks/step_definitions/opsworks.js b/features/opsworks/step_definitions/opsworks.js index ae6b36954438..7701501b6bb0 100644 --- a/features/opsworks/step_definitions/opsworks.js +++ b/features/opsworks/step_definitions/opsworks.js @@ -1,14 +1,17 @@ module.exports = function() { - this.Before("@opsworks", function (callback) { + this.Before("@opsworks", function(callback) { this.iam = new this.AWS.IAM(); this.service = new this.AWS.OpsWorks(); callback(); }); - this.Given(/^I create an OpsWorks user profile with the IAM user ARN$/, function(callback) { - var params = {IamUserArn: this.iamUserArn}; - this.request(null, 'createUserProfile', params, callback, false); - }); + this.Given( + /^I create an OpsWorks user profile with the IAM user ARN$/, + function(callback) { + var params = { IamUserArn: this.iamUserArn }; + this.request(null, "createUserProfile", params, callback, false); + } + ); this.Given(/^the IAM user ARN is in the result$/, function(callback) { this.assert.equal(this.data.IamUserArn, this.iamUserArn); @@ -16,8 +19,8 @@ module.exports = function() { }); this.Given(/^I describe the OpsWorks user profiles$/, function(callback) { - var params = {IamUserArns: [this.iamUserArn]}; - this.request(null, 'describeUserProfiles', params, callback); + var params = { IamUserArns: [this.iamUserArn] }; + this.request(null, "describeUserProfiles", params, callback); }); this.Then(/^the IAM user ARN should be in the result$/, function(callback) { @@ -25,18 +28,22 @@ module.exports = function() { callback(); }); - this.Then(/^the name should be equal to the IAM username$/, function(callback) { + this.Then(/^the name should be equal to the IAM username$/, function( + callback + ) { this.assert.equal(this.data.UserProfiles[0].Name, this.iamUser); callback(); }); - this.Then(/^the SSH username should be equal to the IAM username$/, function(callback) { + this.Then(/^the SSH username should be equal to the IAM username$/, function( + callback + ) { this.assert.equal(this.data.UserProfiles[0].SshUsername, this.iamUser); callback(); }); this.Then(/^I delete the OpsWorks user profile$/, function(callback) { - var params = {IamUserArn: this.iamUserArn}; - this.request(null, 'deleteUserProfile', params, callback, false); + var params = { IamUserArn: this.iamUserArn }; + this.request(null, "deleteUserProfile", params, callback, false); }); }; diff --git a/features/rds/step_definitions/rds.js b/features/rds/step_definitions/rds.js index e487d098307b..993e71c6a4a3 100644 --- a/features/rds/step_definitions/rds.js +++ b/features/rds/step_definitions/rds.js @@ -1,66 +1,83 @@ -var jmespath = require('jmespath'); -var { RDS } = require('../../../clients/node/client-rds-node'); +var jmespath = require("jmespath"); +var { RDS } = require("../../../clients/node/client-rds-node"); module.exports = function() { - this.Before("@rds", function (callback) { + this.Before("@rds", function(callback) { this.service = new RDS({}); callback(); }); - this.Given(/^I create a RDS security group with prefix name "([^"]*)"$/, function(prefix, callback) { - this.dbGroupName = this.uniqueName(prefix); - var params = { DBSecurityGroupDescription: 'Description', DBSecurityGroupName: this.dbGroupName }; - this.request(null, 'createDBSecurityGroup', params, callback, false); - }); + this.Given( + /^I create a RDS security group with prefix name "([^"]*)"$/, + function(prefix, callback) { + this.dbGroupName = this.uniqueName(prefix); + var params = { + DBSecurityGroupDescription: "Description", + DBSecurityGroupName: this.dbGroupName + }; + this.request(null, "createDBSecurityGroup", params, callback, false); + } + ); - this.Then(/the value at "([^"]*)" should contain "([^"]*)" with "([^"]*)"/, function (path, key, value, callback) { - var member = jmespath.search(this.data, path); - var containDefault = false; - member.forEach(function(config) { - console.log(config[key], value) - if (config[key] === value) { - containDefault = true - } - }); - this.assert.ok(containDefault === true, `No ${path} has member key ${key} of the value ${value}`); - callback(); - }); + this.Then( + /the value at "([^"]*)" should contain "([^"]*)" with "([^"]*)"/, + function(path, key, value, callback) { + var member = jmespath.search(this.data, path); + var containDefault = false; + member.forEach(function(config) { + console.log(config[key], value); + if (config[key] === value) { + containDefault = true; + } + }); + this.assert.ok( + containDefault === true, + `No ${path} has member key ${key} of the value ${value}` + ); + callback(); + } + ); - this.Given(/^I paginate the "([^"]*)" operation asynchronously with limit (\d+)$/, function (operation, limit, callback) { - var maxPages = 3; - limit = parseInt(limit); + this.Given( + /^I paginate the "([^"]*)" operation asynchronously with limit (\d+)$/, + function(operation, limit, callback) { + var maxPages = 3; + limit = parseInt(limit); - var world = this; - this.numPages = 0; - this.numMarkers = 0 - this.operation = operation; - this.paginationConfig = this.service.paginationConfig(operation); - this.params = this.params || {}; - this.finishedPagination = false; + var world = this; + this.numPages = 0; + this.numMarkers = 0; + this.operation = operation; + this.paginationConfig = this.service.paginationConfig(operation); + this.params = this.params || {}; + this.finishedPagination = false; - var marker = this.paginationConfig.outputToken; - if (this.paginationConfig.limitKey) { - this.params[this.paginationConfig.limitKey] = limit; - } - this.service[operation](this.params).eachPage(function (err, data, done) { - process.nextTick(function() { - if (err) callback.fail(err); - else if (data === null || world.numPages === maxPages) { - world.finishedPagination = true; - callback(); - return false; - } else { - if (data[marker]) world.numMarkers++; - world.numPages++; - world.data = data; - } + var marker = this.paginationConfig.outputToken; + if (this.paginationConfig.limitKey) { + this.params[this.paginationConfig.limitKey] = limit; + } + this.service[operation](this.params).eachPage(function(err, data, done) { + process.nextTick(function() { + if (err) callback.fail(err); + else if (data === null || world.numPages === maxPages) { + world.finishedPagination = true; + callback(); + return false; + } else { + if (data[marker]) world.numMarkers++; + world.numPages++; + world.data = data; + } - done(); // start getting next page + done(); // start getting next page + }); }); - }); - }); + } + ); - this.Then(/^I should be able to asynchronously paginate all pages$/, function (callback) { + this.Then(/^I should be able to asynchronously paginate all pages$/, function( + callback + ) { this.assert.equal(this.finishedPagination, true); callback(); }); diff --git a/features/redshift/step_definitions/redshift.js b/features/redshift/step_definitions/redshift.js index 5d40e872250e..6e19b4b5ac84 100644 --- a/features/redshift/step_definitions/redshift.js +++ b/features/redshift/step_definitions/redshift.js @@ -1,18 +1,27 @@ -var { Redshift } = require('../../../clients/node/client-redshift-node'); +var { Redshift } = require("../../../clients/node/client-redshift-node"); module.exports = function() { - this.Before("@redshift", function (callback) { + this.Before("@redshift", function(callback) { this.service = new Redshift({}); callback(); }); - this.Given(/^I create a Redshift cluster parameter group with prefix name "([^"]*)"$/, function(prefix, callback) { - this.parameterGroupName = this.uniqueName(prefix); - var params = { - Description: 'Description', - ParameterGroupName: this.parameterGroupName, - ParameterGroupFamily: 'redshift-1.0' - }; - this.request(null, 'createClusterParameterGroup', params, callback, false); - }); + this.Given( + /^I create a Redshift cluster parameter group with prefix name "([^"]*)"$/, + function(prefix, callback) { + this.parameterGroupName = this.uniqueName(prefix); + var params = { + Description: "Description", + ParameterGroupName: this.parameterGroupName, + ParameterGroupFamily: "redshift-1.0" + }; + this.request( + null, + "createClusterParameterGroup", + params, + callback, + false + ); + } + ); }; diff --git a/features/route53/step_definitions/route53.js b/features/route53/step_definitions/route53.js index 504bdc12904f..4db15e400a3a 100644 --- a/features/route53/step_definitions/route53.js +++ b/features/route53/step_definitions/route53.js @@ -1,22 +1,27 @@ module.exports = function() { - this.Before("@route53", function (callback) { + this.Before("@route53", function(callback) { this.service = new this.AWS.Route53(); callback(); }); - this.When(/^I create a Route53 hosted zone with name prefix "([^"]*)"$/, function(prefix, callback) { - this.zoneName = 'zone1.example.com'; - var params = { - Name: this.zoneName, - CallerReference: this.uniqueName(prefix), - HostedZoneConfig: { - Comment: 'A comment about the zone' - } - }; - this.request(null, 'createHostedZone', params, callback, false); - }); + this.When( + /^I create a Route53 hosted zone with name prefix "([^"]*)"$/, + function(prefix, callback) { + this.zoneName = "zone1.example.com"; + var params = { + Name: this.zoneName, + CallerReference: this.uniqueName(prefix), + HostedZoneConfig: { + Comment: "A comment about the zone" + } + }; + this.request(null, "createHostedZone", params, callback, false); + } + ); - this.Then(/^the result should contain the hosted zone ID$/, function(callback) { + this.Then(/^the result should contain the hosted zone ID$/, function( + callback + ) { this.hostedZoneId = this.data.HostedZone.Id; callback(); }); @@ -26,72 +31,94 @@ module.exports = function() { callback(); }); - this.Then(/^the result should contain the hosted zone name$/, function(callback) { - this.assert.equal(this.data.HostedZone.Name, this.zoneName + '.'); + this.Then(/^the result should contain the hosted zone name$/, function( + callback + ) { + this.assert.equal(this.data.HostedZone.Name, this.zoneName + "."); callback(); }); - this.When(/^I get information about the Route53 change ID$/, function(callback) { - this.request(null, 'getChange', {Id: this.changeInfoId}, callback); + this.When(/^I get information about the Route53 change ID$/, function( + callback + ) { + this.request(null, "getChange", { Id: this.changeInfoId }, callback); }); - this.Then(/^the change status should be PENDING or INSYNC$/, function(callback) { + this.Then(/^the change status should be PENDING or INSYNC$/, function( + callback + ) { this.assert.match(this.data.ChangeInfo.Status, /^(PENDING|INSYNC)$/); callback(); }); - this.When(/^I get information about the Route53 hosted zone ID$/, function(callback) { - this.request(null, 'getHostedZone', {Id: this.hostedZoneId}, callback); + this.When(/^I get information about the Route53 hosted zone ID$/, function( + callback + ) { + this.request(null, "getHostedZone", { Id: this.hostedZoneId }, callback); }); - this.Then(/^the result should contain multiple nameservers$/, function(callback) { - this.assert.compare(this.data.DelegationSet.NameServers.length, '>=', 0); - this.assert.equal(typeof this.data.DelegationSet.NameServers[0], 'string'); + this.Then(/^the result should contain multiple nameservers$/, function( + callback + ) { + this.assert.compare(this.data.DelegationSet.NameServers.length, ">=", 0); + this.assert.equal(typeof this.data.DelegationSet.NameServers[0], "string"); callback(); }); this.Then(/^I delete the Route53 hosted zone$/, function(callback) { - this.request(null, 'deleteHostedZone', {Id: this.hostedZoneId}, callback); - }); - - this.When(/^I create a Route53 TCP health check with name prefix "([^"]*)"$/, function(prefix, callback) { - var params = { - CallerReference: this.uniqueName(prefix), - HealthCheckConfig: { - IPAddress: '192.0.43.10', // example.com - Port: 80, - Type: 'TCP' - } + this.request(null, "deleteHostedZone", { Id: this.hostedZoneId }, callback); + }); + + this.When( + /^I create a Route53 TCP health check with name prefix "([^"]*)"$/, + function(prefix, callback) { + var params = { + CallerReference: this.uniqueName(prefix), + HealthCheckConfig: { + IPAddress: "192.0.43.10", // example.com + Port: 80, + Type: "TCP" + } + }; + this.request(null, "createHealthCheck", params, callback); } - this.request(null, 'createHealthCheck', params, callback); - }); + ); - this.Then(/^the result should contain health check information$/, function(callback) { + this.Then(/^the result should contain health check information$/, function( + callback + ) { this.healthCheckInfo = this.data.HealthCheck; callback(); }); - this.Then(/^the result should contain the health check ID$/, function(callback) { + this.Then(/^the result should contain the health check ID$/, function( + callback + ) { this.healthCheckId = this.data.HealthCheck.Id; callback(); }); - this.When(/^I get information about the health check ID$/, function(callback) { - var params = {HealthCheckId: this.healthCheckId}; - this.request(null, 'getHealthCheck', params, callback); + this.When(/^I get information about the health check ID$/, function( + callback + ) { + var params = { HealthCheckId: this.healthCheckId }; + this.request(null, "getHealthCheck", params, callback); }); - this.Then(/^the result should contain the previous health check information$/, function(callback) { - this.assert.deepEqual(this.data.HealthCheck, this.healthCheckInfo); - callback(); - }); + this.Then( + /^the result should contain the previous health check information$/, + function(callback) { + this.assert.deepEqual(this.data.HealthCheck, this.healthCheckInfo); + callback(); + } + ); this.Then(/^I delete the Route53 TCP health check$/, function(callback) { - var params = {HealthCheckId: this.healthCheckId}; - this.request(null, 'deleteHealthCheck', params, callback); + var params = { HealthCheckId: this.healthCheckId }; + this.request(null, "deleteHealthCheck", params, callback); }); this.When(/^I list Route53 hosted zones$/, function(callback) { - this.request(null, 'listHostedZones', {}, callback); + this.request(null, "listHostedZones", {}, callback); }); }; diff --git a/features/route53domains/step_definitions/route53domains.js b/features/route53domains/step_definitions/route53domains.js index ede73bf52437..c15ef6dc8111 100644 --- a/features/route53domains/step_definitions/route53domains.js +++ b/features/route53domains/step_definitions/route53domains.js @@ -1,21 +1,28 @@ -var { Route53Domains } = require('../../../clients/node/client-route-53-domains-node'); +var { + Route53Domains +} = require("../../../clients/node/client-route-53-domains-node"); module.exports = function() { - this.Before("@route53domains", function (callback) { - this.service = new Route53Domains({region: 'us-east-1'}); + this.Before("@route53domains", function(callback) { + this.service = new Route53Domains({ region: "us-east-1" }); callback(); }); - this.Given(/^I list Route53 domains$/, function (callback) { - this.request(null, 'listDomains', {}, callback); + this.Given(/^I list Route53 domains$/, function(callback) { + this.request(null, "listDomains", {}, callback); }); - this.Given(/^I try to register a Route53 domain with invalid parameters$/, function (callback) { - var params = { - DomainName: 'example.com', - DurationInYears: 1, - AdminContact: {}, RegistrantContact: {}, TechContact: {} - }; - this.request(null, 'registerDomain', params, callback, false); - }); + this.Given( + /^I try to register a Route53 domain with invalid parameters$/, + function(callback) { + var params = { + DomainName: "example.com", + DurationInYears: 1, + AdminContact: {}, + RegistrantContact: {}, + TechContact: {} + }; + this.request(null, "registerDomain", params, callback, false); + } + ); }; diff --git a/features/s3/step_definitions/buckets.js b/features/s3/step_definitions/buckets.js index f97e8fcdd500..23f1d8652e1c 100644 --- a/features/s3/step_definitions/buckets.js +++ b/features/s3/step_definitions/buckets.js @@ -1,194 +1,267 @@ module.exports = function() { - - this.Given(/^I am using the S3 "([^"]*)" region$/, function(region, callback) { - this.s3 = new this.AWS.S3({region: region}); + this.Given(/^I am using the S3 "([^"]*)" region$/, function( + region, + callback + ) { + this.s3 = new this.AWS.S3({ region: region }); callback(); }); - this.Given(/^I am using the S3 "([^"]*)" region with signatureVersion "([^"]*)"$/, function(region, signatureVersion, callback) { - this.s3 = new this.AWS.S3({region: region, signatureVersion: signatureVersion}); - callback(); - }); + this.Given( + /^I am using the S3 "([^"]*)" region with signatureVersion "([^"]*)"$/, + function(region, signatureVersion, callback) { + this.s3 = new this.AWS.S3({ + region: region, + signatureVersion: signatureVersion + }); + callback(); + } + ); - this.When(/^I create a bucket with the location constraint "([^"]*)"$/, function(location, callback) { - var bucket = this.bucket = this.uniqueName('aws-sdk-js-integration'); - var params = { - Bucket: this.bucket, - CreateBucketConfiguration: { - LocationConstraint: location - } - }; - this.request('s3', 'createBucket', params, function(err, data) { - if (err) { - return callback(err); - } - this.s3.waitFor('bucketExists', {Bucket: bucket}, callback); - }); - }); + this.When( + /^I create a bucket with the location constraint "([^"]*)"$/, + function(location, callback) { + var bucket = (this.bucket = this.uniqueName("aws-sdk-js-integration")); + var params = { + Bucket: this.bucket, + CreateBucketConfiguration: { + LocationConstraint: location + } + }; + this.request("s3", "createBucket", params, function(err, data) { + if (err) { + return callback(err); + } + this.s3.waitFor("bucketExists", { Bucket: bucket }, callback); + }); + } + ); - this.Then(/^the bucket should have a location constraint of "([^"]*)"$/, function(loc, callback) { - var self = this; - self.s3.getBucketLocation({Bucket: self.bucket}, function(err, data) { - if (err) callback.fail(err); - self.assert.equal(data.LocationConstraint, loc); - callback(); - }); - }); + this.Then( + /^the bucket should have a location constraint of "([^"]*)"$/, + function(loc, callback) { + var self = this; + self.s3.getBucketLocation({ Bucket: self.bucket }, function(err, data) { + if (err) callback.fail(err); + self.assert.equal(data.LocationConstraint, loc); + callback(); + }); + } + ); - this.When(/^I put a transition lifecycle configuration on the bucket with prefix "([^"]*)"$/, function(prefix, callback) { - var params = { - Bucket: this.bucket, - LifecycleConfiguration: { - Rules: [{ - Prefix: prefix, - Status: 'Enabled', - Transition: {Days: 0, StorageClass: 'GLACIER'} - }] - } - }; - this.request('s3', 'putBucketLifecycle', params, callback); - }); + this.When( + /^I put a transition lifecycle configuration on the bucket with prefix "([^"]*)"$/, + function(prefix, callback) { + var params = { + Bucket: this.bucket, + LifecycleConfiguration: { + Rules: [ + { + Prefix: prefix, + Status: "Enabled", + Transition: { Days: 0, StorageClass: "GLACIER" } + } + ] + } + }; + this.request("s3", "putBucketLifecycle", params, callback); + } + ); - this.When(/^I get the transition lifecycle configuration on the bucket$/, function(callback) { - this.eventually(callback, function(next) { - this.request('s3', 'getBucketLifecycle', {Bucket: this.bucket}, next); - }); - }); + this.When( + /^I get the transition lifecycle configuration on the bucket$/, + function(callback) { + this.eventually(callback, function(next) { + this.request("s3", "getBucketLifecycle", { Bucket: this.bucket }, next); + }); + } + ); - this.Then(/^the lifecycle configuration should have transition days of (\d+)$/, function(days, callback) { - this.assert.equal(this.data.Rules[0].Transition.Days, 0); - callback(); - }); + this.Then( + /^the lifecycle configuration should have transition days of (\d+)$/, + function(days, callback) { + this.assert.equal(this.data.Rules[0].Transition.Days, 0); + callback(); + } + ); - this.Then(/^the lifecycle configuration should have transition storage class of "([^"]*)"$/, function(value, callback) { - this.assert.equal(this.data.Rules[0].Transition.StorageClass, value); - callback(); - }); + this.Then( + /^the lifecycle configuration should have transition storage class of "([^"]*)"$/, + function(value, callback) { + this.assert.equal(this.data.Rules[0].Transition.StorageClass, value); + callback(); + } + ); this.When(/^I put a bucket CORS configuration$/, function(callback) { var params = { Bucket: this.bucket, CORSConfiguration: { - CORSRules: [{ - AllowedMethods: ['DELETE', 'POST', 'PUT'], - AllowedOrigins: ['http://example.com'], - AllowedHeaders: ['*'], - ExposeHeaders: ['x-amz-server-side-encryption'], - MaxAgeSeconds: 5000 - }] + CORSRules: [ + { + AllowedMethods: ["DELETE", "POST", "PUT"], + AllowedOrigins: ["http://example.com"], + AllowedHeaders: ["*"], + ExposeHeaders: ["x-amz-server-side-encryption"], + MaxAgeSeconds: 5000 + } + ] } }; - this.request('s3', 'putBucketCors', params, callback); + this.request("s3", "putBucketCors", params, callback); }); this.When(/^I get the bucket CORS configuration$/, function(callback) { - this.request('s3', 'getBucketCors', {Bucket: this.bucket}, callback); + this.request("s3", "getBucketCors", { Bucket: this.bucket }, callback); }); - this.Then(/^the AllowedMethods list should inclue "([^"]*)"$/, function(value, callback) { - this.assert.equal(this.data.CORSRules[0].AllowedMethods.sort().join(' '), 'DELETE POST PUT'); + this.Then(/^the AllowedMethods list should inclue "([^"]*)"$/, function( + value, + callback + ) { + this.assert.equal( + this.data.CORSRules[0].AllowedMethods.sort().join(" "), + "DELETE POST PUT" + ); callback(); }); - this.Then(/^the AllowedOrigin value should equal "([^"]*)"$/, function(value, callback) { + this.Then(/^the AllowedOrigin value should equal "([^"]*)"$/, function( + value, + callback + ) { this.assert.equal(this.data.CORSRules[0].AllowedOrigins[0], value); callback(); }); - this.Then(/^the AllowedHeader value should equal "([^"]*)"$/, function(value, callback) { + this.Then(/^the AllowedHeader value should equal "([^"]*)"$/, function( + value, + callback + ) { this.assert.equal(this.data.CORSRules[0].AllowedHeaders[0], value); callback(); }); - this.Then(/^the ExposeHeader value should equal "([^"]*)"$/, function(value, callback) { + this.Then(/^the ExposeHeader value should equal "([^"]*)"$/, function( + value, + callback + ) { this.assert.equal(this.data.CORSRules[0].ExposeHeaders[0], value); callback(); }); - this.Then(/^the MaxAgeSeconds value should equal (\d+)$/, function(value, callback) { + this.Then(/^the MaxAgeSeconds value should equal (\d+)$/, function( + value, + callback + ) { this.assert.equal(this.data.CORSRules[0].MaxAgeSeconds, parseInt(value)); callback(); }); - this.When(/^I put a bucket tag with key "([^"]*)" and value "([^"]*)"$/, function(key, value, callback) { - var params = { - Bucket: this.bucket, - Tagging: { - TagSet: [ - {Key: key, Value: value} - ] - } - }; + this.When( + /^I put a bucket tag with key "([^"]*)" and value "([^"]*)"$/, + function(key, value, callback) { + var params = { + Bucket: this.bucket, + Tagging: { + TagSet: [{ Key: key, Value: value }] + } + }; - this.request('s3', 'putBucketTagging', params, callback); - }); + this.request("s3", "putBucketTagging", params, callback); + } + ); this.When(/^I get the bucket tagging$/, function(callback) { - this.request('s3', 'getBucketTagging', {Bucket: this.bucket}, callback); + this.request("s3", "getBucketTagging", { Bucket: this.bucket }, callback); }); - this.Then(/^the first tag in the tag set should have key and value "([^"]*)", "([^"]*)"$/, function(key, value, callback) { - this.assert.equal(this.data.TagSet[0].Key, key); - this.assert.equal(this.data.TagSet[0].Value, value); - callback(); - }); + this.Then( + /^the first tag in the tag set should have key and value "([^"]*)", "([^"]*)"$/, + function(key, value, callback) { + this.assert.equal(this.data.TagSet[0].Key, key); + this.assert.equal(this.data.TagSet[0].Value, value); + callback(); + } + ); - this.When(/^I create a bucket with a DNS compatible name that contains a dot$/, function(callback) { - var bucket = this.bucket = this.uniqueName('aws-sdk-js.integration'); - this.request('s3', 'createBucket', {Bucket: this.bucket}, function(err, data) { - if (err) { - return callback(err); - } - this.s3.waitFor('bucketExists', {Bucket: bucket}, callback); - }); - }); + this.When( + /^I create a bucket with a DNS compatible name that contains a dot$/, + function(callback) { + var bucket = (this.bucket = this.uniqueName("aws-sdk-js.integration")); + this.request("s3", "createBucket", { Bucket: this.bucket }, function( + err, + data + ) { + if (err) { + return callback(err); + } + this.s3.waitFor("bucketExists", { Bucket: bucket }, callback); + }); + } + ); this.Given(/^I force path style requests$/, function(callback) { - this.s3 = new this.AWS.S3({s3ForcePathStyle: true}); + this.s3 = new this.AWS.S3({ s3ForcePathStyle: true }); callback(); }); - this.Then(/^the bucket name should be in the request path$/, function(callback) { - var path = this.response.request.httpRequest.path.split('/'); + this.Then(/^the bucket name should be in the request path$/, function( + callback + ) { + var path = this.response.request.httpRequest.path.split("/"); this.assert.equal(path[1], this.bucket); callback(); }); - this.Then(/^the bucket name should not be in the request host$/, function(callback) { + this.Then(/^the bucket name should not be in the request host$/, function( + callback + ) { var host = this.response.request.httpRequest.endpoint.host; - this.assert.compare(host.indexOf(this.bucket), '<', 0); + this.assert.compare(host.indexOf(this.bucket), "<", 0); callback(); }); - this.When(/^I put "([^"]*)" to the key "([^"]*)" in the bucket$/, function(data, key, next) { - var params = {Bucket: this.bucket, Key: key, Body: data}; - this.request('s3', 'putObject', params, next, false); + this.When(/^I put "([^"]*)" to the key "([^"]*)" in the bucket$/, function( + data, + key, + next + ) { + var params = { Bucket: this.bucket, Key: key, Body: data }; + this.request("s3", "putObject", params, next, false); }); - this.Then(/^I delete the object "([^"]*)" from the bucket$/, function(key, next) { - var params = {Bucket: this.bucket, Key: key}; - this.request('s3', 'deleteObject', params, next); - }); - - this.When(/^I put a (small|large) buffer to the key "([^"]*)" in the bucket$/, function(size, key, next) { - var body = this.createBuffer(size); - var params = {Bucket: this.bucket, Key: key, Body: body}; - this.request('s3', 'putObject', params, next); - }); - - this.Then(/^the object "([^"]*)" should (not )?exist in the bucket$/, function(key, shouldNotExist, next) { + this.Then(/^I delete the object "([^"]*)" from the bucket$/, function( + key, + next + ) { var params = { Bucket: this.bucket, Key: key }; - this.eventually(next, function (retry) { - retry.condition = function() { - if (shouldNotExist) { - return this.error && this.error.code === 'NotFound'; - } else { - return !this.error; - } - }; - this.request('s3', 'headObject', params, retry, false); - }); + this.request("s3", "deleteObject", params, next); }); + this.When( + /^I put a (small|large) buffer to the key "([^"]*)" in the bucket$/, + function(size, key, next) { + var body = this.createBuffer(size); + var params = { Bucket: this.bucket, Key: key, Body: body }; + this.request("s3", "putObject", params, next); + } + ); + this.Then( + /^the object "([^"]*)" should (not )?exist in the bucket$/, + function(key, shouldNotExist, next) { + var params = { Bucket: this.bucket, Key: key }; + this.eventually(next, function(retry) { + retry.condition = function() { + if (shouldNotExist) { + return this.error && this.error.code === "NotFound"; + } else { + return !this.error; + } + }; + this.request("s3", "headObject", params, retry, false); + }); + } + ); }; diff --git a/features/s3/step_definitions/hooks.js b/features/s3/step_definitions/hooks.js index b964a9b839f0..fbb0f472fa70 100644 --- a/features/s3/step_definitions/hooks.js +++ b/features/s3/step_definitions/hooks.js @@ -1,8 +1,6 @@ -module.exports = function () { - - this.Before('@s3', function (callback) { - this.service = this.s3 = new this.AWS.S3({maxRetries: 100}); +module.exports = function() { + this.Before("@s3", function(callback) { + this.service = this.s3 = new this.AWS.S3({ maxRetries: 100 }); callback(); }); - }; diff --git a/features/s3/step_definitions/managed_upload.js b/features/s3/step_definitions/managed_upload.js index 62a9a49cc511..6175efbf9aab 100644 --- a/features/s3/step_definitions/managed_upload.js +++ b/features/s3/step_definitions/managed_upload.js @@ -1,121 +1,153 @@ -module.exports = function () { - - this.When(/^I use S3 managed upload to upload(?: a| an) (empty|small|large) buffer to the key "([^"]*)"$/, function (size, key, callback) { - var self = this; - var buffer = self.createBuffer(size); - var params = {Bucket: self.sharedBucket, Key: key, Body: buffer}; - self.s3.upload(params, function (err, data) { - self.error = err; - self.data = data; - callback(); - }); - }); - - this.Given(/^I generate the MD5 checksum of a (\d+MB) buffer$/, function(size, next) { +module.exports = function() { + this.When( + /^I use S3 managed upload to upload(?: a| an) (empty|small|large) buffer to the key "([^"]*)"$/, + function(size, key, callback) { + var self = this; + var buffer = self.createBuffer(size); + var params = { Bucket: self.sharedBucket, Key: key, Body: buffer }; + self.s3.upload(params, function(err, data) { + self.error = err; + self.data = data; + callback(); + }); + } + ); + + this.Given(/^I generate the MD5 checksum of a (\d+MB) buffer$/, function( + size, + next + ) { this.uploadBuffer = this.createBuffer(size); - this.sentContentMD5 = this.AWS.util.crypto.md5(this.uploadBuffer, 'base64'); + this.sentContentMD5 = this.AWS.util.crypto.md5(this.uploadBuffer, "base64"); next(); }); - this.Given(/^I use S3 managed upload to upload the buffer to the key "([^"]*)"$/, function (key, callback) { - var self = this; - var params = {Bucket: self.sharedBucket, Key: key, Body: self.uploadBuffer}; - self.s3.upload(params, function (err, data) { - self.error = err; - self.data = data; - callback(); - }); - }); - - this.Then(/^the multipart upload should succeed$/, function (callback) { + this.Given( + /^I use S3 managed upload to upload the buffer to the key "([^"]*)"$/, + function(key, callback) { + var self = this; + var params = { + Bucket: self.sharedBucket, + Key: key, + Body: self.uploadBuffer + }; + self.s3.upload(params, function(err, data) { + self.error = err; + self.data = data; + callback(); + }); + } + ); + + this.Then(/^the multipart upload should succeed$/, function(callback) { this.assert.equal(this.error, null); - this.assert.equal(typeof this.data.Location, 'string'); + this.assert.equal(typeof this.data.Location, "string"); callback(); }); - this.When(/^I use S3 managed upload to upload(?: a| an) (empty|small|large) stream to the key "([^"]*)"$/, function (size, key, callback) { - var fs = require('fs'); - var self = this; - var fileName = self.createFile(size); - var params = {Bucket: self.sharedBucket, Key: key, Body: fs.createReadStream(fileName)}; - - self.progressEvents = []; - var progress = function(info) { - self.progressEvents.push(info); - }; - - self.s3.upload(params).on('httpUploadProgress', progress).send(function (err, data) { - self.error = err; - self.data = data; - callback(); - }); - }); - - this.Then(/^I should get progress events$/, function (callback) { - this.assert.compare(this.progressEvents.length, '>', 0); + this.When( + /^I use S3 managed upload to upload(?: a| an) (empty|small|large) stream to the key "([^"]*)"$/, + function(size, key, callback) { + var fs = require("fs"); + var self = this; + var fileName = self.createFile(size); + var params = { + Bucket: self.sharedBucket, + Key: key, + Body: fs.createReadStream(fileName) + }; + + self.progressEvents = []; + var progress = function(info) { + self.progressEvents.push(info); + }; + + self.s3 + .upload(params) + .on("httpUploadProgress", progress) + .send(function(err, data) { + self.error = err; + self.data = data; + callback(); + }); + } + ); + + this.Then(/^I should get progress events$/, function(callback) { + this.assert.compare(this.progressEvents.length, ">", 0); callback(); }); - this.Then(/^the ContentLength should equal (\d+)$/, function (val, callback) { + this.Then(/^the ContentLength should equal (\d+)$/, function(val, callback) { this.assert.equal(this.data.ContentLength, val); callback(); }); - this.When(/^I use S3 managed upload to upload some (\d+MB) buffer to the key "([^"]*)"$/, function(size, key, callback) { - var self = this; - var params = { - Bucket: self.sharedBucket, - Key: key, - Body: self.createBuffer(size) - }; - self.progressEvents = []; - var progress = function progress(info) { - self.progressEvents.push(info); - }; - - var managedUpload = self.managedUpload = new self.AWS.S3.ManagedUpload({ - leavePartsOnError: true, - params: params, - service: self.s3 - }); - - managedUpload.on('httpUploadProgress', progress).send(function(err, data) { - self.error = err; - self.data = data; - }); - callback(); - }); - - this.When(/^I use S3 managed upload to partially upload some (\d+MB) buffer to the key "([^"]*)"$/, function(size, key, callback) { - var self = this; - var params = { - Bucket: self.sharedBucket, - Key: key, - Body: self.createBuffer(size) - }; - self.progressEvents = []; - var didAbort = false; - var progress = function progress(info) { - if (self.progressEvents.length && !didAbort) { - didAbort = true; - self.managedUpload.abort(); - } - self.progressEvents.push(info); - }; - - var managedUpload = self.managedUpload = new self.AWS.S3.ManagedUpload({ - leavePartsOnError: true, - queueSize: 1, - params: params, - service: self.s3 - }); - - managedUpload.on('httpUploadProgress', progress).send(function(err, data) { - self.error = err; - self.data = data; + this.When( + /^I use S3 managed upload to upload some (\d+MB) buffer to the key "([^"]*)"$/, + function(size, key, callback) { + var self = this; + var params = { + Bucket: self.sharedBucket, + Key: key, + Body: self.createBuffer(size) + }; + self.progressEvents = []; + var progress = function progress(info) { + self.progressEvents.push(info); + }; + + var managedUpload = (self.managedUpload = new self.AWS.S3.ManagedUpload({ + leavePartsOnError: true, + params: params, + service: self.s3 + })); + + managedUpload + .on("httpUploadProgress", progress) + .send(function(err, data) { + self.error = err; + self.data = data; + }); callback(); - }); - }); + } + ); + + this.When( + /^I use S3 managed upload to partially upload some (\d+MB) buffer to the key "([^"]*)"$/, + function(size, key, callback) { + var self = this; + var params = { + Bucket: self.sharedBucket, + Key: key, + Body: self.createBuffer(size) + }; + self.progressEvents = []; + var didAbort = false; + var progress = function progress(info) { + if (self.progressEvents.length && !didAbort) { + didAbort = true; + self.managedUpload.abort(); + } + self.progressEvents.push(info); + }; + + var managedUpload = (self.managedUpload = new self.AWS.S3.ManagedUpload({ + leavePartsOnError: true, + queueSize: 1, + params: params, + service: self.s3 + })); + + managedUpload + .on("httpUploadProgress", progress) + .send(function(err, data) { + self.error = err; + self.data = data; + callback(); + }); + } + ); this.When(/^I abort the upload$/, function(callback) { this.managedUpload.abort(); @@ -136,7 +168,10 @@ module.exports = function () { }); }); - this.Then(/^uploadPart should have been called (\d+) times$/, function(count, callback) { + this.Then(/^uploadPart should have been called (\d+) times$/, function( + count, + callback + ) { this.assert.equal(this.progressEvents.length, count); callback(); }); diff --git a/features/s3/step_definitions/objects.js b/features/s3/step_definitions/objects.js index 8524884142e7..e3f7622aa825 100644 --- a/features/s3/step_definitions/objects.js +++ b/features/s3/step_definitions/objects.js @@ -1,178 +1,263 @@ -module.exports = function () { - - this.When(/^I put "([^"]*)" to the(?: invalid)? key "([^"]*)"$/, function(data, key, next) { - var params = {Bucket: this.sharedBucket, Key: key, Body: data}; - this.request('s3', 'putObject', params, next, false); +module.exports = function() { + this.When(/^I put "([^"]*)" to the(?: invalid)? key "([^"]*)"$/, function( + data, + key, + next + ) { + var params = { Bucket: this.sharedBucket, Key: key, Body: data }; + this.request("s3", "putObject", params, next, false); }); this.When(/^I get the object "([^"]*)"$/, function(key, next) { - var params = {Bucket: this.sharedBucket, Key: key}; - this.request('s3', 'getObject', params, next, false); + var params = { Bucket: this.sharedBucket, Key: key }; + this.request("s3", "getObject", params, next, false); }); - this.When(/^I put (?:a |an )(empty|small|large|\d+KB|\d+MB) buffer to the key "([^"]*)"$/, function(size, key, next) { - var body = this.createBuffer(size); - var params = {Bucket: this.sharedBucket, Key: key, Body: body}; - this.request('s3', 'putObject', params, next); - }); + this.When( + /^I put (?:a |an )(empty|small|large|\d+KB|\d+MB) buffer to the key "([^"]*)"$/, + function(size, key, next) { + var body = this.createBuffer(size); + var params = { Bucket: this.sharedBucket, Key: key, Body: body }; + this.request("s3", "putObject", params, next); + } + ); - this.When(/^I put (?:a |an )(empty|small|large) file to the key "([^"]*)"$/, function(size, key, next) { - var fs = require('fs'); - var filename = this.createFile(size, key); - var params = {Bucket: this.sharedBucket, Key: key, Body: fs.createReadStream(filename)}; - this.request('s3', 'putObject', params, next); - }); + this.When( + /^I put (?:a |an )(empty|small|large) file to the key "([^"]*)"$/, + function(size, key, next) { + var fs = require("fs"); + var filename = this.createFile(size, key); + var params = { + Bucket: this.sharedBucket, + Key: key, + Body: fs.createReadStream(filename) + }; + this.request("s3", "putObject", params, next); + } + ); - this.When(/^I put "([^"]*)" to the key "([^"]*)" with ContentLength (\d+)$/, function(contents, key, contentLength, next) { - var params = {Bucket: this.sharedBucket, Key: key, Body: contents, ContentLength: parseInt(contentLength)}; - this.s3nochecksums = new this.AWS.S3({computeChecksums: false}); - this.request('s3nochecksums', 'putObject', params, next); - }); + this.When( + /^I put "([^"]*)" to the key "([^"]*)" with ContentLength (\d+)$/, + function(contents, key, contentLength, next) { + var params = { + Bucket: this.sharedBucket, + Key: key, + Body: contents, + ContentLength: parseInt(contentLength) + }; + this.s3nochecksums = new this.AWS.S3({ computeChecksums: false }); + this.request("s3nochecksums", "putObject", params, next); + } + ); - this.Then(/^the object "([^"]*)" should contain "([^"]*)"$/, function(key, contents, next) { - this.assert.equal(this.data.Body.toString().replace('\n', ''), contents); + this.Then(/^the object "([^"]*)" should contain "([^"]*)"$/, function( + key, + contents, + next + ) { + this.assert.equal(this.data.Body.toString().replace("\n", ""), contents); next(); }); - this.Then(/^the HTTP response should have a content length of (\d+)$/, function(contentLength, next) { - this.assert.equal(this.response.httpResponse.body.length, parseInt(contentLength)); - next(); - }); + this.Then( + /^the HTTP response should have a content length of (\d+)$/, + function(contentLength, next) { + this.assert.equal( + this.response.httpResponse.body.length, + parseInt(contentLength) + ); + next(); + } + ); - this.When(/^I copy the object "([^"]*)" to "([^"]*)"$/, function(key1, key2, next) { + this.When(/^I copy the object "([^"]*)" to "([^"]*)"$/, function( + key1, + key2, + next + ) { var params = { - Bucket: this.sharedBucket, Key: key2, CopySource: '/' + this.sharedBucket + '/' + key1 + Bucket: this.sharedBucket, + Key: key2, + CopySource: "/" + this.sharedBucket + "/" + key1 }; - this.request('s3', 'copyObject', params, next); + this.request("s3", "copyObject", params, next); }); this.When(/^I delete the object "([^"]*)"$/, function(key, next) { - var params = {Bucket: this.sharedBucket, Key: key}; - this.request('s3', 'deleteObject', params, next); + var params = { Bucket: this.sharedBucket, Key: key }; + this.request("s3", "deleteObject", params, next); }); - this.Then(/^the object "([^"]*)" should (not )?exist$/, function(key, shouldNotExist, next) { + this.Then(/^the object "([^"]*)" should (not )?exist$/, function( + key, + shouldNotExist, + next + ) { var params = { Bucket: this.sharedBucket, Key: key }; - this.eventually(next, function (retry) { + this.eventually(next, function(retry) { retry.condition = function() { if (shouldNotExist) { - return this.error && this.error.code === 'NotFound'; + return this.error && this.error.code === "NotFound"; } else { return !this.error; } }; - this.request('s3', 'headObject', params, retry, false); + this.request("s3", "headObject", params, retry, false); }); }); this.When(/^I stream key "([^"]*)"$/, function(key, callback) { - var params = {Bucket: this.sharedBucket, Key: key}; + var params = { Bucket: this.sharedBucket, Key: key }; var world = this; - this.result = ''; + this.result = ""; var s = this.service.getObject(params).createReadStream(); setTimeout(function() { - s.on('end', function() { callback(); }); - s.on('data', function(d) { world.result += d.toString(); }); + s.on("end", function() { + callback(); + }); + s.on("data", function(d) { + world.result += d.toString(); + }); }, 2000); // delay streaming to ensure it is buffered }); this.When(/^I stream2 key "([^"]*)"$/, function(key, callback) { - if (!require('stream').Readable) return callback(); - var params = {Bucket: this.sharedBucket, Key: key}; + if (!require("stream").Readable) return callback(); + var params = { Bucket: this.sharedBucket, Key: key }; var world = this; - this.result = ''; + this.result = ""; var stream = this.service.getObject(params).createReadStream(); setTimeout(function() { - stream.on('end', function() { callback(); }); - stream.on('readable', function() { - var v = stream.read(); if (v) world.result += v; + stream.on("end", function() { + callback(); + }); + stream.on("readable", function() { + var v = stream.read(); + if (v) world.result += v; }); }, 2000); // delay streaming to ensure it is buffered }); - this.Then(/^the streamed data should contain "([^"]*)"$/, function(data, callback) { - this.assert.equal(this.result.replace('\n', ''), data); + this.Then(/^the streamed data should contain "([^"]*)"$/, function( + data, + callback + ) { + this.assert.equal(this.result.replace("\n", ""), data); callback(); }); - this.Then(/^the streamed data content length should equal (\d+)$/, function(length, callback) { + this.Then(/^the streamed data content length should equal (\d+)$/, function( + length, + callback + ) { this.assert.equal(this.result.length, length); callback(); }); - this.When(/^I get a pre\-signed URL to GET the key "([^"]*)"$/, function(key, callback) { + this.When(/^I get a pre\-signed URL to GET the key "([^"]*)"$/, function( + key, + callback + ) { var world = this; - this.s3.getSignedUrl('getObject', {Bucket: this.sharedBucket, Key: key}, function(err, url) { - world.signedUrl = url; - callback(); - }); + this.s3.getSignedUrl( + "getObject", + { Bucket: this.sharedBucket, Key: key }, + function(err, url) { + world.signedUrl = url; + callback(); + } + ); }); this.When(/^I access the URL via HTTP GET$/, function(callback) { var world = this; - this.data = ''; - require('https').get(this.signedUrl, function (res) { - res.on('data', function (chunk) { - world.data += chunk.toString(); - }).on('end', callback); - }).on('error', callback.fail); + this.data = ""; + require("https") + .get(this.signedUrl, function(res) { + res + .on("data", function(chunk) { + world.data += chunk.toString(); + }) + .on("end", callback); + }) + .on("error", callback.fail); }); - this.Given(/^I get a pre\-signed URL to PUT the key "([^"]*)"(?: with data "([^"]*)")?$/, function(key, body, callback) { - var world = this; - var params = {Bucket: this.sharedBucket, Key: key}; - if (body) params.Body = body; - this.s3.getSignedUrl('putObject', params, function(err, url) { - world.signedUrl = url; - callback(); - }); - }); + this.Given( + /^I get a pre\-signed URL to PUT the key "([^"]*)"(?: with data "([^"]*)")?$/, + function(key, body, callback) { + var world = this; + var params = { Bucket: this.sharedBucket, Key: key }; + if (body) params.Body = body; + this.s3.getSignedUrl("putObject", params, function(err, url) { + world.signedUrl = url; + callback(); + }); + } + ); - this.Given(/^I access the URL via HTTP PUT with data "([^"]*)"$/, function(body, callback) { + this.Given(/^I access the URL via HTTP PUT with data "([^"]*)"$/, function( + body, + callback + ) { var world = this; - this.data = ''; + this.data = ""; var data = body; - var options = require('url').parse(this.signedUrl); - options.method = 'PUT'; - options.headers = {'Content-Length': data.length}; - - require('https').request(options, function (res) { - res.on('data', function (chunk) { - world.data += chunk.toString(); - }).on('end', callback); - }).on('error', callback.fail).end(data); + var options = require("url").parse(this.signedUrl); + options.method = "PUT"; + options.headers = { "Content-Length": data.length }; + + require("https") + .request(options, function(res) { + res + .on("data", function(chunk) { + world.data += chunk.toString(); + }) + .on("end", callback); + }) + .on("error", callback.fail) + .end(data); }); this.Given( /^I create a presigned form to POST the key "([^"]*)" with the data "([^"]*)"$/, - function (key, data, callback) { + function(key, data, callback) { var world = this; - var boundary = this.postBoundary = '----WebKitFormBoundaryLL0mBKIuuLUKr7be'; + var boundary = (this.postBoundary = + "----WebKitFormBoundaryLL0mBKIuuLUKr7be"); var conditions = [ - ['content-length-range', data.length - 1, data.length + 1] + ["content-length-range", data.length - 1, data.length + 1] ], params = { Bucket: this.sharedBucket, - Fields: {key: key}, + Fields: { key: key }, Conditions: conditions }; this.s3.createPresignedPost(params, function(err, postData) { - var body = Object.keys(postData.fields).reduce(function(body, fieldName) { - body += '--' + boundary + '\r\n'; - body += 'Content-Disposition: form-data; name="' + fieldName + '"\r\n\r\n'; - return body + postData.fields[fieldName] + '\r\n'; - }, ''); - body += '--' + world.postBoundary + '\r\n'; - body += 'Content-Disposition: form-data; name="file"; filename="' + key + '"\r\n'; - body += 'Content-Type: text/plain\r\n\r\n'; - body += data + '\r\n'; - body += '--' + world.postBoundary + '\r\n'; + var body = Object.keys(postData.fields).reduce(function( + body, + fieldName + ) { + body += "--" + boundary + "\r\n"; + body += + 'Content-Disposition: form-data; name="' + fieldName + '"\r\n\r\n'; + return body + postData.fields[fieldName] + "\r\n"; + }, + ""); + body += "--" + world.postBoundary + "\r\n"; + body += + 'Content-Disposition: form-data; name="file"; filename="' + + key + + '"\r\n'; + body += "Content-Type: text/plain\r\n\r\n"; + body += data + "\r\n"; + body += "--" + world.postBoundary + "\r\n"; body += 'Content-Disposition: form-data; name="submit"\r\n'; - body += 'Content-Type: text/plain\r\n\r\n'; - body += 'submit\r\n'; - body += '--' + world.postBoundary + '--\r\n'; + body += "Content-Type: text/plain\r\n\r\n"; + body += "submit\r\n"; + body += "--" + world.postBoundary + "--\r\n"; world.postBody = body; world.postAction = postData.url; callback(); @@ -180,120 +265,183 @@ module.exports = function () { } ); - this.Given(/^I POST the form$/, function (callback) { + this.Given(/^I POST the form$/, function(callback) { var world = this; - var options = require('url').parse(this.postAction); - options.method = 'POST'; + var options = require("url").parse(this.postAction); + options.method = "POST"; options.headers = { - 'Content-Type': 'multipart/form-data; boundary=' + this.postBoundary, - 'Content-Length': this.postBody.length + "Content-Type": "multipart/form-data; boundary=" + this.postBoundary, + "Content-Length": this.postBody.length }; - require('https').request(options, function(res) { - res.on('data', function (chunk) { - world.data += chunk.toString(); - }).on('end', callback); - }) - .on('error', callback.fail) + require("https") + .request(options, function(res) { + res + .on("data", function(chunk) { + world.data += chunk.toString(); + }) + .on("end", callback); + }) + .on("error", callback.fail) .end(this.postBody); }); - this.Then(/^the HTTP response should equal "([^"]*)"$/, function(data, callback) { + this.Then(/^the HTTP response should equal "([^"]*)"$/, function( + data, + callback + ) { this.assert.equal(this.data, data); callback(); }); - this.Then(/^the HTTP response should contain "([^"]*|)"$/, function(data, callback) { + this.Then(/^the HTTP response should contain "([^"]*|)"$/, function( + data, + callback + ) { this.assert.match(this.data, data); callback(); }); - this.Given(/^I setup the listObjects request for the bucket$/, function(callback) { + this.Given(/^I setup the listObjects request for the bucket$/, function( + callback + ) { this.params = { Bucket: this.sharedBucket }; callback(); }); // progress events - this.When(/^I put (?:a |an )(empty|small|large|\d+KB|\d+MB) buffer to the key "([^"]*)" with progress events$/, function(size, key, callback) { - var self = this; - var body = self.createBuffer(size); - this.progress = []; - var req = this.s3.putObject({Bucket: this.sharedBucket, Key: key, Body: body}); - req.on('httpUploadProgress', function (p) { self.progress.push(p); }); - req.send(callback); - }); + this.When( + /^I put (?:a |an )(empty|small|large|\d+KB|\d+MB) buffer to the key "([^"]*)" with progress events$/, + function(size, key, callback) { + var self = this; + var body = self.createBuffer(size); + this.progress = []; + var req = this.s3.putObject({ + Bucket: this.sharedBucket, + Key: key, + Body: body + }); + req.on("httpUploadProgress", function(p) { + self.progress.push(p); + }); + req.send(callback); + } + ); - this.Then(/^more than (\d+) "([^"]*)" event should fire$/, function(numEvents, eventName, callback) { - this.assert.compare(this.progress.length, '>', numEvents); + this.Then(/^more than (\d+) "([^"]*)" event should fire$/, function( + numEvents, + eventName, + callback + ) { + this.assert.compare(this.progress.length, ">", numEvents); callback(); }); - this.Then(/^the "([^"]*)" value of the progress event should equal (\d+)MB$/, function(prop, mb, callback) { - this.assert.equal(this.progress[0][prop], mb * 1024 * 1024); - callback(); - }); + this.Then( + /^the "([^"]*)" value of the progress event should equal (\d+)MB$/, + function(prop, mb, callback) { + this.assert.equal(this.progress[0][prop], mb * 1024 * 1024); + callback(); + } + ); - this.Then(/^the "([^"]*)" value of the first progress event should be greater than (\d+) bytes$/, function(prop, bytes, callback) { - this.assert.compare(this.progress[0][prop], '>', bytes); - callback(); - }); + this.Then( + /^the "([^"]*)" value of the first progress event should be greater than (\d+) bytes$/, + function(prop, bytes, callback) { + this.assert.compare(this.progress[0][prop], ">", bytes); + callback(); + } + ); - this.When(/^I read the key "([^"]*)" with progress events$/, function(key, callback) { + this.When(/^I read the key "([^"]*)" with progress events$/, function( + key, + callback + ) { var self = this; this.progress = []; - var req = this.s3.getObject({Bucket: this.sharedBucket, Key: key}); - req.on('httpDownloadProgress', function (p) { self.progress.push(p); }); + var req = this.s3.getObject({ Bucket: this.sharedBucket, Key: key }); + req.on("httpDownloadProgress", function(p) { + self.progress.push(p); + }); req.send(callback); }); - this.When(/^I put "([^"]*)" to the (public|private) key "([^"]*)"$/, function(data, access, key, next) { + this.When(/^I put "([^"]*)" to the (public|private) key "([^"]*)"$/, function( + data, + access, + key, + next + ) { var acl; - if (access === 'public') acl = 'public-read'; - else if (access === 'private') acl = access; - var params = {Bucket: this.sharedBucket, Key: key, Body: data, ACL: acl}; - this.request('s3', 'putObject', params, next); + if (access === "public") acl = "public-read"; + else if (access === "private") acl = access; + var params = { Bucket: this.sharedBucket, Key: key, Body: data, ACL: acl }; + this.request("s3", "putObject", params, next); }); - this.When(/^I put "([^"]*)" to the key "([^"]*)" with an AES key$/, function(data, key, next) { + this.When(/^I put "([^"]*)" to the key "([^"]*)" with an AES key$/, function( + data, + key, + next + ) { var params = { Bucket: this.sharedBucket, Key: key, Body: data, - SSECustomerAlgorithm: 'AES256', - SSECustomerKey: 'aaaabbbbccccddddaaaabbbbccccdddd' + SSECustomerAlgorithm: "AES256", + SSECustomerKey: "aaaabbbbccccddddaaaabbbbccccdddd" }; - this.request('s3', 'putObject', params, next); + this.request("s3", "putObject", params, next); }); - this.When(/^I read the object "([^"]*)" with the AES key$/, function(key, next) { + this.When(/^I read the object "([^"]*)" with the AES key$/, function( + key, + next + ) { var params = { Bucket: this.sharedBucket, Key: key, - SSECustomerAlgorithm: 'AES256', - SSECustomerKey: 'aaaabbbbccccddddaaaabbbbccccdddd' + SSECustomerAlgorithm: "AES256", + SSECustomerKey: "aaaabbbbccccddddaaaabbbbccccdddd" }; - this.request('s3', 'getObject', params, next); - }); - - this.Then(/^I make an unauthenticated request to read object "([^"]*)"$/, function(key, next) { - var params = {Bucket: this.sharedBucket, Key: key}; - this.s3.makeUnauthenticatedRequest('getObject', params, function (err, data) { - if (err) return next(err); - this.data = data; - next(); - }.bind(this)); - }); + this.request("s3", "getObject", params, next); + }); + + this.Then( + /^I make an unauthenticated request to read object "([^"]*)"$/, + function(key, next) { + var params = { Bucket: this.sharedBucket, Key: key }; + this.s3.makeUnauthenticatedRequest( + "getObject", + params, + function(err, data) { + if (err) return next(err); + this.data = data; + next(); + }.bind(this) + ); + } + ); - this.Given(/^I generate the MD5 checksum of "([^"]*)"$/, function(data, next) { - this.sentContentMD5 = this.AWS.util.crypto.md5(data, 'base64'); + this.Given(/^I generate the MD5 checksum of "([^"]*)"$/, function( + data, + next + ) { + this.sentContentMD5 = this.AWS.util.crypto.md5(data, "base64"); next(); }); - this.Then(/^the MD5 checksum of the response data should equal the generated checksum$/, function(next) { - var receivedContentMD5 = this.AWS.util.crypto.md5(this.data.Body.toString(), 'base64'); - this.assert.equal(receivedContentMD5, this.sentContentMD5); - next(); - }); + this.Then( + /^the MD5 checksum of the response data should equal the generated checksum$/, + function(next) { + var receivedContentMD5 = this.AWS.util.crypto.md5( + this.data.Body.toString(), + "base64" + ); + this.assert.equal(receivedContentMD5, this.sentContentMD5); + next(); + } + ); this.Given(/^an empty bucket$/, function(next) { var self = this; @@ -302,31 +450,37 @@ module.exports = function () { if (err) return next(err); if (data.Contents.length > 0) { params.Delete = { Objects: [] }; - data.Contents.forEach(function (item) { - params.Delete.Objects.push({Key: item.Key}); + data.Contents.forEach(function(item) { + params.Delete.Objects.push({ Key: item.Key }); }); - self.request('s3', 'deleteObjects', params, next); + self.request("s3", "deleteObjects", params, next); } else { next(); } }); }); - this.Given(/^I use signatureVersion "([^"]*)"$/, function(signatureVersion, next) { - this.s3Slashes = new this.AWS.S3({signatureVersion: signatureVersion}); + this.Given(/^I use signatureVersion "([^"]*)"$/, function( + signatureVersion, + next + ) { + this.s3Slashes = new this.AWS.S3({ signatureVersion: signatureVersion }); next(); }); - this.When(/^I put "([^"]*)" to the key "([^"]*)" with bucket suffix "([^"]*)"$/, function(data, key, suffix, next) { - var world = this; - var params = { - Bucket: this.sharedBucket + suffix, - Key: key, - Body: data - }; - this.s3Slashes.putObject(params, function(err, data) { - world.assert.equal(!!err, false); - next(); - }); - }); + this.When( + /^I put "([^"]*)" to the key "([^"]*)" with bucket suffix "([^"]*)"$/, + function(data, key, suffix, next) { + var world = this; + var params = { + Bucket: this.sharedBucket + suffix, + Key: key, + Body: data + }; + this.s3Slashes.putObject(params, function(err, data) { + world.assert.equal(!!err, false); + next(); + }); + } + ); }; diff --git a/features/s3/step_definitions/proxy.js b/features/s3/step_definitions/proxy.js index 644c11033690..74f7821fd26a 100644 --- a/features/s3/step_definitions/proxy.js +++ b/features/s3/step_definitions/proxy.js @@ -1,12 +1,12 @@ -var url = require('url'); -var http = require('http'); +var url = require("url"); +var http = require("http"); module.exports = function() { - this.Before('@s3', '@proxy', function(callback) { + this.Before("@s3", "@proxy", function(callback) { setupProxyServer.call(this); this.service = this.s3 = new this.AWS.S3({ - httpOptions: { proxy: 'http://localhost:' + this.proxyPort } + httpOptions: { proxy: "http://localhost:" + this.proxyPort } }); callback(); @@ -20,7 +20,7 @@ module.exports = function() { function setupProxyServer() { if (this.proxyServer) return; this.proxyPort = 8000 + parseInt(Math.random() * 100); - this.proxyServer = http.createServer(function (req, res) { + this.proxyServer = http.createServer(function(req, res) { var uri = url.parse(req.url); var options = { host: uri.hostname, @@ -31,11 +31,15 @@ module.exports = function() { }; options.headers.host = uri.hostname; - var s = http.request(options, function (res2) { + var s = http.request(options, function(res2) { res.writeHead(res2.statusCode, res2.headers); - res2.on('data', function(ch) { - res.write(ch); - }).on('end', function() { res.end(); }); + res2 + .on("data", function(ch) { + res.write(ch); + }) + .on("end", function() { + res.end(); + }); }); req.pipe(s); }); diff --git a/features/ses/step_definitions/ses.js b/features/ses/step_definitions/ses.js index ad29a6c85e44..20fe1f78a0f4 100644 --- a/features/ses/step_definitions/ses.js +++ b/features/ses/step_definitions/ses.js @@ -1,24 +1,37 @@ -var { SES } = require('../../../clients/node/client-ses-node'); +var { SES } = require("../../../clients/node/client-ses-node"); module.exports = function() { - this.Before("@ses", function (callback) { + this.Before("@ses", function(callback) { this.service = new SES({}); callback(); }); this.When(/^I check quota$/, function(next) { - this.request(null, 'getSendQuota', {}, next); + this.request(null, "getSendQuota", {}, next); }); - this.Then(/^the result should include (\S+) "([^"]*)"$/, function(type, attr, next) { + this.Then(/^the result should include (\S+) "([^"]*)"$/, function( + type, + attr, + next + ) { if (this.data[attr] === undefined) next.fail("Missing " + attr); if (typeof this.data[attr] !== type) next.fail("Incorrect type " + attr); next(); }); - this.When(/^I ask to verify the email address "([^"]*)"$/, function(email, next) { - this.request(null, 'verifyEmailAddress', {EmailAddress: email}, next, function() { - // do nothing - }); + this.When(/^I ask to verify the email address "([^"]*)"$/, function( + email, + next + ) { + this.request( + null, + "verifyEmailAddress", + { EmailAddress: email }, + next, + function() { + // do nothing + } + ); }); }; diff --git a/features/sns/step_definitions/sns.js b/features/sns/step_definitions/sns.js index 4330b3da58c0..b816a5fe4d78 100644 --- a/features/sns/step_definitions/sns.js +++ b/features/sns/step_definitions/sns.js @@ -1,20 +1,23 @@ -var { SNS } = require('../../../clients/node/client-sns-node'); +var { SNS } = require("../../../clients/node/client-sns-node"); module.exports = function() { - this.Before("@sns", function (callback) { + this.Before("@sns", function(callback) { this.service = new SNS({}); callback(); }); - this.Given(/^I create an SNS topic with name "([^"]*)"$/, function(name, callback) { + this.Given(/^I create an SNS topic with name "([^"]*)"$/, function( + name, + callback + ) { var world = this; - this.request(null, 'createTopic', {Name: name}, callback, function (data) { + this.request(null, "createTopic", { Name: name }, callback, function(data) { world.topicArn = data.TopicArn; }); }); this.Given(/^I list the SNS topics$/, function(callback) { - this.request(null, 'listTopics', {}, callback); + this.request(null, "listTopics", {}, callback); }); this.Then(/^the list should contain the topic ARN$/, function(callback) { @@ -26,10 +29,18 @@ module.exports = function() { }); this.Then(/^I delete the SNS topic$/, function(callback) { - this.request(null, 'deleteTopic', {TopicArn: this.topicArn}, callback); + this.request(null, "deleteTopic", { TopicArn: this.topicArn }, callback); }); - this.Given(/^I get SNS topic attributes with an invalid ARN$/, function(callback) { - this.request(null, 'getTopicAttributes', {TopicArn:'INVALID'}, callback, false); + this.Given(/^I get SNS topic attributes with an invalid ARN$/, function( + callback + ) { + this.request( + null, + "getTopicAttributes", + { TopicArn: "INVALID" }, + callback, + false + ); }); }; diff --git a/features/sqs/step_definitions/messages.js b/features/sqs/step_definitions/messages.js index 2b1a015e9d46..bc059cafe1a0 100644 --- a/features/sqs/step_definitions/messages.js +++ b/features/sqs/step_definitions/messages.js @@ -1,46 +1,68 @@ -module.exports = function () { - +module.exports = function() { this.When(/^I send the message "([^"]*)"$/, function(message, callback) { - this.request(null, 'sendMessage', {QueueUrl:this.queueUrl,MessageBody:message}, callback); + this.request( + null, + "sendMessage", + { QueueUrl: this.queueUrl, MessageBody: message }, + callback + ); }); this.Then(/^the result should include a message ID$/, function(callback) { - this.assert.compare(this.data.MessageId.length, '>', 0); + this.assert.compare(this.data.MessageId.length, ">", 0); callback(); }); - this.Then(/^the result should have an MD5 digest of "([^"]*)"$/, function(digest, callback) { + this.Then(/^the result should have an MD5 digest of "([^"]*)"$/, function( + digest, + callback + ) { this.assert.equal(this.data.MD5OfMessageBody, digest); callback(); }); - this.Then(/^I should eventually be able to receive "([^"]*)" from the queue$/, function(message, callback) { - this.eventually(callback, function (next) { - next.condition = function() { - return this.data.Messages[0].Body === message; - }; - this.request(null, 'receiveMessage', {QueueUrl:this.queueUrl}, next); - }); - }); + this.Then( + /^I should eventually be able to receive "([^"]*)" from the queue$/, + function(message, callback) { + this.eventually(callback, function(next) { + next.condition = function() { + return this.data.Messages[0].Body === message; + }; + this.request(null, "receiveMessage", { QueueUrl: this.queueUrl }, next); + }); + } + ); - this.When(/^I send the message "([^"]*)" with a binary attribute$/, function (message, callback) { + this.When(/^I send the message "([^"]*)" with a binary attribute$/, function( + message, + callback + ) { var params = { QueueUrl: this.queueUrl, MessageBody: message, MessageAttributes: { - binary: { DataType: 'Binary', BinaryValue: Buffer.from([1,2,3]) } + binary: { DataType: "Binary", BinaryValue: Buffer.from([1, 2, 3]) } } }; - this.request(null, 'sendMessage', params, callback); + this.request(null, "sendMessage", params, callback); }); - this.Then(/^I should eventually be able to receive "([^"]*)" from the queue with a binary attribute$/, function (message, callback) { - this.eventually(callback, function (next) { - next.condition = function() { - return this.data.Messages[0].MessageAttributes.binary.BinaryValue.toString() === '\u0001\u0002\u0003'; - }; - var params = {QueueUrl:this.queueUrl,MessageAttributeNames:['binary']}; - this.request(null, 'receiveMessage', params, next); - }); - }); + this.Then( + /^I should eventually be able to receive "([^"]*)" from the queue with a binary attribute$/, + function(message, callback) { + this.eventually(callback, function(next) { + next.condition = function() { + return ( + this.data.Messages[0].MessageAttributes.binary.BinaryValue.toString() === + "\u0001\u0002\u0003" + ); + }; + var params = { + QueueUrl: this.queueUrl, + MessageAttributeNames: ["binary"] + }; + this.request(null, "receiveMessage", params, next); + }); + } + ); }; diff --git a/features/sqs/step_definitions/queues.js b/features/sqs/step_definitions/queues.js index d633218f14af..b05be4ebb420 100644 --- a/features/sqs/step_definitions/queues.js +++ b/features/sqs/step_definitions/queues.js @@ -1,33 +1,46 @@ -module.exports = function () { - - this.Given(/^I create a queue with the prefix name "([^"]*)"$/, function(prefix, callback) { +module.exports = function() { + this.Given(/^I create a queue with the prefix name "([^"]*)"$/, function( + prefix, + callback + ) { var name = this.uniqueName(prefix); - this.request(null, 'createQueue', { QueueName: name }, callback, function() { - this.queueUrl = this.data.QueueUrl; - this.createdQueues.push(this.queueUrl); - }); + this.request( + null, + "createQueue", + { QueueName: name }, + callback, + function() { + this.queueUrl = this.data.QueueUrl; + this.createdQueues.push(this.queueUrl); + } + ); }); - this.Then(/^list queues should eventually return the queue urls$/, function(callback) { - this.eventually(callback, function (next) { - next.condition = function() { - var matchingCount = 0; - for (var i = 0; i < this.createdQueues.length; ++i) { - for (var j = 0; j < this.data.QueueUrls.length; ++j) { - if (this.createdQueues[i] == this.data.QueueUrls[j]) { - matchingCount++; + this.Then(/^list queues should eventually return the queue urls$/, function( + callback + ) { + this.eventually( + callback, + function(next) { + next.condition = function() { + var matchingCount = 0; + for (var i = 0; i < this.createdQueues.length; ++i) { + for (var j = 0; j < this.data.QueueUrls.length; ++j) { + if (this.createdQueues[i] == this.data.QueueUrls[j]) { + matchingCount++; + } } } - } - return matchingCount == this.createdQueues.length; - }; - this.request(null, 'listQueues', {}, next); - }, { maxTime: 60 }); + return matchingCount == this.createdQueues.length; + }; + this.request(null, "listQueues", {}, next); + }, + { maxTime: 60 } + ); }); - this.Then(/^I delete the SQS queue$/, function (callback) { + this.Then(/^I delete the SQS queue$/, function(callback) { var url = this.createdQueues.pop(); - this.request(null, 'deleteQueue', { QueueUrl: url }, callback); + this.request(null, "deleteQueue", { QueueUrl: url }, callback); }); - }; diff --git a/features/sqs/step_definitions/sqs.js b/features/sqs/step_definitions/sqs.js index ed96d32b1aeb..905f4932e683 100644 --- a/features/sqs/step_definitions/sqs.js +++ b/features/sqs/step_definitions/sqs.js @@ -1,6 +1,6 @@ module.exports = function() { - this.Before("@sqs", function (callback) { - this.service = new this.AWS.SQS({region: 'us-east-1'}); + this.Before("@sqs", function(callback) { + this.service = new this.AWS.SQS({ region: "us-east-1" }); this.createdQueues = []; callback(); }); diff --git a/features/ssm/step_definitions/ssm.js b/features/ssm/step_definitions/ssm.js index 1e1bb61c98e0..fe2afbef1426 100644 --- a/features/ssm/step_definitions/ssm.js +++ b/features/ssm/step_definitions/ssm.js @@ -1,7 +1,7 @@ -var { SSM } = require('../../../clients/node/client-ssm-node'); +var { SSM } = require("../../../clients/node/client-ssm-node"); module.exports = function() { - this.Before("@ssm", function (callback) { + this.Before("@ssm", function(callback) { this.service = new SSM({}); callback(); }); diff --git a/features/storagegateway/step_definitions/storagegateway.js b/features/storagegateway/step_definitions/storagegateway.js index b269b2a2a1b1..84212b2fd8a1 100644 --- a/features/storagegateway/step_definitions/storagegateway.js +++ b/features/storagegateway/step_definitions/storagegateway.js @@ -1,18 +1,20 @@ -var { StorageGateway } = require('../../../clients/node/client-storage-gateway-node'); +var { + StorageGateway +} = require("../../../clients/node/client-storage-gateway-node"); module.exports = function() { - this.Before("@storagegateway", function (callback) { - this.service = new StorageGateway({region: 'us-east-1'}); + this.Before("@storagegateway", function(callback) { + this.service = new StorageGateway({ region: "us-east-1" }); callback(); }); this.When(/^I try to activate a Storage Gateway$/, function(callback) { var params = { - ActivationKey: 'INVALIDKEY', - GatewayName: this.uniqueName('aws-sdk-js'), - GatewayTimezone: 'GMT-5:00', - GatewayRegion: 'us-east-1' + ActivationKey: "INVALIDKEY", + GatewayName: this.uniqueName("aws-sdk-js"), + GatewayTimezone: "GMT-5:00", + GatewayRegion: "us-east-1" }; - this.request(null, 'activateGateway', params, callback, false); + this.request(null, "activateGateway", params, callback, false); }); }; diff --git a/features/sts/step_definitions/sts.js b/features/sts/step_definitions/sts.js index 85acb794293d..de13dd6fee8b 100644 --- a/features/sts/step_definitions/sts.js +++ b/features/sts/step_definitions/sts.js @@ -1,30 +1,46 @@ -var { STS } = require('../../../clients/node/client-sts-node'); +var { STS } = require("../../../clients/node/client-sts-node"); module.exports = function() { - this.Before('@sts', function (callback) { + this.Before("@sts", function(callback) { this.service = new STS({}); callback(); }); - this.Given(/^I get an STS session token with a duration of (\d+) seconds$/, function(duration, callback) { - this.request(null, 'getSessionToken', {DurationSeconds: parseInt(duration)}, callback, false); - }); + this.Given( + /^I get an STS session token with a duration of (\d+) seconds$/, + function(duration, callback) { + this.request( + null, + "getSessionToken", + { DurationSeconds: parseInt(duration) }, + callback, + false + ); + } + ); - this.Then(/^the result should contain an access key ID and secret access key$/, function(callback) { - this.assert.compare(this.data.Credentials.AccessKeyId.length, '>', 0); - this.assert.compare(this.data.Credentials.SecretAccessKey.length, '>', 0); - callback(); - }); + this.Then( + /^the result should contain an access key ID and secret access key$/, + function(callback) { + this.assert.compare(this.data.Credentials.AccessKeyId.length, ">", 0); + this.assert.compare(this.data.Credentials.SecretAccessKey.length, ">", 0); + callback(); + } + ); this.Given(/^I try to assume role with web identity$/, function(callback) { - var params = {RoleArn: 'arn:aws:iam::123456789:role/WebIdentity', RoleSessionName: 'name', WebIdentityToken: 'token'}; - this.request(null, 'assumeRoleWithWebIdentity', params, callback, false); + var params = { + RoleArn: "arn:aws:iam::123456789:role/WebIdentity", + RoleSessionName: "name", + WebIdentityToken: "token" + }; + this.request(null, "assumeRoleWithWebIdentity", params, callback, false); }); this.Given(/^I try to assume role with SAML$/, function(callback) { - var arn = 'arn:aws:iam::123456789:role/Role'; - var token = 'TOKENVALUETOKENVALUETOKENVALUETOKENVALUE'; - var params = {RoleArn: arn, PrincipalArn: arn, SAMLAssertion: token}; - this.request(null, 'assumeRoleWithSAML', params, callback, false); + var arn = "arn:aws:iam::123456789:role/Role"; + var token = "TOKENVALUETOKENVALUETOKENVALUETOKENVALUE"; + var params = { RoleArn: arn, PrincipalArn: arn, SAMLAssertion: token }; + this.request(null, "assumeRoleWithSAML", params, callback, false); }); }; diff --git a/features/support/step_definitions/support.js b/features/support/step_definitions/support.js index 12f1fd4487c2..e7ac183f012a 100644 --- a/features/support/step_definitions/support.js +++ b/features/support/step_definitions/support.js @@ -1,28 +1,34 @@ -var { Support } = require('../../../clients/node/client-support-node'); +var { Support } = require("../../../clients/node/client-support-node"); module.exports = function() { - this.Before("@support", function (callback) { - this.service = new Support({region: 'us-east-1'}); + this.Before("@support", function(callback) { + this.service = new Support({ region: "us-east-1" }); callback(); }); this.Given(/^I describe Support services$/, function(callback) { - this.request(null, 'describeServices', {}, callback); + this.request(null, "describeServices", {}, callback); }); - this.Then(/^the Supported services list should contain a service with code "([^"]*)"$/, function(code, callback) { - this.assert.contains(this.data.services, function (svc) { - return svc.code == code; - }); - callback(); - }); + this.Then( + /^the Supported services list should contain a service with code "([^"]*)"$/, + function(code, callback) { + this.assert.contains(this.data.services, function(svc) { + return svc.code == code; + }); + callback(); + } + ); - this.Then(/^the Supported services list should contain a service with name "([^"]*)"$/, function(name, callback) { - this.assert.contains(this.data.services, function (svc) { - return svc.name == name; - }); - callback(); - }); + this.Then( + /^the Supported services list should contain a service with name "([^"]*)"$/, + function(name, callback) { + this.assert.contains(this.data.services, function(svc) { + return svc.name == name; + }); + callback(); + } + ); this.Given(/^I create a case with an invalid category$/, function(callback) { var params = { @@ -32,6 +38,6 @@ module.exports = function() { communicationBody: "Communication" }; - this.request(null, 'createCase', params, callback, false); + this.request(null, "createCase", params, callback, false); }); }; diff --git a/features/swf/step_definitions/swf.js b/features/swf/step_definitions/swf.js index 754c6fdb9386..a52208559685 100644 --- a/features/swf/step_definitions/swf.js +++ b/features/swf/step_definitions/swf.js @@ -1,7 +1,7 @@ -var { SWF } = require('../../../clients/node/client-swf-node'); +var { SWF } = require("../../../clients/node/client-swf-node"); module.exports = function() { - this.Before('@swf', function (callback) { + this.Before("@swf", function(callback) { this.service = new SWF({}); callback(); }); diff --git a/features/waf/step_definitions/waf.js b/features/waf/step_definitions/waf.js index 36e7a27ff03b..b014f3fbcf95 100644 --- a/features/waf/step_definitions/waf.js +++ b/features/waf/step_definitions/waf.js @@ -1,5 +1,5 @@ module.exports = function() { - this.Before("@waf", function (callback) { + this.Before("@waf", function(callback) { this.service = new this.AWS.WAF(); callback(); }); diff --git a/features/workspaces/step_definitions/workspaces.js b/features/workspaces/step_definitions/workspaces.js index 90f6013c10fa..a9214b6f6824 100644 --- a/features/workspaces/step_definitions/workspaces.js +++ b/features/workspaces/step_definitions/workspaces.js @@ -1,7 +1,7 @@ -var { WorkSpaces } = require('../../../clients/node/client-workspaces-node'); +var { WorkSpaces } = require("../../../clients/node/client-workspaces-node"); module.exports = function() { - this.Before("@workspaces", function (callback) { + this.Before("@workspaces", function(callback) { this.service = new WorkSpaces({}); callback(); }); diff --git a/package.json b/package.json index 0d998d71333d..407c03e5d929 100644 --- a/package.json +++ b/package.json @@ -61,9 +61,9 @@ } }, "lint-staged": { - "{scripts,packages,clients}/**/*.{ts,js,md,json}": [ + "**/*.{ts,js,md,json}": [ "prettier --write", "git add" ] } -} \ No newline at end of file +}