|
@@ -12,20 +12,31 @@ var execSync = require('child_process').execSync,
|
|
|
superagent = require('superagent'),
|
|
|
webdriver = require('selenium-webdriver');
|
|
|
|
|
|
+var firefox = require('selenium-webdriver/firefox');
|
|
|
+var server, browser = new firefox.Driver();
|
|
|
+var by = require('selenium-webdriver').By,
|
|
|
+ until = require('selenium-webdriver').until;
|
|
|
+
|
|
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
|
|
|
|
describe('Application life cycle test', function () {
|
|
|
this.timeout(0);
|
|
|
+ var server, browser = new require('selenium-webdriver/firefox').Driver();
|
|
|
|
|
|
before(function () {
|
|
|
var seleniumJar= require('selenium-server-standalone-jar');
|
|
|
var SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;
|
|
|
- var server = new SeleniumServer(seleniumJar.path, { port: 4444 });
|
|
|
+ server = new SeleniumServer(seleniumJar.path, { port: 4444 });
|
|
|
server.start();
|
|
|
});
|
|
|
|
|
|
+ after(function () {
|
|
|
+ browser.quit();
|
|
|
+ server.stop();
|
|
|
+ });
|
|
|
+
|
|
|
var LOCATION = 'test' + Date.now();
|
|
|
- var app;
|
|
|
+ var app, reponame = 'testrepo';
|
|
|
var username = process.env.USERNAME;
|
|
|
var password = process.env.PASSWORD;
|
|
|
|
|
@@ -54,6 +65,56 @@ describe('Application life cycle test', function () {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+ it('can login', function (done) {
|
|
|
+ browser.get('https://' + app.fqdn + '/user/login');
|
|
|
+ browser.findElement(by.id('user_name')).sendKeys(username);
|
|
|
+ browser.findElement(by.id('password')).sendKeys(password);
|
|
|
+ browser.findElement(by.tagName('form')).submit();
|
|
|
+ browser.wait(until.elementLocated(by.linkText('Dashboard')), 4000);
|
|
|
+ done();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('can add public key', function (done) {
|
|
|
+ browser.get('https://' + app.fqdn + '/user/settings/ssh');
|
|
|
+ var publicKey = fs.readFileSync(__dirname + '/id_rsa.pub', 'utf8');
|
|
|
+
|
|
|
+ browser.findElement(by.xpath('//div[text()="Add Key"]')).click();
|
|
|
+ browser.findElement(by.id('title')).sendKeys('testkey');
|
|
|
+ browser.findElement(by.id('content')).sendKeys(publicKey);
|
|
|
+ browser.findElement(by.xpath('//button[contains(text(), "Add Key")]')).click();
|
|
|
+ browser.wait(until.elementLocated(by.xpath('p[contains(text(), "added successfully!")]')), 4000);
|
|
|
+ done();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('can create repo', function (done) {
|
|
|
+ browser.get('https://' + app.fqdn);
|
|
|
+ browser.findElement(by.linkText('New Repository')).click();
|
|
|
+ browser.wait(until.elementLocated(by.xpath('//*[contains(text(), "New Repository")]')), 4000);
|
|
|
+ browser.findElement(by.id('repo_name')).sendKeys(reponame);
|
|
|
+ browser.findElement(by.id('auto-init')).click();
|
|
|
+ browser.findElement(by.xpath('//button[contains(text(), "Create Repository")]')).click();
|
|
|
+ browser.wait(function () {
|
|
|
+ return browser.getCurrentUrl().then(function (url) {
|
|
|
+ return url === 'https://' + app.fqdn + '/' + username + '/' + reponame;
|
|
|
+ });
|
|
|
+ }, 4000);
|
|
|
+ done();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('displays correct clone url', function (done) {
|
|
|
+ browser.get('https://' + app.fqdn + '/' + username + '/' + reponame);
|
|
|
+ browser.findElement(by.id('repo-clone-url')).getAttribute('value').then(function (cloneUrl) {
|
|
|
+ expect(cloneUrl).to.be('ssh://cloudron@' + app.fqdn + ':29418/' + username + '/' + reponame + '.git');
|
|
|
+ done();
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ it('can clone the url', function (done) {
|
|
|
+ execSync('git clone ssh://cloudron@' + app.fqdn + ':29418/' + username + '/' + reponame + '.git /tmp/testrepo', { env: { GIT_SSH : __dirname + '/git_ssh_wrapper.sh' } });
|
|
|
+ rimraf.sync('/tmp/testrepo');
|
|
|
+ done();
|
|
|
+ });
|
|
|
+
|
|
|
it('backup app', function () {
|
|
|
execSync('cloudron backup --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
});
|
|
@@ -62,8 +123,13 @@ describe('Application life cycle test', function () {
|
|
|
execSync('cloudron restore --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
});
|
|
|
|
|
|
+ it('can clone the url', function (done) {
|
|
|
+ execSync('git clone ssh://cloudron@' + app.fqdn + ':29418/' + username + '/' + reponame + '.git /tmp/testrepo', { env: { GIT_SSH : __dirname + '/git_ssh_wrapper.sh' } });
|
|
|
+ rimraf.sync('/tmp/testrepo');
|
|
|
+ done();
|
|
|
+ });
|
|
|
+
|
|
|
it('uninstall app', function () {
|
|
|
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
|
|
});
|
|
|
});
|
|
|
-
|