mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Drop tests that rely on the legacy deploy service
This commit is contained in:
@@ -1,147 +0,0 @@
|
||||
var selftest = require('../tool-testing/selftest.js');
|
||||
var testUtils = require('../tool-testing/test-utils.js');
|
||||
var Sandbox = selftest.Sandbox;
|
||||
var config = require('../meteor-services/config.js');
|
||||
|
||||
var commandTimeoutSecs = testUtils.accountsCommandTimeoutSecs;
|
||||
|
||||
var loggedInError = function(run) {
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr("You must be logged in for that.");
|
||||
run.expectExit(1);
|
||||
};
|
||||
|
||||
selftest.define("authorized", ['net', 'slow'], function () {
|
||||
var s = new Sandbox;
|
||||
|
||||
// Deploy an app authorized to test.
|
||||
testUtils.login(s, "test", "testtest");
|
||||
var appName = testUtils.createAndDeployApp(s);
|
||||
testUtils.logout(s);
|
||||
|
||||
// You are not authorized if you are not logged in.
|
||||
var run = s.run("authorized", appName);
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr("You must be logged in for that.");
|
||||
run.expectExit(1);
|
||||
|
||||
run = s.run("authorized");
|
||||
run.matchErr("not enough arguments");
|
||||
|
||||
run = s.run("authorized", appName, "--remove", "bob");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr("You must be logged in for that.");
|
||||
run.expectExit(1);
|
||||
|
||||
run = s.run("authorized", appName, "--add", "bob");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr("You must be logged in for that.");
|
||||
run.expectExit(1);
|
||||
|
||||
run = s.run("authorized", appName, "--list");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr("You must be logged in for that.");
|
||||
run.expectExit(1);
|
||||
|
||||
// Now let us log in, but as the wrong user.
|
||||
testUtils.login(s, "testtest", "testtest");
|
||||
|
||||
run = s.run("authorized", appName, "--remove", "bob");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr("Couldn't change authorized users");
|
||||
run.expectExit(1);
|
||||
|
||||
run = s.run("authorized", appName, "--add", "bob");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr("Couldn't change authorized users");
|
||||
run.expectExit(1);
|
||||
|
||||
run = s.run("authorized", appName, "--list");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr("Couldn't get authorized users list");
|
||||
run.expectExit(1);
|
||||
|
||||
// Yay, now let's log in as the right user.
|
||||
testUtils.logout(s);
|
||||
testUtils.login(s, "test", "testtest");
|
||||
|
||||
run = s.run("authorized", appName, "--list");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.match("test");
|
||||
run.expectExit(0);
|
||||
|
||||
run = s.run("authorized", appName, "--add", "test");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr("Couldn't change authorized users: test: already an authorized user");
|
||||
run.expectExit(1);
|
||||
|
||||
// Adding a user
|
||||
var newUser = testUtils.randomString(10);
|
||||
run = s.run("authorized", appName, "--add", newUser);
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr("Couldn't change authorized users: Unknown user");
|
||||
run.expectExit(1);
|
||||
|
||||
run = s.run("authorized", appName, "--add", "testtest");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.match(": added testtest");
|
||||
run.expectExit(0);
|
||||
|
||||
run = s.run("authorized", appName, "--list");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.match("test\ntesttest");
|
||||
run.expectExit(0);
|
||||
|
||||
// Removing a user
|
||||
run = s.run("authorized", appName, "--remove", newUser);
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr("Couldn't change authorized users: Unknown user");
|
||||
run.expectExit(1);
|
||||
|
||||
run = s.run("authorized", appName, "--remove", "test");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr("Couldn't change authorized users: Can't remove yourself");
|
||||
run.expectExit(1);
|
||||
|
||||
run = s.run("authorized", appName, "--remove", "testtest");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.match(": removed testtest");
|
||||
run.expectExit(0);
|
||||
|
||||
run = s.run("authorized", appName, "--list");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.match("test\n");
|
||||
run.expectExit(0);
|
||||
|
||||
run = s.run("authorized", appName, "--remove", "testtest");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr("Couldn't change authorized users: testtest: not an authorized user");
|
||||
run.expectExit(1);
|
||||
|
||||
testUtils.cleanUpApp(s, appName);
|
||||
testUtils.logout(s);
|
||||
});
|
||||
|
||||
selftest.define('authorized - no username', ['net', 'slow'], function () {
|
||||
var s = new Sandbox;
|
||||
|
||||
// We shouldn't be able to add authorized users before we set a
|
||||
// username.
|
||||
var email = testUtils.randomUserEmail();
|
||||
var username = testUtils.randomString(10);
|
||||
var appName = testUtils.randomAppName() + "." +
|
||||
(process.env.DEPLOY_HOSTNAME || config.getDeployHostname());
|
||||
var token = testUtils.deployWithNewEmail(s, email, appName);
|
||||
var run = s.run('authorized', appName, '--add', 'test');
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr('You must set a password on your account');
|
||||
run.expectExit(1);
|
||||
// After we set a username, we should be able to authorize others.
|
||||
testUtils.registerWithToken(token, username, 'testtest', email);
|
||||
run = s.run('authorized', appName, '--add', 'test');
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.match(': added test');
|
||||
run.expectExit(0);
|
||||
testUtils.cleanUpApp(s, appName);
|
||||
testUtils.logout(s);
|
||||
});
|
||||
39
tools/tests/cordova-hcp.js
vendored
39
tools/tests/cordova-hcp.js
vendored
@@ -39,42 +39,3 @@ selftest.define(
|
||||
|
||||
run.stop();
|
||||
});
|
||||
|
||||
selftest.define("cordova app gets https:// URLs when force-ssl is used", ["cordova", "net", "slow"], function () {
|
||||
var s = new Sandbox();
|
||||
var run;
|
||||
|
||||
s.createApp("myapp", "standard-app");
|
||||
s.cd("myapp");
|
||||
|
||||
// Add 'android' to the .meteor/platforms file, just so that the
|
||||
// Cordova boilerplate will be generated and served, without having
|
||||
// to download the whole Android sdk.
|
||||
var platforms = s.read(".meteor/platforms");
|
||||
s.write(".meteor/platforms", platforms + "\nandroid\n");
|
||||
|
||||
run = s.run("add", "force-ssl");
|
||||
run.waitSecs(15);
|
||||
run.expectExit(0);
|
||||
|
||||
testUtils.login(s, "test", "testtest");
|
||||
|
||||
var appName = testUtils.randomAppName() + "." + config.getDeployHostname();
|
||||
run = s.run("deploy", appName);
|
||||
run.waitSecs(90);
|
||||
run.expectExit(0);
|
||||
|
||||
var url = "https://" + appName;
|
||||
|
||||
var result = httpHelpers.getUrl(url + "/__cordova/index.html");
|
||||
|
||||
run = s.run("deploy", "-D", appName);
|
||||
run.waitSecs(30);
|
||||
run.expectExit(0);
|
||||
|
||||
testUtils.logout(s);
|
||||
|
||||
var mrc = testUtils.getMeteorRuntimeConfigFromHTML(result);
|
||||
selftest.expectEqual(mrc.DDP_DEFAULT_CONNECTION_URL, url + "/");
|
||||
selftest.expectEqual(mrc.ROOT_URL, url + "/");
|
||||
});
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
var _ = require('underscore');
|
||||
var selftest = require('../tool-testing/selftest.js');
|
||||
var testUtils = require('../tool-testing/test-utils.js');
|
||||
var files = require('../fs/files.js');
|
||||
var Sandbox = selftest.Sandbox;
|
||||
var httpHelpers = require('../utils/http-helpers.js');
|
||||
var config = require('../meteor-services/config.js');
|
||||
|
||||
var commandTimeoutSecs = testUtils.accountsCommandTimeoutSecs;
|
||||
|
||||
selftest.define('deploy - expired credentials', ['net', 'slow'], function () {
|
||||
var s = new Sandbox;
|
||||
// Create an account and then expire the login token before setting a
|
||||
// username. On the next deploy, we should get an email prompt
|
||||
// followed by a registration email, not a username prompt.
|
||||
var email = testUtils.randomUserEmail();
|
||||
var appName = testUtils.randomAppName() + "." +
|
||||
config.getDeployHostname();
|
||||
var token = testUtils.deployWithNewEmail(s, email, appName);
|
||||
var sessionFile = s.readSessionFile();
|
||||
testUtils.logout(s);
|
||||
s.writeSessionFile(sessionFile);
|
||||
var run = s.run('deploy', appName);
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr('Expired credential');
|
||||
run.expectExit(1);
|
||||
|
||||
// Complete registration so that we can clean up our app.
|
||||
var username = testUtils.randomString(10);
|
||||
testUtils.registerWithToken(token, username,
|
||||
'testtest', email);
|
||||
testUtils.login(s, username, 'testtest');
|
||||
testUtils.cleanUpApp(s, appName);
|
||||
testUtils.logout(s);
|
||||
|
||||
// Create an account, set a username, expire the login token, and
|
||||
// deploy again. We should get a username/password prompt.
|
||||
email = testUtils.randomUserEmail();
|
||||
appName = testUtils.randomAppName() + "." +
|
||||
config.getDeployHostname();
|
||||
username = testUtils.randomString(10);
|
||||
token = testUtils.deployWithNewEmail(s, email, appName);
|
||||
testUtils.registerWithToken(token, username,
|
||||
'testtest', email);
|
||||
run = s.run('whoami');
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.read(username + '\n');
|
||||
run.expectExit(0);
|
||||
|
||||
sessionFile = s.readSessionFile();
|
||||
testUtils.logout(s);
|
||||
s.writeSessionFile(sessionFile);
|
||||
|
||||
run = s.run('deploy', appName);
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr('Username:');
|
||||
run.write(username + '\n');
|
||||
run.matchErr('Password:');
|
||||
run.write('testtest' + '\n');
|
||||
run.waitSecs(90);
|
||||
run.expectExit(0);
|
||||
|
||||
testUtils.cleanUpApp(s, appName);
|
||||
testUtils.logout(s);
|
||||
});
|
||||
|
||||
selftest.define('deploy - bad arguments', [], function () {
|
||||
var s = new Sandbox;
|
||||
|
||||
// Deploy with no app name should fail
|
||||
var run = s.run('deploy');
|
||||
run.matchErr('not enough arguments');
|
||||
run.expectExit(1);
|
||||
|
||||
// Deploy outside of an app directory
|
||||
run = s.run('deploy', testUtils.randomAppName() + "." +
|
||||
config.getDeployHostname());
|
||||
run.matchErr('not in a Meteor project directory');
|
||||
run.expectExit(1);
|
||||
});
|
||||
|
||||
selftest.define('deploy - logged in', ['net', 'slow'], function () {
|
||||
var sandbox = new Sandbox;
|
||||
sandbox.createApp('deployapp', 'empty');
|
||||
sandbox.cd('deployapp');
|
||||
|
||||
testUtils.login(sandbox, 'test', 'testtest');
|
||||
|
||||
// NON-LEGACY APPS
|
||||
|
||||
// Deploy an app.
|
||||
var appName = testUtils.createAndDeployApp(sandbox);
|
||||
|
||||
// Try to deploy to it from a different account -- should fail.
|
||||
testUtils.logout(sandbox);
|
||||
testUtils.login(sandbox, 'testtest', 'testtest');
|
||||
var run = sandbox.run('deploy', appName);
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr('belongs to a different user');
|
||||
run.expectExit(1);
|
||||
|
||||
testUtils.logout(sandbox);
|
||||
testUtils.login(sandbox, 'test', 'testtest');
|
||||
|
||||
// Delete our deployed app.
|
||||
testUtils.cleanUpApp(sandbox, appName);
|
||||
testUtils.logout(sandbox);
|
||||
});
|
||||
|
||||
|
||||
selftest.define('deploy - logged out', ['net', 'slow'], function () {
|
||||
var s = new Sandbox;
|
||||
|
||||
testUtils.login(s, 'test', 'testtest');
|
||||
var appName = testUtils.createAndDeployApp(s);
|
||||
testUtils.logout(s);
|
||||
|
||||
// Deploy when logged out. We should be prompted to log in and then
|
||||
// the deploy should succeed.
|
||||
var run = s.run('deploy', appName);
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr('Email:');
|
||||
run.write('test@test.com\n');
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr('Password:');
|
||||
run.write('testtest\n');
|
||||
run.waitSecs(90);
|
||||
run.match('Now serving at http://' + appName);
|
||||
run.expectExit(0);
|
||||
testUtils.cleanUpApp(s, appName);
|
||||
|
||||
testUtils.logout(s);
|
||||
|
||||
// Deploying to a new app using a user that exists but has no password
|
||||
// set should prompt us to set a password.
|
||||
// First, create a user without a password.
|
||||
appName = testUtils.randomAppName() + "." + config.getDeployHostname();
|
||||
var email = testUtils.randomUserEmail();
|
||||
run = s.run('deploy', appName);
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr('Email:');
|
||||
run.write(email + '\n');
|
||||
run.waitSecs(90);
|
||||
run.match('Now serving');
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.expectExit(0);
|
||||
// Now that we've created an account with this email address, we
|
||||
// should be logged in as it and should be able to delete it.
|
||||
testUtils.cleanUpApp(s, appName);
|
||||
testUtils.logout(s);
|
||||
// Now that we've created a user, try to deploy a new app.
|
||||
appName = testUtils.randomAppName() + "." + config.getDeployHostname();
|
||||
run = s.run('deploy', appName);
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr('Email:');
|
||||
run.write(email + '\n');
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr('pick a password');
|
||||
run.matchErr('sent to you with the link');
|
||||
run.stop();
|
||||
});
|
||||
@@ -1,55 +0,0 @@
|
||||
var selftest = require('../tool-testing/selftest.js');
|
||||
var testUtils = require('../tool-testing/test-utils.js');
|
||||
var utils = require('../utils/utils.js');
|
||||
var Sandbox = selftest.Sandbox;
|
||||
|
||||
selftest.define('deploy - with settings', ['net', 'slow'], function () {
|
||||
var s = new Sandbox;
|
||||
testUtils.login(s, 'test', 'testtest');
|
||||
var settings = {
|
||||
'public': { a: 'b' }
|
||||
};
|
||||
s.write('settings.json', JSON.stringify(settings));
|
||||
|
||||
// Deploy an app with settings and check that the public settings
|
||||
// appear in the HTTP response body.
|
||||
var appName = testUtils.createAndDeployApp(s, {
|
||||
// Use standard-app instead of empty because we actually want
|
||||
// standard-app-packages (including webapp) so that we can send a
|
||||
// HTTP request to the app and get a response.
|
||||
templateApp: 'standard-app',
|
||||
// The path is ../settings.json instead of settings.json because
|
||||
// createAndDeployApp creates a new app directory and cd's into it.
|
||||
settingsFile: '../settings.json'
|
||||
});
|
||||
testUtils.checkForSettings(appName, settings, 10);
|
||||
|
||||
// Re-deploy without settings and check that the settings still
|
||||
// appear.
|
||||
s.cd('..');
|
||||
testUtils.createAndDeployApp(s, {
|
||||
templateApp: 'standard-app',
|
||||
appName: appName
|
||||
});
|
||||
// It takes a few seconds for the app to actually update, and we don't
|
||||
// want to get a false positive in the meantime (i.e., if the settings
|
||||
// disappear, we don't want to send our request before the app has
|
||||
// updated and conclude that the settings are still there).
|
||||
utils.sleepMs(5000);
|
||||
testUtils.checkForSettings(appName, settings, 10);
|
||||
|
||||
// Re-deploy with new settings and check that the settings get
|
||||
// updated.
|
||||
settings['public'].a = 'c';
|
||||
s.cd('..');
|
||||
s.write('settings.json', JSON.stringify(settings));
|
||||
testUtils.createAndDeployApp(s, {
|
||||
templateApp: 'standard-app',
|
||||
settingsFile: '../settings.json',
|
||||
appName: appName
|
||||
});
|
||||
testUtils.checkForSettings(appName, settings, 10);
|
||||
|
||||
testUtils.cleanUpApp(s, appName);
|
||||
testUtils.logout(s);
|
||||
});
|
||||
@@ -1,30 +0,0 @@
|
||||
var _ = require('underscore');
|
||||
var selftest = require('../tool-testing/selftest.js');
|
||||
var testUtils = require('../tool-testing/test-utils.js');
|
||||
var files = require('../fs/files.js');
|
||||
var config = require('../meteor-services/config.js');
|
||||
var Sandbox = selftest.Sandbox;
|
||||
|
||||
var commandTimeoutSecs = testUtils.accountsCommandTimeoutSecs;
|
||||
|
||||
selftest.define('list-sites - basic', ['net', 'slow'], function () {
|
||||
var s = new Sandbox;
|
||||
var email = testUtils.randomUserEmail();
|
||||
var appName1 = testUtils.randomAppName() + "." + config.getDeployHostname();
|
||||
var appName2 = testUtils.randomAppName() + "." + config.getDeployHostname();
|
||||
testUtils.deployWithNewEmail(s, email, appName1);
|
||||
testUtils.createAndDeployApp(s, { appName: appName2 });
|
||||
var sortedApps = [appName1, appName2];
|
||||
sortedApps.sort();
|
||||
|
||||
var run = s.run('list-sites');
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
_.each(sortedApps, function (app) {
|
||||
run.read(app + '\n');
|
||||
});
|
||||
run.expectEnd();
|
||||
run.expectExit(0);
|
||||
testUtils.cleanUpApp(s, appName1);
|
||||
testUtils.cleanUpApp(s, appName2);
|
||||
testUtils.logout(s);
|
||||
});
|
||||
@@ -122,26 +122,3 @@ selftest.define("login", ['net'], function () {
|
||||
run.matchErr("Login failed");
|
||||
run.expectExit(1);
|
||||
});
|
||||
|
||||
selftest.define('whoami - no username', ['net', 'slow'], function () {
|
||||
var s = new Sandbox;
|
||||
var email = testUtils.randomUserEmail();
|
||||
var username = testUtils.randomString(10);
|
||||
var appName = testUtils.randomAppName();
|
||||
var token = testUtils.deployWithNewEmail(s, email, appName);
|
||||
|
||||
var run = s.run('whoami');
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr('You haven\'t chosen your username yet');
|
||||
run.matchErr(testUtils.registrationUrlRegexp);
|
||||
run.expectExit(1);
|
||||
testUtils.registerWithToken(token, username, 'test', email);
|
||||
|
||||
run = s.run('whoami');
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.read(username);
|
||||
run.expectExit(0);
|
||||
|
||||
testUtils.cleanUpApp(s, appName);
|
||||
testUtils.logout(s);
|
||||
});
|
||||
|
||||
@@ -1,192 +0,0 @@
|
||||
var _ = require('underscore');
|
||||
var selftest = require('../tool-testing/selftest.js');
|
||||
var Sandbox = selftest.Sandbox;
|
||||
var testUtils = require('../tool-testing/test-utils.js');
|
||||
var config = require('../meteor-services/config.js');
|
||||
|
||||
// XXX need to make sure that mother doesn't clean up:
|
||||
// 'legacy-password-app-for-selftest'
|
||||
// 'legacy-no-password-app-for-selftest'
|
||||
// 'app-for-selftest-not-test-owned'
|
||||
// 'app-for-selftest-test-owned'
|
||||
|
||||
var commandTimeoutSecs = testUtils.accountsCommandTimeoutSecs;
|
||||
var loginTimeoutSecs = 2;
|
||||
|
||||
// Run 'meteor logs' or 'meteor mongo' against an app. Options:
|
||||
// - legacy: boolean
|
||||
// - passwordProtected: if legacy is true, then true if the app has a
|
||||
// password set
|
||||
// - loggedIn: if true, the user is currently logged in, so we should
|
||||
// not expect a login prompt
|
||||
// - authorized: if loggedIn is true, then this boolean should indicate
|
||||
// whether the current user is authorized for the app
|
||||
// - username: the username to use if given a login prompt (defaults to
|
||||
// 'test')
|
||||
// - password: the password to use if given a login prompt (defaults to
|
||||
// 'testtest');
|
||||
var logsOrMongoForApp = function (sandbox, command, appName, options) {
|
||||
|
||||
if (appName.indexOf(".") === -1) {
|
||||
appName = appName + "." + config.getDeployHostname();
|
||||
}
|
||||
|
||||
var runArgs = [command, appName];
|
||||
var matchString;
|
||||
if (command === 'mongo') {
|
||||
runArgs.push('--url');
|
||||
matchString = 'mongodb://';
|
||||
} else if (command === 'logs') {
|
||||
// I suppose it's possible that we don't have any INFO messages in
|
||||
// the logs, but it seems unlikely. Every time we run a command we
|
||||
// hit /_GALAXY_ on the site.
|
||||
// XXX This is no longer true now that we've removed legacy Galaxy
|
||||
// prototype support, so if this causes test flakiness, it may
|
||||
// need to be tweaked.
|
||||
matchString = 'INFO';
|
||||
} else {
|
||||
throw new Error('Command must be "logs" or "mongo"');
|
||||
}
|
||||
|
||||
var run = sandbox.run.apply(sandbox, runArgs);
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
|
||||
var expectSuccess = selftest.markStack(function () {
|
||||
run.waitSecs(2);
|
||||
run.match(matchString);
|
||||
run.expectExit(0);
|
||||
});
|
||||
|
||||
var expectUnauthorized = selftest.markStack(function () {
|
||||
run.matchErr('belongs to a different user');
|
||||
run.expectExit(1);
|
||||
});
|
||||
|
||||
if (options.legacy) {
|
||||
if (options.passwordProtected) {
|
||||
run.matchErr('meteor claim');
|
||||
run.expectExit(1);
|
||||
} else {
|
||||
// Getting logs or mongo for a non-password-protected legacy app
|
||||
// should just work, without a login or registration prompt.
|
||||
expectSuccess();
|
||||
}
|
||||
} else {
|
||||
if (options.loggedIn) {
|
||||
if (options.authorized) {
|
||||
expectSuccess();
|
||||
} else {
|
||||
expectUnauthorized();
|
||||
}
|
||||
} else {
|
||||
// If we are not logged in and this is not a legacy app, then we
|
||||
// expect a login prompt.
|
||||
//
|
||||
// (If testReprompt is true, try getting reprompted as a result
|
||||
// of entering no username or a bad password.)
|
||||
run.waitSecs(loginTimeoutSecs);
|
||||
if (options.testReprompt) {
|
||||
run.matchErr('Username: ');
|
||||
run.write("\n");
|
||||
run.matchErr("Username:");
|
||||
run.write(" \n");
|
||||
}
|
||||
run.matchErr('Username: ');
|
||||
run.waitSecs(loginTimeoutSecs);
|
||||
run.write((options.username || 'test') + '\n');
|
||||
if (options.testReprompt) {
|
||||
run.matchErr("Password:");
|
||||
run.write("wrongpassword\n");
|
||||
run.waitSecs(15);
|
||||
run.matchErr("failed");
|
||||
}
|
||||
run.matchErr('Password: ');
|
||||
run.write((options.password || 'testtest') + '\n');
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
if (options.authorized) {
|
||||
expectSuccess();
|
||||
} else {
|
||||
expectUnauthorized();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
_.each([false, true], function (loggedIn) {
|
||||
_.each(['logs', 'mongo'], function (command) {
|
||||
selftest.define(
|
||||
command + ' - ' + (loggedIn ? 'logged in' : 'logged out'),
|
||||
['net'],
|
||||
function () {
|
||||
var s = new Sandbox;
|
||||
var run;
|
||||
if (loggedIn) {
|
||||
run = s.run('login');
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr('Username:');
|
||||
run.write('test\n');
|
||||
run.matchErr('Password:');
|
||||
run.write('testtest\n');
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr('Logged in as test.');
|
||||
run.expectExit(0);
|
||||
}
|
||||
|
||||
// Running 'meteor logs' without an app name should fail.
|
||||
if (command === 'logs') {
|
||||
run = s.run(command);
|
||||
run.matchErr('not enough arguments');
|
||||
run.expectExit(1);
|
||||
}
|
||||
// Running 'meteor mongo' without an app name and not in an app
|
||||
// dir should fail.
|
||||
if (command === 'mongo') {
|
||||
run = s.run('mongo');
|
||||
run.matchErr('not in a Meteor project directory');
|
||||
run.expectExit(1);
|
||||
}
|
||||
|
||||
logsOrMongoForApp(s, command,
|
||||
'legacy-no-password-app-for-selftest', {
|
||||
legacy: true,
|
||||
passwordProtected: false,
|
||||
loggedIn: loggedIn
|
||||
});
|
||||
|
||||
logsOrMongoForApp(s, command,
|
||||
'legacy-password-app-for-selftest', {
|
||||
legacy: true,
|
||||
passwordProtected: true,
|
||||
loggedIn: loggedIn
|
||||
});
|
||||
|
||||
logsOrMongoForApp(s, command,
|
||||
'app-for-selftest-not-test-owned', {
|
||||
loggedIn: loggedIn,
|
||||
authorized: false,
|
||||
testReprompt: true
|
||||
});
|
||||
|
||||
if (! loggedIn) {
|
||||
// We logged in as a result of running the previous command,
|
||||
// so log out again.
|
||||
run = s.run('logout');
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr('Logged out');
|
||||
run.expectExit(0);
|
||||
}
|
||||
|
||||
logsOrMongoForApp(s, command,
|
||||
'app-for-selftest-test-owned', {
|
||||
loggedIn: loggedIn,
|
||||
authorized: true
|
||||
});
|
||||
|
||||
// Again, we logged in as a result of running the previous
|
||||
// command if we weren't logged in already, so log out now to
|
||||
// clean up our token.
|
||||
testUtils.logout(s);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -85,102 +85,5 @@ selftest.define("organizations", ["net", "slow", "checkout"], function () {
|
||||
run.match(orgName + "\n");
|
||||
run.expectExit(0);
|
||||
|
||||
// Deploy an app and authorize our organization.
|
||||
var appName = testUtils.createAndDeployApp(s);
|
||||
run = s.run("authorized", appName, "--add", orgName);
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.expectExit(0);
|
||||
|
||||
run = s.run("authorized", appName);
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.read("test\n" + orgName + "\n");
|
||||
run.expectExit(0);
|
||||
|
||||
testUtils.logout(s);
|
||||
|
||||
// Log in as testtest and see that we are authorized.
|
||||
testUtils.login(s, "testtest", "testtest");
|
||||
run = s.run("list-sites");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.match(appName);
|
||||
run.expectExit(0);
|
||||
|
||||
run = s.run("logs", appName);
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.expectExit(0);
|
||||
|
||||
run = s.run("admin", "list-organizations");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.match(orgName);
|
||||
run.expectExit(0);
|
||||
|
||||
testUtils.logout(s);
|
||||
testUtils.login(s, "test", "testtest");
|
||||
|
||||
// Remove testtest from the organization.
|
||||
run = s.run("admin", "members", orgName, "--remove", "testtest");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.expectExit(0);
|
||||
|
||||
run = s.run("admin", "members", orgName);
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.forbidAll("testtest");
|
||||
run.expectExit(0);
|
||||
|
||||
testUtils.logout(s);
|
||||
|
||||
// Log in as testtest, see that we are no longer authorized.
|
||||
testUtils.login(s, "testtest", "testtest");
|
||||
run = s.run("list-sites");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.forbidAll(appName);
|
||||
run.expectExit(0);
|
||||
|
||||
run = s.run("logs", appName);
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr("belongs to a different user");
|
||||
run.expectExit(1);
|
||||
|
||||
run = s.run("admin", "list-organizations");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.forbidAll(orgName);
|
||||
run.expectExit(0);
|
||||
|
||||
run = s.run("admin", "members", orgName);
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr("not a member of this organization");
|
||||
run.expectExit(1);
|
||||
|
||||
testUtils.logout(s);
|
||||
|
||||
// Add testtest back to the org, and then de-authorize the org for our
|
||||
// app.
|
||||
testUtils.login(s, "test", "testtest");
|
||||
run = s.run("admin", "members", orgName, "--add", "testtest");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.expectExit(0);
|
||||
|
||||
run = s.run("authorized", appName, "--remove", orgName);
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.expectExit(0);
|
||||
|
||||
run = s.run("authorized", appName);
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.forbidAll(appName);
|
||||
run.expectExit(0);
|
||||
|
||||
// As testtest, check that we are not still authorized.
|
||||
testUtils.logout(s);
|
||||
testUtils.login(s, "testtest", "testtest");
|
||||
run = s.run("list-sites");
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.forbidAll(appName);
|
||||
run.expectExit(0);
|
||||
|
||||
run = s.run("logs", appName);
|
||||
run.waitSecs(commandTimeoutSecs);
|
||||
run.matchErr("belongs to a different user");
|
||||
run.expectExit(1);
|
||||
|
||||
testUtils.logout(s);
|
||||
});
|
||||
|
||||
@@ -1,279 +0,0 @@
|
||||
var _ = require('underscore');
|
||||
var selftest = require('../tool-testing/selftest.js');
|
||||
var testUtils = require('../tool-testing/test-utils.js');
|
||||
var utils = require('../utils/utils.js');
|
||||
var Sandbox = selftest.Sandbox;
|
||||
var httpHelpers = require('../utils/http-helpers.js');
|
||||
var config = require('../meteor-services/config.js');
|
||||
|
||||
var expectInvalidToken = selftest.markStack(function (token) {
|
||||
// Same XXX as testUtils.registerWithToken: should be hardcoded to
|
||||
// https://www.meteor.com?
|
||||
var accountsConn = testUtils.ddpConnect(config.getAuthDDPUrl());
|
||||
var registrationTokenInfo = accountsConn.call('registrationTokenInfo',
|
||||
token);
|
||||
// We should not be able to get a registration code for an invalid
|
||||
// token.
|
||||
if (registrationTokenInfo.valid || registrationTokenInfo.code) {
|
||||
selftest.fail('Expected invalid token is valid!');
|
||||
}
|
||||
accountsConn.close();
|
||||
});
|
||||
|
||||
// Polls a guerrillamail.com inbox every 3 seconds looking for an email
|
||||
// that matches the given subject and body regexes. This could fail if
|
||||
// there is someone else polling this same inbox, so use a random email
|
||||
// address.
|
||||
//
|
||||
// If a matching email is found before the timeout elapses, this
|
||||
// function returns an object with keys:
|
||||
// - subject: the subject line of the matching email
|
||||
// - bodyPage: HTML (an entire rendered page) containing the body of
|
||||
// the email
|
||||
// Throws an exception if no matching email is found before the timeout
|
||||
// elapses.
|
||||
var waitForEmail = selftest.markStack(function (inbox, subjectRegExp,
|
||||
bodyRegExp, timeoutSecs) {
|
||||
var timedOut = false;
|
||||
if (timeoutSecs) {
|
||||
var timeout = setTimeout(function () {
|
||||
timedOut = true;
|
||||
}, timeoutSecs * 1000);
|
||||
}
|
||||
|
||||
// Get a session cookie for this inbox.
|
||||
var setEmailUrl = 'https://www.guerrillamail.com/ajax.php?f=set_email_user';
|
||||
var setEmailData = {
|
||||
email_user: inbox.split('@')[0],
|
||||
domain: 'guerrillamail.com'
|
||||
};
|
||||
var setEmailResult = httpHelpers.request({
|
||||
method: 'POST',
|
||||
url: setEmailUrl,
|
||||
form: setEmailData
|
||||
});
|
||||
|
||||
var sessionCookie = JSON.parse(setEmailResult.body).sid_token;
|
||||
|
||||
var cookieHeader = "PHPSESSID=" + sessionCookie + ";";
|
||||
|
||||
var match;
|
||||
while (! match) {
|
||||
var checkInboxUrl = 'https://www.guerrillamail.com/ajax.php?' +
|
||||
'f=check_email&seq=1&domain=guerrillamail.com&_=' +
|
||||
(+ new Date());
|
||||
var checkInboxResult = httpHelpers.request({
|
||||
method: 'GET',
|
||||
url: checkInboxUrl,
|
||||
headers: { Cookie: cookieHeader }
|
||||
});
|
||||
|
||||
var body = JSON.parse(checkInboxResult.body);
|
||||
_.each(body.list, function (email) {
|
||||
var emailId = email.mail_id;
|
||||
var subject = email.mail_subject;
|
||||
if (subjectRegExp.test(subject)) {
|
||||
// Subject matches, so now check the body.
|
||||
var bodyResult = httpHelpers.request({
|
||||
url: 'https://www.guerrillamail.com/inbox?mail_id=' + emailId,
|
||||
headers: { Cookie: cookieHeader }
|
||||
});
|
||||
if (bodyRegExp.test(bodyResult.body)) {
|
||||
match = {
|
||||
subject: email.mail_subject,
|
||||
bodyPage: bodyResult.body
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (! match) {
|
||||
utils.sleepMs(3000);
|
||||
if (timedOut) {
|
||||
selftest.fail('Waiting for email to ' + inbox + ' timed out.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clearTimeout(timeout);
|
||||
return match;
|
||||
});
|
||||
|
||||
selftest.define('deferred registration - email registration token', ['net', 'slow'], function () {
|
||||
var s = new Sandbox;
|
||||
var email = testUtils.randomUserEmail();
|
||||
var username = testUtils.randomString(10);
|
||||
var appName = testUtils.randomAppName();
|
||||
|
||||
var apiToken = testUtils.deployWithNewEmail(s, email, appName);
|
||||
|
||||
// Check that we got a registration email in our inbox.
|
||||
var registrationEmail = waitForEmail(email, /Set a password/,
|
||||
/set a password/, 60);
|
||||
|
||||
// Fish out the registration token and use to it to complete
|
||||
// registration.
|
||||
var token = testUtils.registrationUrlRegexp.exec(registrationEmail.bodyPage);
|
||||
if (! token || ! token[1]) {
|
||||
selftest.fail("No registration token in email");
|
||||
}
|
||||
token = token[1];
|
||||
|
||||
testUtils.registerWithToken(token, username, 'testtest', email);
|
||||
|
||||
// Success! 'meteor whoami' should now know who we are.
|
||||
var run = s.run('whoami');
|
||||
run.waitSecs(testUtils.accountsCommandTimeoutSecs);
|
||||
run.read(username + '\n');
|
||||
run.expectExit(0);
|
||||
|
||||
// We should be able to log out and log back in with our new password.
|
||||
testUtils.logout(s);
|
||||
testUtils.login(s, username, 'testtest');
|
||||
|
||||
// And after logging out and logging back in, we should have
|
||||
// authorization to delete our app.
|
||||
testUtils.cleanUpApp(s, appName);
|
||||
|
||||
// All the tokens we got should now be invalid.
|
||||
expectInvalidToken(token);
|
||||
expectInvalidToken(apiToken);
|
||||
|
||||
testUtils.logout(s);
|
||||
|
||||
// XXX Test that registration URLs get printed when they should
|
||||
});
|
||||
|
||||
selftest.define('deferred registration revocation', ['net'], function () {
|
||||
// Test that if we are logged in as a passwordless user, and our
|
||||
// credential gets revoked, and we do something like 'meteor whoami'
|
||||
// that polls to see if registration is complete, then we handle it
|
||||
// gracefully.
|
||||
|
||||
var s = new Sandbox;
|
||||
s.createApp('deployapp', 'empty');
|
||||
s.cd('deployapp');
|
||||
|
||||
// Create a new deferred registration account. (Don't bother to wait
|
||||
// for the deploy to go through.)
|
||||
var email = testUtils.randomUserEmail();
|
||||
var username = testUtils.randomString(10);
|
||||
var appName = testUtils.randomAppName();
|
||||
var run = s.run('deploy', appName);
|
||||
run.waitSecs(5);
|
||||
run.matchErr('Email:');
|
||||
run.write(email + '\n');
|
||||
run.waitSecs(90);
|
||||
run.match('Deploying');
|
||||
run.waitSecs(15); // because the bundler doesn't yield
|
||||
run.stop();
|
||||
|
||||
// 'whoami' says that we don't have a password
|
||||
run = s.run('whoami');
|
||||
run.waitSecs(15);
|
||||
run.matchErr('/setPassword?');
|
||||
run.expectExit(1);
|
||||
|
||||
// Revoke the credential without updating .meteorsession.
|
||||
var sessionState = s.readSessionFile();
|
||||
run = s.run('logout');
|
||||
run.waitSecs(15);
|
||||
run.matchErr("Logged out.\n");
|
||||
run.expectExit(0);
|
||||
s.writeSessionFile(sessionState);
|
||||
|
||||
// 'whoami' now says that we're not logged in. No errors are printed.
|
||||
run = s.run('whoami');
|
||||
run.waitSecs(15);
|
||||
run.readErr("Not logged in. 'meteor login' to log in.\n");
|
||||
run.expectExit(1);
|
||||
});
|
||||
|
||||
selftest.define(
|
||||
'deferred registration - api registration token',
|
||||
['net', 'slow'],
|
||||
function () {
|
||||
var s = new Sandbox;
|
||||
|
||||
var email = testUtils.randomUserEmail();
|
||||
var username = testUtils.randomString(10);
|
||||
var appName = testUtils.randomAppName();
|
||||
var token = testUtils.deployWithNewEmail(s, email, appName);
|
||||
testUtils.registerWithToken(token, username, 'testtest', email);
|
||||
|
||||
testUtils.logout(s);
|
||||
testUtils.login(s, username, 'testtest');
|
||||
testUtils.cleanUpApp(s, appName);
|
||||
|
||||
// All tokens we received should not be invalid.
|
||||
expectInvalidToken(token);
|
||||
var registrationEmail = waitForEmail(email, /Set a password/,
|
||||
/set a password/, 60);
|
||||
var emailToken = testUtils.registrationUrlRegexp.exec(
|
||||
registrationEmail.bodyPage
|
||||
);
|
||||
if (! emailToken || ! emailToken[1]) {
|
||||
selftest.fail('No registration token in email');
|
||||
}
|
||||
expectInvalidToken(emailToken[1]);
|
||||
|
||||
testUtils.logout(s);
|
||||
}
|
||||
);
|
||||
|
||||
selftest.define(
|
||||
'deferred registration - register after logging out',
|
||||
['net', 'slow'],
|
||||
function () {
|
||||
var s = new Sandbox;
|
||||
var email = testUtils.randomUserEmail();
|
||||
var username = testUtils.randomString(10);
|
||||
var appName = testUtils.randomAppName();
|
||||
var token = testUtils.deployWithNewEmail(s, email, appName);
|
||||
testUtils.logout(s);
|
||||
|
||||
// If we deploy again with the same email address after logging out,
|
||||
// we should get a message telling us to check our email and
|
||||
// register, and the tool should obediently wait for us to do that
|
||||
// before doing the deploy.
|
||||
s.createApp('deployapp2', 'empty');
|
||||
s.cd('deployapp2');
|
||||
var run = s.run('deploy', appName);
|
||||
run.waitSecs(testUtils.accountsCommandTimeoutSecs);
|
||||
run.matchErr('Email:');
|
||||
run.write(email + '\n');
|
||||
run.waitSecs(testUtils.accountsCommandTimeoutSecs);
|
||||
run.matchErr('pick a password');
|
||||
run.matchErr('Waiting for you to register on the web...');
|
||||
|
||||
var registrationEmail = waitForEmail(
|
||||
email,
|
||||
/Set a password/,
|
||||
/You previously created a Meteor developer account/,
|
||||
60
|
||||
);
|
||||
token = testUtils.registrationUrlRegexp.exec(
|
||||
registrationEmail.bodyPage
|
||||
);
|
||||
if (! token || ! token[1]) {
|
||||
selftest.fail('No registration token in email:\n' +
|
||||
registrationEmail.bodyPage);
|
||||
}
|
||||
|
||||
testUtils.registerWithToken(token[1], username, 'testtest', email);
|
||||
run.waitSecs(testUtils.accountsCommandTimeoutSecs);
|
||||
run.matchErr('Username: ' + username + '\n');
|
||||
run.matchErr('Password: ');
|
||||
run.write('testtest\n');
|
||||
run.waitSecs(90);
|
||||
run.match('Now serving at');
|
||||
run.expectExit(0);
|
||||
|
||||
run = s.run('whoami');
|
||||
run.read(username);
|
||||
run.expectExit(0);
|
||||
|
||||
testUtils.cleanUpApp(s, appName);
|
||||
testUtils.logout(s);
|
||||
}
|
||||
);
|
||||
@@ -29,45 +29,6 @@ exports.randomUserEmail = function () {
|
||||
return 'selftest-user-' + randomString(15) + '@guerrillamail.com';
|
||||
};
|
||||
|
||||
// Creates an app and deploys it. Assumes the sandbox is already logged
|
||||
// in. Returns the name of the deployed app. Options:
|
||||
// - settingsFile: a path to a settings file to deploy with
|
||||
// - appName: app name to use; will be generated randomly if not
|
||||
// provided
|
||||
// - templateApp: the name of the template app to use. defaults to 'empty'
|
||||
exports.createAndDeployApp = function (sandbox, options) {
|
||||
options = options || {};
|
||||
var name = options.appName || randomAppName();
|
||||
sandbox.createApp(name, options.templateApp || 'empty');
|
||||
sandbox.cd(name);
|
||||
|
||||
name = config.getFullAppName(name);
|
||||
|
||||
var runArgs = ['deploy', name];
|
||||
if (options.settingsFile) {
|
||||
runArgs.push('--settings');
|
||||
runArgs.push(options.settingsFile);
|
||||
}
|
||||
var run = sandbox.run.apply(sandbox, runArgs);
|
||||
run.waitSecs(90);
|
||||
run.match('Now serving at http://' + name);
|
||||
run.waitSecs(10);
|
||||
run.expectExit(0);
|
||||
return name;
|
||||
};
|
||||
|
||||
exports.cleanUpApp = function (sandbox, name) {
|
||||
if (name.indexOf(".") === -1) {
|
||||
name = name + "." + config.getDeployHostname();
|
||||
}
|
||||
|
||||
var run = sandbox.run('deploy', '-D', name);
|
||||
run.waitSecs(180);
|
||||
run.match('Deleted');
|
||||
run.expectExit(0);
|
||||
return name;
|
||||
};
|
||||
|
||||
exports.login = function (s, username, password) {
|
||||
var run = s.run('login');
|
||||
run.waitSecs(15);
|
||||
@@ -96,35 +57,6 @@ var registrationUrlRegexp =
|
||||
/https:\/\/www\.meteor\.com\/setPassword\?([a-zA-Z0-9\+\/]+)/;
|
||||
exports.registrationUrlRegexp = registrationUrlRegexp;
|
||||
|
||||
// In the sandbox `s`, create and deploy a new app with an unregistered
|
||||
// email address. Returns the registration token from the printed URL in
|
||||
// the deploy message.
|
||||
exports.deployWithNewEmail = function (s, email, appName) {
|
||||
s.createApp('deployapp', 'empty');
|
||||
s.cd('deployapp');
|
||||
|
||||
if (appName.indexOf(".") === -1) {
|
||||
appName = appName + "." + config.getDeployHostname();
|
||||
}
|
||||
|
||||
var run = s.run('deploy', appName);
|
||||
run.waitSecs(exports.accountsCommandTimeoutSecs);
|
||||
run.matchErr('Email:');
|
||||
run.write(email + '\n');
|
||||
run.waitSecs(90);
|
||||
// Check that we got a prompt to set a password on meteor.com.
|
||||
run.matchErr('set a password');
|
||||
var urlMatch = run.matchErr(registrationUrlRegexp);
|
||||
if (! urlMatch || ! urlMatch.length || ! urlMatch[1]) {
|
||||
throw new Error("Missing registration token");
|
||||
}
|
||||
var token = urlMatch[1];
|
||||
|
||||
run.expectExit(0);
|
||||
|
||||
return token;
|
||||
};
|
||||
|
||||
var getLoadedPackages = function () {
|
||||
return isopackets.load('ddp');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user