summaryrefslogtreecommitdiffstats
path: root/webapp/tests
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2016-05-24 14:31:30 -0700
committerCorey Hulen <corey@hulen.com>2016-05-24 14:31:30 -0700
commit09863c0b80610f2f3a35cf3caa7c5b66a0c3878e (patch)
treedcce1b5c0fa62a9da2b25a99862af5ba30306901 /webapp/tests
parent4ae7128ecb66cdddeb9d40a24970c6552814c18b (diff)
downloadchat-09863c0b80610f2f3a35cf3caa7c5b66a0c3878e.tar.gz
chat-09863c0b80610f2f3a35cf3caa7c5b66a0c3878e.tar.bz2
chat-09863c0b80610f2f3a35cf3caa7c5b66a0c3878e.zip
Adding APIs to reload config, recycle db connections and ping server (#3096)
* Adding APIs to reload config, recycle db connections and ping server * Fixing unit test * Adding unit tests
Diffstat (limited to 'webapp/tests')
-rw-r--r--webapp/tests/client_admin.test.jsx295
-rw-r--r--webapp/tests/client_general.test.jsx255
-rw-r--r--webapp/tests/client_team.test.jsx1
3 files changed, 302 insertions, 249 deletions
diff --git a/webapp/tests/client_admin.test.jsx b/webapp/tests/client_admin.test.jsx
new file mode 100644
index 000000000..719903bcf
--- /dev/null
+++ b/webapp/tests/client_admin.test.jsx
@@ -0,0 +1,295 @@
+// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+var assert = require('assert');
+import TestHelper from './test_helper.jsx';
+
+describe('Client.Admin', function() {
+ this.timeout(10000);
+
+ it('Admin.reloadConfig', function(done) {
+ TestHelper.initBasic(() => {
+ TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
+ TestHelper.basicClient().reloadConfig(
+ function() {
+ done(new Error('should need system admin permissions'));
+ },
+ function(err) {
+ assert.equal(err.id, 'api.context.system_permissions.app_error');
+ done();
+ }
+ );
+ });
+ });
+
+ it('Admin.recycleDatabaseConnection', function(done) {
+ TestHelper.initBasic(() => {
+ TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
+ TestHelper.basicClient().recycleDatabaseConnection(
+ function() {
+ done(new Error('should need system admin permissions'));
+ },
+ function(err) {
+ assert.equal(err.id, 'api.context.system_permissions.app_error');
+ done();
+ }
+ );
+ });
+ });
+
+ it('Admin.getComplianceReports', function(done) {
+ TestHelper.initBasic(() => {
+ TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
+ TestHelper.basicClient().getComplianceReports(
+ function() {
+ done(new Error('should need system admin permissions'));
+ },
+ function(err) {
+ assert.equal(err.id, 'api.context.system_permissions.app_error');
+ done();
+ }
+ );
+ });
+ });
+
+ it('Admin.saveComplianceReports', function(done) {
+ TestHelper.initBasic(() => {
+ TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
+
+ var job = {};
+ job.desc = 'desc';
+ job.emails = '';
+ job.keywords = 'test';
+ job.start_at = new Date();
+ job.end_at = new Date();
+
+ TestHelper.basicClient().saveComplianceReports(
+ job,
+ function() {
+ done(new Error('should need system admin permissions'));
+ },
+ function(err) {
+ assert.equal(err.id, 'api.context.system_permissions.app_error');
+ done();
+ }
+ );
+ });
+ });
+
+ it('Admin.getLogs', function(done) {
+ TestHelper.initBasic(() => {
+ TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
+ TestHelper.basicClient().getLogs(
+ function() {
+ done(new Error('should need system admin permissions'));
+ },
+ function(err) {
+ assert.equal(err.id, 'api.context.system_permissions.app_error');
+ done();
+ }
+ );
+ });
+ });
+
+ it('Admin.getServerAudits', function(done) {
+ TestHelper.initBasic(() => {
+ TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
+ TestHelper.basicClient().getServerAudits(
+ function() {
+ done(new Error('should need system admin permissions'));
+ },
+ function(err) {
+ assert.equal(err.id, 'api.context.system_permissions.app_error');
+ done();
+ }
+ );
+ });
+ });
+
+ it('Admin.getConfig', function(done) {
+ TestHelper.initBasic(() => {
+ TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
+ TestHelper.basicClient().getConfig(
+ function() {
+ done(new Error('should need system admin permissions'));
+ },
+ function(err) {
+ assert.equal(err.id, 'api.context.system_permissions.app_error');
+ done();
+ }
+ );
+ });
+ });
+
+ it('Admin.getAnalytics', function(done) {
+ TestHelper.initBasic(() => {
+ TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
+ TestHelper.basicClient().getAnalytics(
+ 'standard',
+ null,
+ function() {
+ done(new Error('should need system admin permissions'));
+ },
+ function(err) {
+ assert.equal(err.id, 'api.context.system_permissions.app_error');
+ done();
+ }
+ );
+ });
+ });
+
+ it('Admin.getTeamAnalytics', function(done) {
+ TestHelper.initBasic(() => {
+ TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
+ TestHelper.basicClient().getTeamAnalytics(
+ TestHelper.basicTeam().id,
+ 'standard',
+ function() {
+ done(new Error('should need system admin permissions'));
+ },
+ function(err) {
+ assert.equal(err.id, 'api.context.system_permissions.app_error');
+ done();
+ }
+ );
+ });
+ });
+
+ it('Admin.saveConfig', function(done) {
+ TestHelper.initBasic(() => {
+ TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
+ var config = {};
+ config.site_name = 'test';
+
+ TestHelper.basicClient().saveConfig(
+ config,
+ function() {
+ done(new Error('should need system admin permissions'));
+ },
+ function(err) {
+ assert.equal(err.id, 'api.context.system_permissions.app_error');
+ done();
+ }
+ );
+ });
+ });
+
+ it('Admin.testEmail', function(done) {
+ TestHelper.initBasic(() => {
+ TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
+ var config = {};
+ config.site_name = 'test';
+
+ TestHelper.basicClient().testEmail(
+ config,
+ function() {
+ done(new Error('should need system admin permissions'));
+ },
+ function(err) {
+ assert.equal(err.id, 'api.context.system_permissions.app_error');
+ done();
+ }
+ );
+ });
+ });
+
+ it('Admin.adminResetMfa', function(done) {
+ TestHelper.initBasic(() => {
+ TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
+
+ TestHelper.basicClient().adminResetMfa(
+ TestHelper.basicUser().id,
+ function() {
+ done(new Error('should need a license'));
+ },
+ function(err) {
+ assert.equal(err.id, 'api.context.permissions.app_error');
+ done();
+ }
+ );
+ });
+ });
+
+ it('Admin.adminResetPassword', function(done) {
+ TestHelper.initBasic(() => {
+ TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
+ var user = TestHelper.basicUser();
+
+ TestHelper.basicClient().resetPassword(
+ user.id,
+ 'new_password',
+ function() {
+ throw Error('shouldnt work');
+ },
+ function(err) {
+ // this should fail since you're not a system admin
+ assert.equal(err.id, 'api.context.invalid_param.app_error');
+ done();
+ }
+ );
+ });
+ });
+
+ it('License.getClientLicenceConfig', function(done) {
+ TestHelper.initBasic(() => {
+ TestHelper.basicClient().getClientLicenceConfig(
+ function(data) {
+ assert.equal(data.IsLicensed, 'false');
+ done();
+ },
+ function(err) {
+ done(new Error(err.message));
+ }
+ );
+ });
+ });
+
+ it('License.removeLicenseFile', function(done) {
+ TestHelper.initBasic(() => {
+ TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
+ TestHelper.basicClient().removeLicenseFile(
+ function() {
+ done(new Error('not enabled'));
+ },
+ function(err) {
+ assert.equal(err.id, 'api.context.permissions.app_error');
+ done();
+ }
+ );
+ });
+ });
+
+ /*it('License.uploadLicenseFile', function(done) {
+ TestHelper.initBasic(() => {
+ TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
+ TestHelper.basicClient().uploadLicenseFile(
+ 'form data',
+ function() {
+ done(new Error('not enabled'));
+ },
+ function(err) {
+ assert.equal(err.id, 'api.context.permissions.app_error');
+ done();
+ }
+ );
+ });
+ });*/
+
+ // TODO XXX FIX ME - this test depends on make dist
+
+ // it('General.getTranslations', function(done) {
+ // TestHelper.initBasic(() => {
+ // TestHelper.basicClient().getTranslations(
+ // 'http://localhost:8065/static/i18n/es.json',
+ // function(data) {
+ // assert.equal(data['login.or'], 'o');
+ // done();
+ // },
+ // function(err) {
+ // done(new Error(err.message));
+ // }
+ // );
+ // });
+ // });
+});
+
diff --git a/webapp/tests/client_general.test.jsx b/webapp/tests/client_general.test.jsx
index d18927445..61e7832da 100644
--- a/webapp/tests/client_general.test.jsx
+++ b/webapp/tests/client_general.test.jsx
@@ -7,7 +7,7 @@ import TestHelper from './test_helper.jsx';
describe('Client.General', function() {
this.timeout(10000);
- it('Admin.getClientConfig', function(done) {
+ it('General.getClientConfig', function(done) {
TestHelper.initBasic(() => {
TestHelper.basicClient().getClientConfig(
function(data) {
@@ -21,163 +21,21 @@ describe('Client.General', function() {
});
});
- it('Admin.getComplianceReports', function(done) {
+ it('General.getPing', function(done) {
TestHelper.initBasic(() => {
- TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
- TestHelper.basicClient().getComplianceReports(
- function() {
- done(new Error('should need system admin permissions'));
- },
- function(err) {
- assert.equal(err.id, 'api.context.system_permissions.app_error');
- done();
- }
- );
- });
- });
-
- it('Admin.saveComplianceReports', function(done) {
- TestHelper.initBasic(() => {
- TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
-
- var job = {};
- job.desc = 'desc';
- job.emails = '';
- job.keywords = 'test';
- job.start_at = new Date();
- job.end_at = new Date();
-
- TestHelper.basicClient().saveComplianceReports(
- job,
- function() {
- done(new Error('should need system admin permissions'));
- },
- function(err) {
- assert.equal(err.id, 'api.context.system_permissions.app_error');
- done();
- }
- );
- });
- });
-
- it('Admin.getLogs', function(done) {
- TestHelper.initBasic(() => {
- TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
- TestHelper.basicClient().getLogs(
- function() {
- done(new Error('should need system admin permissions'));
- },
- function(err) {
- assert.equal(err.id, 'api.context.system_permissions.app_error');
- done();
- }
- );
- });
- });
-
- it('Admin.getServerAudits', function(done) {
- TestHelper.initBasic(() => {
- TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
- TestHelper.basicClient().getServerAudits(
- function() {
- done(new Error('should need system admin permissions'));
- },
- function(err) {
- assert.equal(err.id, 'api.context.system_permissions.app_error');
- done();
- }
- );
- });
- });
-
- it('Admin.getConfig', function(done) {
- TestHelper.initBasic(() => {
- TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
- TestHelper.basicClient().getConfig(
- function() {
- done(new Error('should need system admin permissions'));
- },
- function(err) {
- assert.equal(err.id, 'api.context.system_permissions.app_error');
- done();
- }
- );
- });
- });
-
- it('Admin.getAnalytics', function(done) {
- TestHelper.initBasic(() => {
- TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
- TestHelper.basicClient().getAnalytics(
- 'standard',
- null,
- function() {
- done(new Error('should need system admin permissions'));
- },
- function(err) {
- assert.equal(err.id, 'api.context.system_permissions.app_error');
- done();
- }
- );
- });
- });
-
- it('Admin.getTeamAnalytics', function(done) {
- TestHelper.initBasic(() => {
- TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
- TestHelper.basicClient().getTeamAnalytics(
- TestHelper.basicTeam().id,
- 'standard',
- function() {
- done(new Error('should need system admin permissions'));
- },
- function(err) {
- assert.equal(err.id, 'api.context.system_permissions.app_error');
- done();
- }
- );
- });
- });
-
- it('Admin.saveConfig', function(done) {
- TestHelper.initBasic(() => {
- TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
- var config = {};
- config.site_name = 'test';
-
- TestHelper.basicClient().saveConfig(
- config,
- function() {
- done(new Error('should need system admin permissions'));
- },
- function(err) {
- assert.equal(err.id, 'api.context.system_permissions.app_error');
+ TestHelper.basicClient().getPing(
+ function(data) {
+ assert.equal(data.version.length > 0, true);
done();
- }
- );
- });
- });
-
- it('Admin.testEmail', function(done) {
- TestHelper.initBasic(() => {
- TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
- var config = {};
- config.site_name = 'test';
-
- TestHelper.basicClient().testEmail(
- config,
- function() {
- done(new Error('should need system admin permissions'));
},
function(err) {
- assert.equal(err.id, 'api.context.system_permissions.app_error');
- done();
+ done(new Error(err.message));
}
);
});
});
- it('Admin.logClientError', function(done) {
+ it('General.logClientError', function(done) {
TestHelper.initBasic(() => {
var config = {};
config.site_name = 'test';
@@ -186,105 +44,6 @@ describe('Client.General', function() {
});
});
- it('Admin.adminResetMfa', function(done) {
- TestHelper.initBasic(() => {
- TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
-
- TestHelper.basicClient().adminResetMfa(
- TestHelper.basicUser().id,
- function() {
- done(new Error('should need a license'));
- },
- function(err) {
- assert.equal(err.id, 'api.context.permissions.app_error');
- done();
- }
- );
- });
- });
-
- it('Admin.adminResetPassword', function(done) {
- TestHelper.initBasic(() => {
- TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
- var user = TestHelper.basicUser();
-
- TestHelper.basicClient().resetPassword(
- user.id,
- 'new_password',
- function() {
- throw Error('shouldnt work');
- },
- function(err) {
- // this should fail since you're not a system admin
- assert.equal(err.id, 'api.context.invalid_param.app_error');
- done();
- }
- );
- });
- });
-
- it('License.getClientLicenceConfig', function(done) {
- TestHelper.initBasic(() => {
- TestHelper.basicClient().getClientLicenceConfig(
- function(data) {
- assert.equal(data.IsLicensed, 'false');
- done();
- },
- function(err) {
- done(new Error(err.message));
- }
- );
- });
- });
-
- it('License.removeLicenseFile', function(done) {
- TestHelper.initBasic(() => {
- TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
- TestHelper.basicClient().removeLicenseFile(
- function() {
- done(new Error('not enabled'));
- },
- function(err) {
- assert.equal(err.id, 'api.context.permissions.app_error');
- done();
- }
- );
- });
- });
-
- /*it('License.uploadLicenseFile', function(done) {
- TestHelper.initBasic(() => {
- TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
- TestHelper.basicClient().uploadLicenseFile(
- 'form data',
- function() {
- done(new Error('not enabled'));
- },
- function(err) {
- assert.equal(err.id, 'api.context.permissions.app_error');
- done();
- }
- );
- });
- });*/
-
- // TODO XXX FIX ME - this test depends on make dist
-
- // it('General.getTranslations', function(done) {
- // TestHelper.initBasic(() => {
- // TestHelper.basicClient().getTranslations(
- // 'http://localhost:8065/static/i18n/es.json',
- // function(data) {
- // assert.equal(data['login.or'], 'o');
- // done();
- // },
- // function(err) {
- // done(new Error(err.message));
- // }
- // );
- // });
- // });
-
it('File.getFileInfo', function(done) {
TestHelper.initBasic(() => {
TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error
diff --git a/webapp/tests/client_team.test.jsx b/webapp/tests/client_team.test.jsx
index 3179e9f69..0935e1477 100644
--- a/webapp/tests/client_team.test.jsx
+++ b/webapp/tests/client_team.test.jsx
@@ -106,7 +106,6 @@ describe('Client.Team', function() {
TestHelper.initBasic(() => {
TestHelper.basicClient().getAllTeamListings(
function(data) {
- console.log(data);
assert.equal(data != null, true);
done();
},