public RessourcesServersController([FromServices] IRessourceServerService service) { _service = service; }
public void Init() { _service = new RessourceServerService() { Configuration = FakeConfigurationHelper.GetFakeConf(), RepositoriesFactory = new FakeRepositoriesFactory(), StringLocalizerFactory = new FakeStringLocalizerFactory(), Logger = new FakeLogger(), EncryptonService = new FakeEncryptionService() }; _adminUser = new User() { CreationDate = DateTime.Now, EMail = "*****@*****.**", FullName = "Samadmin", Id = 123, IsValid = true, Password = new byte[] { 0 }, UserName = "******" }; _normalUser = new User() { CreationDate = DateTime.Now, EMail = "*****@*****.**", FullName = "SamPasadmin", Id = 124, IsValid = true, Password = new byte[] { 0 }, UserName = "******" }; _invalidUser = new User() { CreationDate = DateTime.Now, EMail = "*****@*****.**", FullName = "SamPasValid", Id = 125, IsValid = false, Password = new byte[] { 0 }, UserName = "******" }; FakeDataBase.Instance.Users.Add(_adminUser); FakeDataBase.Instance.Users.Add(_normalUser); FakeDataBase.Instance.Users.Add(_invalidUser); _adminRole = new Role() { Id = (int)ERole.ADMIN, Wording = RoleName.Administrator }; _normalRole = new Role() { Id = (int)ERole.USER, Wording = RoleName.User }; FakeDataBase.Instance.Roles.Clear(); FakeDataBase.Instance.Roles.Add(_adminRole); FakeDataBase.Instance.Roles.Add(_normalRole); FakeDataBase.Instance.UsersRoles.Add(new UserRole() { Id = 345, RoleId = _adminRole.Id, UserId = _adminUser.Id }); FakeDataBase.Instance.UsersRoles.Add(new UserRole() { Id = 346, RoleId = _normalRole.Id, UserId = _normalUser.Id }); _existingRessourceServer = new RessourceServer() { CreationDate = DateTime.Now, Description = "I Exist", Id = 999, IsValid = true, Login = "******", Name = "existing", ServerSecret = new byte[] { 0 } }; _validRessourceServer = new RessourceServer() { CreationDate = DateTime.Now, Description = "I am valid, yeah", Id = 1999, IsValid = true, Login = "******", Name = "valid_rs_name", ServerSecret = new byte[] { 0 } }; _invalidRessourceServer = new RessourceServer() { CreationDate = DateTime.Now, Description = "I am not valid, sad", Id = 2000, IsValid = false, Login = "******", Name = "invalid_rs_name", ServerSecret = new byte[] { 0 } }; FakeDataBase.Instance.RessourceServers.Add(_existingRessourceServer); FakeDataBase.Instance.RessourceServers.Add(_validRessourceServer); FakeDataBase.Instance.RessourceServers.Add(_invalidRessourceServer); _existingScope = new Scope() { Id = 789, RessourceServerId = _existingRessourceServer.Id, NiceWording = "I Exist", Wording = "RW_I_Exist" }; FakeDataBase.Instance.Scopes.Add(_existingScope); _createDto = new CreateRessourceServerDto() { Description = "Test ressource server", Login = "******", Name = "R-Serv", Password = "******", RepeatPassword = "******", Scopes = new List <CreateRessourceServerScopesDto>() { new CreateRessourceServerScopesDto() { IsReadWrite = true, NiceWording = "scope1 nice wording" }, new CreateRessourceServerScopesDto() { IsReadWrite = false, NiceWording = "scope2 another nice wording" }, new CreateRessourceServerScopesDto() { IsReadWrite = true, NiceWording = "scope3 juste another nice wording" } }, UserName = _adminUser.UserName }; }