diff --git a/test/custom-domain-test.js b/test/custom-domain-test.js index ec493f9..825b531 100644 --- a/test/custom-domain-test.js +++ b/test/custom-domain-test.js @@ -10,6 +10,7 @@ var AppStore = require('../appstore.js'), async = require('async'), + AWS = require('aws-sdk'), Cloudron = require('../cloudron.js'), common = require('../common.js'), dns = require('dns'); @@ -24,6 +25,7 @@ describe('Appstore new user flow', function () { this.timeout(0); var appStore = new AppStore('https://api.staging.cloudron.io'); + var route53 = new AWS.Route53({ accessKeyId: process.env.AWS_STAGING_ACCESS_KEY, secretAccessKey: process.env.AWS_STAGING_SECRET_KEY }); var owner = common.getOwner(); var admin = common.getAdmin(); @@ -55,8 +57,34 @@ describe('Appstore new user flow', function () { }); }); - it('can setup my. domain after it got IP', function () { + it('can setup my. domain after it got IP', function (done) { var ip = appStore.waitForIP(box.id); + + // update the route53 record for my subdomain + route53.listHostedZonesByName({ DNSName: CUSTOM_DOMAIN, MaxItems: '1'}, function (error, result) { + if (error) return done(error); + + var params = { + ChangeBatch: { + Changes: [{ + Action: 'UPSERT', + ResourceRecordSet: { + Type: 'A', + Name: 'my.' + CUSTOM_DOMAIN + '.', + ResourceRecords: [ { Value: ip } ], + TTL: 1 + } + }] + }, + HostedZoneId: result.HostedZones[0].Id + }; + + route53.changeResourceRecordSets(params, function(error) { + if (error) return done(error); + + done(); + }); + }); }); it('can wait for cloudron', function () {