17 using NUnit.Framework;
19 namespace Deveel.Data.Security {
23 var testName = TestContext.CurrentContext.Test.Name;
24 if (testName !=
"CreateUser") {
25 using (var session = base.CreateAdminSession(database)) {
26 using (var query = session.CreateQuery()) {
27 query.CreateUser(
"tester",
"123456789");
32 return base.CreateAdminSession(database);
39 Assert.IsNotNull(user);
41 Assert.AreEqual(
"tester", user.
Name);
45 Assert.IsTrue(exists);
52 Assert.DoesNotThrow(() => user =
Database.Authenticate(
"tester",
"123456789"));
53 Assert.IsNotNull(user);
54 Assert.AreEqual(
"tester", user.
Name);
69 Assert.IsTrue(exists);
80 Assert.IsFalse(exists);
94 Assert.DoesNotThrow(() => user =
Query.
GetUser(
"tester"));
95 Assert.IsNotNull(user);
97 string[] userGroups = null;
99 Assert.IsNotNull(userGroups);
100 Assert.Contains(
"test_group", userGroups);
static User CreateUser(this IQuery query, string userName, string password)
void CreateExistingUser()
static void AddUserToGroup(this IQuery queryContext, string username, string group, bool asAdmin=false)
static void AlterUserPassword(this IQuery queryContext, string username, string password)
void Commit()
Commits the latest changes made by the user in the session.
static string[] GetGroupsUserBelongsTo(this IQuery queryContext, string username)
The default implementation of a database in a system.
The representation of a single database in the system.
An isolated session to a given database for a given user, encapsulating the transaction for operation...
const string UserManagerGroup
The name of the user manager group.
static User GetUser(this IQuery query, string userName)
static bool UserExists(this IQuery query, string userName)
void AdminChangesUserPassword()
static bool UserBelongsToGroup(this IQuery queryContext, string group)
static bool DeleteUser(this IQuery query, string userName)
Provides the information for a user in a database system
static void SetUserStatus(this IQuery queryContext, string username, UserStatus status)
override ISession CreateAdminSession(IDatabase database)
static UserStatus GetUserStatus(this IQuery queryContext, string userName)
void Authenticate_Success()
string Name
Gets the name that uniquely identify a user within a database system.