public void AddEntry_UserAlreadyExisting_Throws()//same app,context,obj, user { var c1 = new SecContext { Name = "c1", Description = "context1" }; var group1 = new SecGroup { Name = "my_group" }; var user1 = new SecUser { FirstName = "user1", Login = "******" }; var obj1 = new SecObject { Name = "obj1", Description = "oggetto1", Type = "button" }; CaravanDataSource.Security.AddUser(_myApp.Name, user1); CaravanDataSource.Security.AddGroup(_myApp.Name, group1); CaravanDataSource.Security.AddEntry(_myApp.Name, c1, obj1, user1.Login, null); CaravanDataSource.Security.AddEntry(_myApp.Name, c1, obj1, user1.Login, null); }
public void AddEntry_InsertTwiceTheSameUserDifferentObject_EntriesAdded()//same context and App; different object { var c1 = new SecContext { Name = "c1", Description = "context1" }; var group1 = new SecGroup { Name = "my_group" }; var user1 = new SecUser { FirstName = "user1", Login = "******" }; var user2 = new SecUser { FirstName = "user2", Login = "******" }; var obj1 = new SecObject { Name = "obj1", Description = "oggetto1", Type = "button" }; var obj2 = new SecObject { Name = "obj2", Description = "oggetto2", Type = "button" }; CaravanDataSource.Security.AddUser(_myApp.Name, user1); CaravanDataSource.Security.AddUser(_myApp.Name, user2); CaravanDataSource.Security.AddGroup(_myApp.Name, group1); CaravanDataSource.Security.AddEntry(_myApp.Name, c1, obj1, user1.Login, null); CaravanDataSource.Security.AddEntry(_myApp.Name, c1, obj2, user1.Login, null); var l = CaravanDataSource.Security.GetEntriesForUser(_myApp.Name, c1.Name, user1.Login); Assert.That(l.Count(), Is.EqualTo(2)); }
public void AddEntry_InsertDifferentGroupsOnTheSameObject_EntryAdded() { var c1 = new SecContext { Name = "c1", Description = "context1" }; var group1 = new SecGroup { Name = "my_group" }; var group2 = new SecGroup { Name = "group2" }; var obj1 = new SecObject { Name = "obj1", Description = "oggetto1", Type = "button" }; CaravanDataSource.Security.AddGroup(_myApp.Name, group1); CaravanDataSource.Security.AddGroup(_myApp.Name, group2); CaravanDataSource.Security.AddEntry(_myApp.Name, c1, obj1, null, group1.Name); CaravanDataSource.Security.AddEntry(_myApp.Name, c1, obj1, null, group2.Name); var l1 = CaravanDataSource.Security.GetEntriesForObject(_myApp.Name, c1.Name, obj1.Name); Assert.That(l1.Count(), Is.EqualTo(2)); }
public void AddEntry_InsertTheSameGroupOnDifferentObjects_EntryAdded() { var c1 = new SecContext { Name = "c1", Description = "context1" }; var group1 = new SecGroup { Name = "my_group" }; var obj1 = new SecObject { Name = "obj1", Description = "oggetto1", Type = "button" }; var obj2 = new SecObject { Name = "obj2", Description = "oggetto2", Type = "button" }; CaravanDataSource.Security.AddGroup(_myApp.Name, group1); CaravanDataSource.Security.AddEntry(_myApp.Name, c1, obj1, null, group1.Name); CaravanDataSource.Security.AddEntry(_myApp.Name, c1, obj2, null, group1.Name); var l1 = CaravanDataSource.Security.GetEntries(_myApp.Name, c1.Name); Assert.That(l1.Count(), Is.EqualTo(2)); var l2 = CaravanDataSource.Security.GetEntriesForObject(_myApp.Name, c1.Name, obj1.Name); Assert.That(l2.Count(), Is.EqualTo(1)); Assert.That(l2.First().GroupName, Is.EqualTo("my_group")); var l3 = CaravanDataSource.Security.GetEntriesForObject(_myApp.Name, c1.Name, obj2.Name); Assert.That(l3.Count(), Is.EqualTo(1)); Assert.That(l3.First().GroupName, Is.EqualTo("my_group")); }
public void LogFatal_validArgs_Async(int logCount) { Parallel.ForEach(Enumerable.Range(1, logCount), i => { var c1 = new SecContext { Name = "c1" + i, Description = "context1" + i }; var res = CaravanDataSource.Logger.LogFatal<LogManagerTests>(new Exception(), c1.Name); Assert.True(res.Succeeded); var q = CaravanDataSource.Logger.GetEntries(LogLevel.Fatal).Where(l => l.Function == "logfatal_validargs_async" && l.Context == c1.Name); Assert.That(q.Count(), Is.EqualTo(1)); }); var q1 = CaravanDataSource.Logger.GetEntries(LogLevel.Fatal).Where(l => l.Function == "logfatal_validargs_async"); Assert.That(q1.Count(), Is.EqualTo(logCount)); }
public void AddEntry_Insert2DifferentUsersOnTheSameObject_EntryAdded() { var c1 = new SecContext { Name = "c1", Description = "context1" }; var group1 = new SecGroup { Name = "my_group" }; var user1 = new SecUser { FirstName = "user1", Login = "******" }; var user2 = new SecUser { FirstName = "user2", Login = "******" }; var obj1 = new SecObject { Name = "obj1", Description = "oggetto1", Type = "button" }; CaravanDataSource.Security.AddUser(_myApp.Name, user1); CaravanDataSource.Security.AddUser(_myApp.Name, user2); CaravanDataSource.Security.AddGroup(_myApp.Name, group1); CaravanDataSource.Security.AddEntry(_myApp.Name, c1, obj1, user1.Login, null); CaravanDataSource.Security.AddEntry(_myApp.Name, c1, obj1, user2.Login, null); var l = CaravanDataSource.Security.GetEntriesForObject(_myApp.Name, c1.Name, obj1.Name); Assert.That(l.Count(), Is.EqualTo(2)); var l1 = CaravanDataSource.Security.GetEntriesForObjectAndUser(_myApp.Name, c1.Name, obj1.Name, user1.Login); Assert.That(l1.Count(), Is.EqualTo(1)); var l2 = CaravanDataSource.Security.GetEntriesForObjectAndUser(_myApp.Name, c1.Name, obj1.Name, user2.Login); Assert.That(l2.Count(), Is.EqualTo(1)); }
public void Entries_EmptyAppName_throwsArgumentException() { var c1 = new SecContext { Name = "c1", Description = "context1" }; var group1 = new SecGroup { Name = "my_group" }; var user1 = new SecUser { FirstName = "user1", Login = "******" }; CaravanDataSource.Security.AddUser(_myApp.Name, user1); CaravanDataSource.Security.AddGroup(_myApp.Name, group1); var l = CaravanDataSource.Security.GetEntries("", c1.Name); }
public myHelperData() { myContext = new SecContext(); }
public void Entries_validArgs_ReturnsListOfEntries()//associo un gruppo e un utente allo stesso oggetto { var c1 = new SecContext { Name = "c1", Description = "context1" }; var group1 = new SecGroup { Name = "my_group" }; var user1 = new SecUser { FirstName = "user1", Login = "******" }; var obj1 = new SecObject { Name = "obj1", Description = "oggetto1", Type = "button" }; CaravanDataSource.Security.AddUser(_myApp.Name, user1); CaravanDataSource.Security.AddGroup(_myApp.Name, group1); CaravanDataSource.Security.AddEntry(_myApp.Name, c1, obj1, null, group1.Name); CaravanDataSource.Security.AddEntry(_myApp.Name, c1, obj1, user1.Login, null); var l = CaravanDataSource.Security.GetEntries(_myApp.Name, c1.Name); var l1 = CaravanDataSource.Security.GetEntriesForObject(_myApp.Name, c1.Name, obj1.Name); var l3 = CaravanDataSource.Security.GetEntriesForUser(_myApp.Name, c1.Name, user1.Login); Assert.That(l.Count(), Is.EqualTo(2)); Assert.That(l3.Count(), Is.EqualTo(1)); Assert.That(l1.Count(), Is.EqualTo(2)); }
public void Entries_NoEntries_ReturnsZero() { var c1 = new SecContext { Name = "c1", Description = "context1" }; var group1 = new SecGroup { Name = "my_group" }; var user1 = new SecUser { FirstName = "user1", Login = "******" }; CaravanDataSource.Security.AddUser(_myApp.Name, user1); CaravanDataSource.Security.AddGroup(_myApp.Name, group1); var l = CaravanDataSource.Security.GetEntries(_myApp.Name, c1.Name); Assert.That(l.Count(), Is.EqualTo(0)); }
public void Objects_EmptyAppName_ThrowsArgumentException() { var c1 = new SecContext { Name = "c1", Description = "context1" }; var group1 = new SecGroup { Name = "my_group" }; var user1 = new SecUser { FirstName = "user1", Login = "******" }; var obj1 = new SecObject { Name = "obj1", Description = "oggetto1", Type = "button" }; CaravanDataSource.Security.AddUser(_myApp.Name, user1); CaravanDataSource.Security.AddGroup(_myApp.Name, group1); CaravanDataSource.Security.AddEntry(_myApp.Name, c1, obj1, null, group1.Name); CaravanDataSource.Security.GetObjects(""); }
public void Objects_ValidArgs_ReturnsListOfObjects() { var c1 = new SecContext { Name = "c1", Description = "context1" }; var obj1 = new SecObject { Name = "obj1", Description = "oggetto1", Type = "button" }; var user1 = new SecUser { FirstName = "user1", Login = "******" }; var group1 = new SecGroup { Name = "my_group" }; CaravanDataSource.Security.AddUser(_myApp.Name, user1); CaravanDataSource.Security.AddGroup(_myApp.Name, group1); CaravanDataSource.Security.AddEntry(_myApp.Name, c1, obj1, user1.Login, null); var l = CaravanDataSource.Security.GetObjects(_myApp.Name); Assert.That(l.Count(), Is.EqualTo(1)); var l1 = CaravanDataSource.Security.GetObjects(_myApp2.Name); Assert.That(l1.Count(), Is.EqualTo(0)); }
public void Contexts_ValidArgs3_ReturnslistOfContexts() //Null Userlogin { var c1 = new SecContext { Name = "c1", Description = "context1" }; var c2 = new SecContext { Name = "c2", Description = "context2" }; var obj1 = new SecObject { Name = "obj1", Description = "oggetto1", Type = "button" }; var user1 = new SecUser { FirstName = "user1", Login = "******" }; var group1 = new SecGroup { Name = "my_group" }; CaravanDataSource.Security.AddUser(_myApp.Name, user1); CaravanDataSource.Security.AddGroup(_myApp.Name, group1); CaravanDataSource.Security.AddEntry(_myApp.Name, c1, obj1, null, group1.Name); CaravanDataSource.Security.AddEntry(_myApp.Name, c2, obj1, null, group1.Name); var l = CaravanDataSource.Security.GetContexts(_myApp.Name); Assert.That(l.Count(), Is.EqualTo(2)); Assert.That(l.Contains(c1)); Assert.That(l.Contains(c2)); }
public void RemoveEntry_ValidArgs_EntryRemoved() { var c1 = new SecContext { Name = "c1", Description = "context1" }; var group1 = new SecGroup { Name = "my_group" }; var user1 = new SecUser { FirstName = "user1", Login = "******" }; var user2 = new SecUser { FirstName = "user2", Login = "******" }; var obj1 = new SecObject { Name = "obj1", Description = "oggetto1", Type = "button" }; var obj2 = new SecObject { Name = "obj2", Description = "oggetto2", Type = "button" }; CaravanDataSource.Security.AddUser(_myApp.Name, user1); CaravanDataSource.Security.AddUser(_myApp.Name, user2); CaravanDataSource.Security.AddGroup(_myApp.Name, group1); CaravanDataSource.Security.AddEntry(_myApp.Name, c1, obj1, user1.Login, null); CaravanDataSource.Security.AddEntry(_myApp.Name, c1, obj2, user1.Login, null); CaravanDataSource.Security.RemoveEntry(_myApp.Name, c1.Name, obj1.Name, user1.Login, null); CaravanDataSource.Security.RemoveEntry(_myApp.Name, c1.Name, obj2.Name, user1.Login, null); var l = CaravanDataSource.Security.GetEntriesForObject(_myApp.Name, c1.Name, obj1.Name); Assert.That(l.Count(), Is.EqualTo(0)); var l1 = CaravanDataSource.Security.GetEntriesForObject(_myApp.Name, c1.Name, obj2.Name); Assert.That(l1.Count(), Is.EqualTo(0)); }
public void Entries_NullUserLoginAsFourthParam_Throws() { var c1 = new SecContext { Name = "c1", Description = "context1" }; var group1 = new SecGroup { Name = "my_group" }; var user1 = new SecUser { FirstName = "user1", Login = "******" }; var obj1 = new SecObject { Name = "obj1", Description = "oggetto1", Type = "button" }; CaravanDataSource.Security.AddUser(_myApp.Name, user1); CaravanDataSource.Security.AddGroup(_myApp.Name, group1); CaravanDataSource.Security.AddEntry(_myApp.Name, c1, obj1, null, group1.Name); CaravanDataSource.Security.GetEntriesForObjectAndUser(_myApp.Name, c1.Name, obj1.Name, null); }
public void RemoveEntry_EmptyGroupName_Throws() { var c1 = new SecContext { Name = "c1", Description = "context1" }; var group1 = new SecGroup { Name = "my_group" }; var user1 = new SecUser { FirstName = "user1", Login = "******" }; var obj1 = new SecObject { Name = "obj1", Description = "oggetto1", Type = "button" }; CaravanDataSource.Security.AddUser(_myApp.Name, user1); CaravanDataSource.Security.AddGroup(_myApp.Name, group1); CaravanDataSource.Security.AddEntry(_myApp.Name, c1, obj1, user1.Login, null); CaravanDataSource.Security.RemoveEntry(_myApp.Name, c1.Name, obj1.Name, user1.Login, ""); }
public void Addentry_ValidArgsNullGroupName_EntryAdded() { var c1 = new SecContext { Name = "c1", Description = "context1" }; var group1 = new SecGroup { Name = "my_group" }; var user1 = new SecUser { FirstName = "user1", Login = "******" }; var obj1 = new SecObject { Name = "obj1", Description = "oggetto1", Type = "button" }; CaravanDataSource.Security.AddUser(_myApp.Name, user1); CaravanDataSource.Security.AddGroup(_myApp.Name, group1); CaravanDataSource.Security.AddEntry(_myApp.Name, c1, obj1, user1.Login, null); var l = CaravanDataSource.Security.GetEntries(_myApp.Name, c1.Name); Assert.That(l.Count(), Is.EqualTo(1)); Assert.That(l.First().ContextName, Is.EqualTo("c1")); Assert.That(l.First().ObjectName, Is.EqualTo("obj1")); Assert.That(l.First().UserLogin, Is.EqualTo("mylogin")); }
public myHelperClienteTienda() { myContext = new SecContext(); }
public async Task GetEntriesForRoleAsync_ShouldReturnOneItemIfTwoAreStoredButOnlyOneIsForRole() { await SecurityRepository.AddAppAsync(new SecApp { Name = TestAppName, Description = TestAppDescription }); await SecurityRepository.AddGroupAsync(TestAppName, new SecGroup { Name = TestGroupName1, Description = TestGroupName1 }); await SecurityRepository.AddRoleAsync(TestAppName, TestGroupName1, new SecRole { Name = TestRoleName1, Description = TestRoleName1 }); await SecurityRepository.AddRoleAsync(TestAppName, TestGroupName1, new SecRole { Name = TestRoleName2, Description = TestRoleName2 }); var context = new SecContext { Name = TestContextName1, Description = TestContextName1 }; var obj = new SecObject { Name = TestObjectName1, Description = TestObjectName1, Type = TestObjectName1 }; await SecurityRepository.AddEntryAsync(TestAppName, context, obj, null, TestGroupName1, TestRoleName1); await SecurityRepository.AddEntryAsync(TestAppName, context, obj, null, TestGroupName1, TestRoleName2); var entriesForRole1 = await SecurityRepository.GetEntriesForRoleAsync(TestAppName, context.Name, TestGroupName1, TestRoleName1); Assert.That(entriesForRole1.Length, Is.EqualTo(1)); Assert.That(entriesForRole1[0].ObjectName, Is.EqualTo(obj.Name)); var entriesForRole2 = await SecurityRepository.GetEntriesForRoleAsync(TestAppName, context.Name, TestGroupName1, TestRoleName2); Assert.That(entriesForRole2.Length, Is.EqualTo(1)); Assert.That(entriesForRole2[0].ObjectName, Is.EqualTo(obj.Name)); }