forked from cloudron-apps/gitea-app
Add selenium tests
This commit is contained in:
parent
cc4222fdbc
commit
9bf97c60ee
4 changed files with 102 additions and 3 deletions
5
test/git_ssh_wrapper.sh
Executable file
5
test/git_ssh_wrapper.sh
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
ssh -o IdentitiesOnly=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ${SCRIPT_DIR}/id_rsa "$@"
|
27
test/id_rsa
Normal file
27
test/id_rsa
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIIEowIBAAKCAQEA14L+HdwPXRHC2A+fyRv1FTsRE/OPl0Z0KnEigzIIdA65CzTy
|
||||||
|
l3m3ATNFI1o/Ies7RW6rsr9UHuLLufNVg1NwIBdns8sPE4pSZSjfdPnznifIIs7y
|
||||||
|
wL/vn2D3JEhpA8EOasSy0c+z+6X23evsLB3D81y7ICsBc16Q147WZ6D+QMUP+A4b
|
||||||
|
wlmEcy0hAoPx/jnnPlRDVOK1ZnBvuAaHBkcBh+sA272BhB6Kv13MBu0wctDjKw5w
|
||||||
|
cNmgVWbzBBtK1L8BZVMDKmKWZ2PKP4GkkpnAvkD0+4sdARe148faV8HHigAKKNN7
|
||||||
|
vt+njs6nHuS4ksJL1E9cKGHdBJudJc3p24iI7QIDAQABAoIBABm5ojnQPek/KIIA
|
||||||
|
A3PPKYc6QMSf60EEgPNcA+GjRE0OQNpsnJSmS8kR5KvepvCWksGr/0Tb/9+b9POi
|
||||||
|
b0+40waRpKhakdckSMeYhGwDNihn2UUGbQXDI4hj27xyBE8VaXInPq063OIqInjF
|
||||||
|
I7D0cKKJLDEf0RGDdUi13TQLjK4QX78W/9S8d5ClznAVi4wUBb1urs7fAoVetn/i
|
||||||
|
PnlEj9KZHio4mCg28djTudAoWzjzUikRqKRYY5QNEJ13abVoLqIRSRHC1DzwpxVv
|
||||||
|
Y88l4hmm6IcmWGo0O9lpu5IJFvEmngfpmyaVbeLE0fhLPFWcEHARw37SThTZVQeY
|
||||||
|
Tx1816UCgYEA9j5dyNbFcC4YL9i9DQyut658bYziY2vsAvZNMMf249IJGbZOxlZK
|
||||||
|
ylB00zlbO/2uNh12Y9z6BN2hO2lER3O3SM75tCnvXR0+qG+xmfjLcRVczEkU10+r
|
||||||
|
8UxKBgg7Sf9uvfeONefEYPwiwzFoWgdaFSrR2sCmuoHPwfc9i+PSp+8CgYEA4Azq
|
||||||
|
DToKdv6VBWPlNXT6OW3+HUPeHF087Ve03+3orCckZ+d2DImEOvWdt+pDeGQJJcq+
|
||||||
|
o+SzZk9FjFOIiQehuA44OFrvcbag9YAlm1JQYYrRTdZEJz3iSucXCzJH/P5TrB84
|
||||||
|
BHvzgCklZzZ0IpEFxzMe8oNS6XfJmilh6I98YOMCgYBybOy7xUGeLW1D3p2LENen
|
||||||
|
t0dOyObyeFYF0lpwTpulphZgglz8wWCjvttqw/5nVCy+LNa09RyhYjPoHbSC13zW
|
||||||
|
MofKdqoqRMq3DqAjAn/XHqwuqc8rdnRZ/q9vOigC7NWTJRRKbFbPEps8xRrOqxfr
|
||||||
|
OiimVFul02ito6xP8yAStQKBgQDHbPdPup/h9wzx9U7p3Ct1vt/3cJddK+i1YeIP
|
||||||
|
iBYYVebjzXSYCDd4u3MdZxmTKYey6dnyy/ibUmgXVassPWzHBXEpSFflIaf3nY7b
|
||||||
|
x9LgX82ZuOSFAWJRRYyPXLwTBtW3WTplU2cUZotyaVfKBMfd3TToq9e7E/KQk9Eg
|
||||||
|
Tcdp/QKBgCyKD1gGU/H1bsQOuWHuFR1v7v82V1DLVjyn5kllej0tlfTLO/5uUsEE
|
||||||
|
SIjGHfTHxgpww9HN9BPyy8xdQMAc6p7UyvJAIyhg679AQBrMLLvhE5niaGu4jQOa
|
||||||
|
ZVY6nZUQNCwgxJwnUkFnOyXDYjzjyxZOCAWPxghYbS+IEl1GzhZU
|
||||||
|
-----END RSA PRIVATE KEY-----
|
1
test/id_rsa.pub
Normal file
1
test/id_rsa.pub
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXgv4d3A9dEcLYD5/JG/UVOxET84+XRnQqcSKDMgh0DrkLNPKXebcBM0UjWj8h6ztFbquyv1Qe4su581WDU3AgF2ezyw8TilJlKN90+fOeJ8gizvLAv++fYPckSGkDwQ5qxLLRz7P7pfbd6+wsHcPzXLsgKwFzXpDXjtZnoP5AxQ/4DhvCWYRzLSECg/H+Oec+VENU4rVmcG+4BocGRwGH6wDbvYGEHoq/XcwG7TBy0OMrDnBw2aBVZvMEG0rUvwFlUwMqYpZnY8o/gaSSmcC+QPT7ix0BF7Xjx9pXwceKAAoo03u+36eOzqce5LiSwkvUT1woYd0Em50lzenbiIjt girish@beast
|
72
test/test.js
72
test/test.js
|
@ -12,20 +12,31 @@ var execSync = require('child_process').execSync,
|
||||||
superagent = require('superagent'),
|
superagent = require('superagent'),
|
||||||
webdriver = require('selenium-webdriver');
|
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';
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
||||||
|
|
||||||
describe('Application life cycle test', function () {
|
describe('Application life cycle test', function () {
|
||||||
this.timeout(0);
|
this.timeout(0);
|
||||||
|
var server, browser = new require('selenium-webdriver/firefox').Driver();
|
||||||
|
|
||||||
before(function () {
|
before(function () {
|
||||||
var seleniumJar= require('selenium-server-standalone-jar');
|
var seleniumJar= require('selenium-server-standalone-jar');
|
||||||
var SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;
|
var SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;
|
||||||
var server = new SeleniumServer(seleniumJar.path, { port: 4444 });
|
server = new SeleniumServer(seleniumJar.path, { port: 4444 });
|
||||||
server.start();
|
server.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
after(function () {
|
||||||
|
browser.quit();
|
||||||
|
server.stop();
|
||||||
|
});
|
||||||
|
|
||||||
var LOCATION = 'test' + Date.now();
|
var LOCATION = 'test' + Date.now();
|
||||||
var app;
|
var app, reponame = 'testrepo';
|
||||||
var username = process.env.USERNAME;
|
var username = process.env.USERNAME;
|
||||||
var password = process.env.PASSWORD;
|
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 () {
|
it('backup app', function () {
|
||||||
execSync('cloudron backup --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
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' });
|
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 () {
|
it('uninstall app', function () {
|
||||||
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue