DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Protected Member Functions | List of all members
Deveel.Data.Security.UserManagementTests Class Reference
Inheritance diagram for Deveel.Data.Security.UserManagementTests:
Deveel.Data.ContextBasedTest

Public Member Functions

void CreateUser ()
 
void Authenticate_Success ()
 
void Authenticate_Fail ()
 
void CreateExistingUser ()
 
void DropUser ()
 
void AdminChangesUserPassword ()
 
void SetUserGroups ()
 
void LockUser ()
 
- Public Member Functions inherited from Deveel.Data.ContextBasedTest
void TestSetUp ()
 
void TestFixtureSetUp ()
 
void TestTearDown ()
 
void TestFixtureTearDown ()
 

Protected Member Functions

override ISession CreateAdminSession (IDatabase database)
 
- Protected Member Functions inherited from Deveel.Data.ContextBasedTest
virtual void RegisterServices (ServiceContainer container)
 
virtual ISystem CreateSystem ()
 
virtual IDatabase CreateDatabase (ISystem system, IConfiguration configuration)
 
virtual IQuery CreateQuery (ISession session)
 
ISession CreateUserSession (string userName, string password)
 
virtual void OnSetUp (string testName)
 
virtual void OnTearDown ()
 

Additional Inherited Members

- Protected Attributes inherited from Deveel.Data.ContextBasedTest
const string AdminUserName = "SA"
 
const string AdminPassword = "1234567890"
 
const string DatabaseName = "testdb"
 
- Properties inherited from Deveel.Data.ContextBasedTest
virtual bool SingleContext [get]
 
IQuery Query [get, private set]
 
ISystem System [get, private set]
 
IDatabase Database [get, private set]
 
ISession Session [get, private set]
 

Detailed Description

Definition at line 21 of file UserManagementTests.cs.

Member Function Documentation

void Deveel.Data.Security.UserManagementTests.AdminChangesUserPassword ( )
inline

Definition at line 84 of file UserManagementTests.cs.

84  {
85  Assert.DoesNotThrow(() => Query.AlterUserPassword("tester", "0123456789"));
86  }
void Deveel.Data.Security.UserManagementTests.Authenticate_Fail ( )
inline

Definition at line 58 of file UserManagementTests.cs.

58  {
59  User user = null;
60 
61  Assert.Throws<SecurityException>(() => user = Database.Authenticate("test2", "12545587"));
62  Assert.IsNull(user);
63  }
void Deveel.Data.Security.UserManagementTests.Authenticate_Success ( )
inline

Definition at line 49 of file UserManagementTests.cs.

49  {
50  User user = null;
51 
52  Assert.DoesNotThrow(() => user = Database.Authenticate("tester", "123456789"));
53  Assert.IsNotNull(user);
54  Assert.AreEqual("tester", user.Name);
55  }
override ISession Deveel.Data.Security.UserManagementTests.CreateAdminSession ( IDatabase  database)
inlineprotectedvirtual

Reimplemented from Deveel.Data.ContextBasedTest.

Definition at line 22 of file UserManagementTests.cs.

22  {
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");
28  query.Commit();
29  }
30  }
31  }
32  return base.CreateAdminSession(database);
33  }
void Deveel.Data.Security.UserManagementTests.CreateExistingUser ( )
inline

Definition at line 66 of file UserManagementTests.cs.

66  {
67  bool exists = false;
68  Assert.DoesNotThrow(() => exists = Query.UserExists("tester"));
69  Assert.IsTrue(exists);
70 
71  Assert.Throws<SecurityException>(() => Query.CreateUser("tester", "123456789"));
72  }
void Deveel.Data.Security.UserManagementTests.CreateUser ( )
inline

Definition at line 36 of file UserManagementTests.cs.

36  {
37  User user = null;
38  Assert.DoesNotThrow(() => user = Query.CreateUser("tester", "123456"));
39  Assert.IsNotNull(user);
40 
41  Assert.AreEqual("tester", user.Name);
42 
43  bool exists = false;
44  Assert.DoesNotThrow(() => exists = Query.UserExists("tester"));
45  Assert.IsTrue(exists);
46  }
void Deveel.Data.Security.UserManagementTests.DropUser ( )
inline

Definition at line 75 of file UserManagementTests.cs.

75  {
76  Assert.DoesNotThrow(() => Query.DeleteUser("tester"));
77 
78  bool exists = false;
79  Assert.DoesNotThrow(() => Query.UserExists("tester"));
80  Assert.IsFalse(exists);
81  }
void Deveel.Data.Security.UserManagementTests.LockUser ( )
inline

Definition at line 107 of file UserManagementTests.cs.

107  {
108  Query.SetUserStatus("tester", UserStatus.Locked);
109 
110  UserStatus status = new UserStatus();
111  Assert.DoesNotThrow(() => status = Query.GetUserStatus("tester"));
112  Assert.AreEqual(UserStatus.Locked, status);
113  }
void Deveel.Data.Security.UserManagementTests.SetUserGroups ( )
inline

Definition at line 89 of file UserManagementTests.cs.

89  {
90  Assert.DoesNotThrow(() => Query.AddUserToGroup("tester", "test_group"));
91  Assert.DoesNotThrow(() => Query.AddUserToGroup("tester", SystemGroups.UserManagerGroup));
92 
93  User user = null;
94  Assert.DoesNotThrow(() => user = Query.GetUser("tester"));
95  Assert.IsNotNull(user);
96 
97  string[] userGroups = null;
98  Assert.DoesNotThrow(() => userGroups = Query.GetGroupsUserBelongsTo(user.Name));
99  Assert.IsNotNull(userGroups);
100  Assert.Contains("test_group", userGroups);
101  Assert.Contains(SystemGroups.UserManagerGroup, userGroups);
102 
103  Assert.IsTrue(Query.UserBelongsToGroup("tester", "test_group"));
104  }

The documentation for this class was generated from the following file: