mirror of https://gitee.com/bigwinds/arangodb
Fix dump authentication test
This commit is contained in:
parent
cbc9b3a749
commit
9d03f85e9b
|
@ -307,6 +307,18 @@ exports.document = function(username) {
|
||||||
return convertToLegacyFormat(user);
|
return convertToLegacyFormat(user);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.exists = function(username) {
|
||||||
|
try {
|
||||||
|
exports.document(username);
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
if (e.errNum == arangodb.errors.ERROR_USER_NOT_FOUND.code) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// checks whether a combination of username / password is valid.
|
// checks whether a combination of username / password is valid.
|
||||||
exports.isValid = function(username, password) {
|
exports.isValid = function(username, password) {
|
||||||
const users = getStorage();
|
const users = getStorage();
|
||||||
|
|
|
@ -42,11 +42,10 @@
|
||||||
|
|
||||||
// create user in _system database
|
// create user in _system database
|
||||||
require("@arangodb/users").save("foobaruser", "foobarpasswd", true);
|
require("@arangodb/users").save("foobaruser", "foobarpasswd", true);
|
||||||
|
require("@arangodb/users").grantDatabase("foobaruser", "_system");
|
||||||
|
require("@arangodb/users").grantDatabase("foobaruser", "UnitTestsDumpSrc");
|
||||||
db._useDatabase("UnitTestsDumpSrc");
|
db._useDatabase("UnitTestsDumpSrc");
|
||||||
|
|
||||||
// create user in target database
|
|
||||||
require("@arangodb/users").save("foobaruser", "foobarpasswd", true);
|
|
||||||
|
|
||||||
var endpoint = arango.getEndpoint();
|
var endpoint = arango.getEndpoint();
|
||||||
|
|
||||||
arango.reconnect(endpoint, "UnitTestsDumpSrc", "foobaruser", "foobarpasswd");
|
arango.reconnect(endpoint, "UnitTestsDumpSrc", "foobaruser", "foobarpasswd");
|
||||||
|
|
|
@ -530,7 +530,9 @@
|
||||||
if (args && args.users) {
|
if (args && args.users) {
|
||||||
args.users.forEach(function(user) {
|
args.users.forEach(function(user) {
|
||||||
try {
|
try {
|
||||||
|
if (!userManager.exists(user.username)) {
|
||||||
userManager.save(user.username, user.passwd, user.active, user.extra || {});
|
userManager.save(user.username, user.passwd, user.active, user.extra || {});
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.warn("could not add database user '" + user.username + "': " +
|
logger.warn("could not add database user '" + user.username + "': " +
|
||||||
String(err) + " " +
|
String(err) + " " +
|
||||||
|
|
Loading…
Reference in New Issue