[Test] public void CheckLogin() { var identity_IsAuthenticated = TmRest.RBAC_CurrentIdentity_IsAuthenticated(); var identity_Name = TmRest.RBAC_CurrentIdentity_Name(); var identity_Roles = TmRest.RBAC_CurrentPrincipal_Roles(); var identity_IsAdmin = TmRest.RBAC_IsAdmin(); Assert.IsTrue(identity_IsAuthenticated); Assert.IsNull(identity_Name); Assert.AreEqual(identity_Roles.size(), 2); Assert.IsFalse(identity_IsAdmin); var username = tmConfig.TMSecurity.Default_AdminUserName; var pwd = tmConfig.TMSecurity.Default_AdminPassword; var sessionId = TmRest.Login(username, pwd); Assert.AreNotEqual(Guid.Empty, sessionId); identity_IsAuthenticated = TmRest.RBAC_CurrentIdentity_IsAuthenticated(); identity_Name = TmRest.RBAC_CurrentIdentity_Name(); Assert.IsTrue(identity_IsAuthenticated); Assert.AreEqual(username, identity_Name); //without the CSRF-token these should fail Assert.IsFalse(TmRest.RBAC_IsAdmin()); Assert.AreEqual(TmRest.RBAC_CurrentPrincipal_Roles().size(), 2); sessionId.set_Guid_as_CsrfToken_on_Request(); //Now the mappings should work Assert.IsTrue(TmRest.RBAC_IsAdmin()); Assert.AreEqual(TmRest.RBAC_CurrentPrincipal_Roles().size(), 6); }
[Test] public void CheckLogin() { var identity_IsAuthenticated = TmRest.RBAC_CurrentIdentity_IsAuthenticated(); var identity_Name = TmRest.RBAC_CurrentIdentity_Name(); var identity_Roles = TmRest.RBAC_CurrentPrincipal_Roles(); var identity_IsAdmin = TmRest.RBAC_IsAdmin(); Assert.IsTrue(identity_IsAuthenticated); Assert.IsNull(identity_Name); Assert.AreEqual(identity_Roles.size(), 1); Assert.IsFalse(identity_IsAdmin); var username = tmConfig.TMSecurity.Default_AdminUserName; var pwd = tmConfig.TMSecurity.Default_AdminPassword; var sessionId = TmRest.Login(username, pwd); Assert.AreNotEqual(Guid.Empty, sessionId); identity_IsAuthenticated = TmRest.RBAC_CurrentIdentity_IsAuthenticated(); identity_Name = TmRest.RBAC_CurrentIdentity_Name(); identity_Roles = TmRest.RBAC_CurrentPrincipal_Roles(); identity_IsAdmin = TmRest.RBAC_IsAdmin(); Assert.IsTrue(identity_IsAuthenticated); Assert.AreEqual(username, identity_Name); Assert.AreEqual(identity_Roles.size(), 5); Assert.IsTrue(identity_IsAdmin); }