2013-04-11 19:59:02 +04:00
|
|
|
#!/usr/bin/env node
|
2013-11-08 10:22:08 +04:00
|
|
|
//
|
|
|
|
// Copyright (c) Microsoft and contributors. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
//
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
2011-12-10 03:47:08 +04:00
|
|
|
|
|
|
|
var fs = require('fs');
|
2014-01-05 15:38:07 +04:00
|
|
|
var path = require('path');
|
2011-12-10 03:47:08 +04:00
|
|
|
|
2012-03-15 12:26:33 +04:00
|
|
|
var args = (process.ARGV || process.argv);
|
|
|
|
|
2013-05-18 04:31:11 +04:00
|
|
|
var reporter = 'list';
|
|
|
|
var xunitOption = Array.prototype.indexOf.call(args, '-xunit');
|
|
|
|
if (xunitOption !== -1) {
|
|
|
|
reporter = 'xunit';
|
|
|
|
args.splice(xunitOption, 1);
|
|
|
|
}
|
|
|
|
|
2012-03-15 12:26:33 +04:00
|
|
|
var testList = args.pop();
|
|
|
|
|
2011-12-10 03:47:08 +04:00
|
|
|
var fileContent;
|
|
|
|
var root = false;
|
2012-07-10 23:43:33 +04:00
|
|
|
|
|
|
|
if (!fs.existsSync) {
|
|
|
|
fs.existsSync = require('path').existsSync;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fs.existsSync(testList)) {
|
2012-03-15 12:26:33 +04:00
|
|
|
fileContent = fs.readFileSync(testList).toString();
|
2011-12-10 03:47:08 +04:00
|
|
|
} else {
|
2012-03-15 12:26:33 +04:00
|
|
|
fileContent = fs.readFileSync('./test/' + testList).toString();
|
2011-12-10 03:47:08 +04:00
|
|
|
root = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
var files = fileContent.split('\n');
|
|
|
|
|
2012-02-24 10:25:15 +04:00
|
|
|
args.push('-u');
|
|
|
|
args.push('tdd');
|
|
|
|
|
2013-04-12 00:54:31 +04:00
|
|
|
// TODO: remove this timeout once tests are faster
|
|
|
|
args.push('-t');
|
|
|
|
args.push('200000');
|
|
|
|
|
2011-12-10 03:47:08 +04:00
|
|
|
files.forEach(function (file) {
|
2012-12-27 20:08:54 +04:00
|
|
|
if (file.length > 0 && file.trim()[0] !== '#') {
|
|
|
|
// trim trailing \r if it exists
|
|
|
|
file = file.replace('\r', '');
|
2011-12-10 03:47:08 +04:00
|
|
|
|
2012-12-27 20:08:54 +04:00
|
|
|
if (root) {
|
|
|
|
args.push('test/' + file);
|
|
|
|
} else {
|
|
|
|
args.push(file);
|
|
|
|
}
|
2011-12-10 03:47:08 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-09-30 10:30:50 +03:00
|
|
|
args.push('-R');
|
|
|
|
args.push(reporter);
|
2012-04-16 09:40:23 +04:00
|
|
|
|
2013-03-25 20:49:46 +04:00
|
|
|
var defaultStorageAccount = 'ciserversdk';
|
|
|
|
var defaultServiceBusAccount = 'ciserversb';
|
2013-10-15 19:21:48 +04:00
|
|
|
var defaultSubscription = 'db1ab6f0-4769-4b27-930e-01e2ef9c123c';
|
2013-10-26 21:50:54 +04:00
|
|
|
var defaultAccessToken = 'access_token';
|
2013-03-25 20:49:46 +04:00
|
|
|
|
2013-04-24 00:36:54 +04:00
|
|
|
if (!process.env.AZURE_APNS_CERTIFICATE && process.env.AZURE_APNS_CERTIFICATE_FILE) {
|
|
|
|
process.env.AZURE_APNS_CERTIFICATE = new Buffer(fs.readFileSync(process.env['AZURE_APNS_CERTIFICATE_FILE'])).toString('base64');
|
2013-07-27 14:46:26 +04:00
|
|
|
} else if (process.env.AZURE_APNS_CERTIFICATE && process.env.AZURE_APNS_CERTIFICATE_FILE) {
|
2013-07-29 22:34:12 +04:00
|
|
|
throw new Error('Only one of AZURE_APNS_CERTIFICATE or AZURE_APNS_CERTIFICATE_FILE can be set. Not both.');
|
2013-04-24 00:36:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!process.env.AZURE_APNS_CERTIFICATE_KEY && process.env.AZURE_APNS_CERTIFICATE_KEY_FILE) {
|
|
|
|
process.env.AZURE_APNS_CERTIFICATE_KEY = fs.readFileSync(process.env['AZURE_APNS_CERTIFICATE_KEY_FILE']).toString();
|
2013-07-29 22:34:12 +04:00
|
|
|
} else if (process.env.AZURE_APNS_CERTIFICATE_KEY && process.env.AZURE_APNS_CERTIFICATE_KEY_FILE) {
|
|
|
|
throw new Error('Only one of AZURE_APNS_CERTIFICATE_KEY or AZURE_APNS_CERTIFICATE_KEY_FILE can be set. Not both.');
|
2013-04-24 00:36:54 +04:00
|
|
|
}
|
|
|
|
|
2014-04-18 19:12:17 +04:00
|
|
|
|
2013-07-18 13:45:15 +04:00
|
|
|
if (!process.env.AZURE_MPNS_CERTIFICATE && process.env.AZURE_MPNS_CERTIFICATE_FILE) {
|
|
|
|
process.env.AZURE_MPNS_CERTIFICATE = new Buffer(fs.readFileSync(process.env['AZURE_MPNS_CERTIFICATE_FILE'])).toString('base64');
|
2013-07-27 14:46:26 +04:00
|
|
|
} else if (process.env.AZURE_MPNS_CERTIFICATE && process.env.AZURE_MPNS_CERTIFICATE_FILE) {
|
|
|
|
throw new Error('Only one of AZURE_MPNS_CERTIFICATE or AZURE_MPNS_CERTIFICATE_FILE can be set. Not both.');
|
2013-07-18 13:45:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!process.env.AZURE_MPNS_CERTIFICATE_KEY && process.env.AZURE_MPNS_CERTIFICATE_KEY_FILE) {
|
|
|
|
process.env.AZURE_MPNS_CERTIFICATE_KEY = fs.readFileSync(process.env['AZURE_MPNS_CERTIFICATE_KEY_FILE']).toString();
|
2013-07-29 22:34:12 +04:00
|
|
|
} else if (process.env.AZURE_MPNS_CERTIFICATE_KEY && process.env.AZURE_MPNS_CERTIFICATE_KEY_FILE) {
|
|
|
|
throw new Error('Only one of AZURE_MPNS_CERTIFICATE_KEY or AZURE_MPNS_CERTIFICATE_KEY_FILE can be set. Not both.');
|
2013-07-18 13:45:15 +04:00
|
|
|
}
|
2014-04-18 19:13:10 +04:00
|
|
|
|
2013-10-26 21:50:54 +04:00
|
|
|
if (!process.env.AZURE_ACCESS_TOKEN) {
|
|
|
|
process.env.AZURE_ACCESS_TOKEN = defaultAccessToken;
|
|
|
|
}
|
|
|
|
|
2014-01-05 15:38:07 +04:00
|
|
|
if (!process.env.AZURE_CERTIFICATE_PEM_FILE) {
|
|
|
|
process.env.AZURE_CERTIFICATE_PEM_FILE = path.join(__dirname, '../test/data/certificate.pem');
|
|
|
|
}
|
|
|
|
|
2013-03-25 20:49:46 +04:00
|
|
|
if (!process.env.NOCK_OFF && !process.env.AZURE_NOCK_RECORD) {
|
2013-04-19 15:33:36 +04:00
|
|
|
process.env.AZURE_APNS_CERTIFICATE = 'fake_certificate';
|
|
|
|
process.env.AZURE_APNS_CERTIFICATE_KEY = 'fake_certificate_key';
|
|
|
|
|
|
|
|
process.env.AZURE_WNS_PACKAGE_SID = 'sid';
|
|
|
|
process.env.AZURE_WNS_SECRET_KEY = 'key';
|
|
|
|
|
2013-06-04 02:16:21 +04:00
|
|
|
process.env.AZURE_GCM_KEY = 'fakekey'.toString('base64');
|
2013-06-01 20:28:33 +04:00
|
|
|
|
2013-07-18 13:45:15 +04:00
|
|
|
process.env.AZURE_MPNS_CERTIFICATE = 'fake_certificate';
|
|
|
|
process.env.AZURE_MPNS_CERTIFICATE_KEY = 'fake_certificate_key';
|
|
|
|
|
2013-03-25 20:49:46 +04:00
|
|
|
if (process.env.AZURE_STORAGE_ACCOUNT !== defaultStorageAccount) {
|
|
|
|
process.env.AZURE_STORAGE_ACCOUNT = defaultStorageAccount;
|
2013-02-21 16:37:27 +04:00
|
|
|
}
|
|
|
|
|
2013-05-01 00:41:07 +04:00
|
|
|
process.env.AZURE_STORAGE_ACCESS_KEY = new Buffer('fake_key').toString('base64');
|
|
|
|
|
2013-03-25 20:49:46 +04:00
|
|
|
if (process.env.AZURE_SERVICEBUS_NAMESPACE !== defaultServiceBusAccount) {
|
|
|
|
process.env.AZURE_SERVICEBUS_NAMESPACE = defaultServiceBusAccount;
|
2013-02-21 16:37:27 +04:00
|
|
|
process.env.AZURE_SERVICEBUS_ACCESS_KEY = new Buffer('fake_key').toString('base64');
|
|
|
|
}
|
|
|
|
|
2013-03-25 20:49:46 +04:00
|
|
|
if (process.env.AZURE_SUBSCRIPTION_ID !== defaultSubscription) {
|
|
|
|
process.env.AZURE_SUBSCRIPTION_ID = defaultSubscription;
|
2013-02-21 16:37:27 +04:00
|
|
|
process.env.AZURE_CERTIFICATE = 'fake_certificate';
|
|
|
|
process.env.AZURE_CERTIFICATE_KEY = 'fake_certificate_key';
|
|
|
|
}
|
2013-04-19 15:33:36 +04:00
|
|
|
} else {
|
|
|
|
if (!process.env.NOCK_OFF && process.env.AZURE_NOCK_RECORD) {
|
|
|
|
// If in record mode, and environment variables are set, make sure they are the expected one for recording
|
|
|
|
// NOTE: For now, only the Core team can update recordings. For non-core team PRs, the recordings will be updated
|
|
|
|
// after merge
|
|
|
|
if (process.env.AZURE_STORAGE_ACCOUNT && process.env.AZURE_STORAGE_ACCOUNT !== defaultStorageAccount) {
|
|
|
|
throw new Error('Storage recordings can only be made with the account ' + defaultStorageAccount);
|
|
|
|
}
|
2013-03-25 20:49:46 +04:00
|
|
|
|
2013-04-19 15:33:36 +04:00
|
|
|
if (process.env.AZURE_SERVICEBUS_NAMESPACE && process.env.AZURE_SERVICEBUS_NAMESPACE !== defaultServiceBusAccount) {
|
|
|
|
throw new Error('Service Bus recordings can only be made with the namespace ' + defaultServiceBusAccount);
|
|
|
|
}
|
2013-03-25 20:49:46 +04:00
|
|
|
|
2013-04-19 15:33:36 +04:00
|
|
|
if (process.env.AZURE_SUBSCRIPTION_ID && process.env.AZURE_SUBSCRIPTION_ID !== defaultSubscription) {
|
|
|
|
throw new Error('Service Management recordings can only be made with the subscription ' + defaultSubscription);
|
|
|
|
}
|
2013-03-25 20:49:46 +04:00
|
|
|
}
|
2013-02-21 16:37:27 +04:00
|
|
|
}
|
|
|
|
|
2017-09-30 10:30:50 +03:00
|
|
|
require('../node_modules/mocha/bin/mocha');
|