Merge pull request #1421 from realm/revert-pr-1409
Revert "Merge pull request #1409 from realm/kneth/bugfix/invalid-token"
This commit is contained in:
commit
70ee478d36
|
@ -209,7 +209,6 @@ class User {
|
||||||
* @param {string} adminToken - existing admin token
|
* @param {string} adminToken - existing admin token
|
||||||
* @param {string} server - authentication server
|
* @param {string} server - authentication server
|
||||||
* @return {User} - admin user populated with the given token and server
|
* @return {User} - admin user populated with the given token and server
|
||||||
* @throws {Error} If adminToken or server is invalid.
|
|
||||||
*/
|
*/
|
||||||
static adminUser(adminToken, server) {}
|
static adminUser(adminToken, server) {}
|
||||||
|
|
||||||
|
|
|
@ -187,19 +187,7 @@ const staticMethods = {
|
||||||
|
|
||||||
adminUser(token, server) {
|
adminUser(token, server) {
|
||||||
checkTypes(arguments, ['string', 'string']);
|
checkTypes(arguments, ['string', 'string']);
|
||||||
const user = this._adminUser(server, token);
|
return this._adminUser(server, token);
|
||||||
// FIXME: find a better way to detect that token or server is invalid
|
|
||||||
// check if object is empty
|
|
||||||
var isEmpty = true;
|
|
||||||
for(var prop in user) {
|
|
||||||
if (user.hasOwnProperty(prop)) {
|
|
||||||
isEmpty = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isEmpty) {
|
|
||||||
throw new Error('Invalid adminToken or server.');
|
|
||||||
}
|
|
||||||
return user;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
register(server, username, password, callback) {
|
register(server, username, password, callback) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ if (global.enableSyncTests) {
|
||||||
// FIXME: Permission tests currently fail in chrome debugging mode.
|
// FIXME: Permission tests currently fail in chrome debugging mode.
|
||||||
if (typeof navigator === 'undefined' ||
|
if (typeof navigator === 'undefined' ||
|
||||||
!/Chrome/.test(navigator.userAgent)) { // eslint-disable-line no-undef
|
!/Chrome/.test(navigator.userAgent)) { // eslint-disable-line no-undef
|
||||||
TESTS.PermissionTests = require('./permission-tests');
|
TESTS.PermissionTests = require('./permission-tests');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -371,38 +371,6 @@ module.exports = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
testAdminUser() {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
if (!isNodeProcess) {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: check if adminUser() returns user iff valid token/server
|
|
||||||
let didThrow = false;
|
|
||||||
try {
|
|
||||||
let user = Realm.Sync.User.adminUser('THIS_IS_INVALID', 'http://localhost:9080');
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
didThrow = true;
|
|
||||||
TestCase.assertTrue(e.message === 'Invalid adminToken or server.');
|
|
||||||
}
|
|
||||||
TestCase.assertTrue(didThrow);
|
|
||||||
|
|
||||||
// FIXME: find a way to set up a proper admin token
|
|
||||||
didThrow = false;
|
|
||||||
try {
|
|
||||||
Realm.Sync.User.adminUser('THIS_IS_VALID', 'http://foo.bar:9080');
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
didThrow = true;
|
|
||||||
TestCase.assertTrue(e.message === 'Invalid adminToken or server.');
|
|
||||||
}
|
|
||||||
TestCase.assertTrue(didThrow);
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* This test fails because of realm-object-store #243 . We should use 2 users.
|
/* This test fails because of realm-object-store #243 . We should use 2 users.
|
||||||
testSynchronizeChangesWithTwoClientsAndOneUser() {
|
testSynchronizeChangesWithTwoClientsAndOneUser() {
|
||||||
// Test Schema
|
// Test Schema
|
||||||
|
@ -464,3 +432,4 @@ module.exports = {
|
||||||
}, */
|
}, */
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue