Ejemplo n.º 1
0
        public static void ClassSetup(TestContext context)
        {
            AppDomain.CurrentDomain.SetData(
                "DataDirectory",
                Path.Combine(context.TestDeploymentDir, string.Empty));

            IPasswordHashingService hashingService = ApplicationContext.Current.GetService <IPasswordHashingService>();
            var dataService = ApplicationContext.Current.GetService <IDataPersistenceService <SecurityUser> >();

            dataService.Insert(new SecurityUser()
            {
                UserName     = "******",
                Email        = "*****@*****.**",
                PasswordHash = hashingService.EncodePassword("password"),
                UserClass    = UserClassKeys.HumanUser
            }, AuthenticationContext.SystemPrincipal, TransactionMode.Commit);
            dataService.Insert(new SecurityUser()
            {
                UserName     = "******",
                Email        = "*****@*****.**",
                PasswordHash = hashingService.EncodePassword("password"),
                UserClass    = UserClassKeys.HumanUser
            }, AuthenticationContext.SystemPrincipal, TransactionMode.Commit);

            IRoleProviderService roleService = ApplicationContext.Current.GetService <IRoleProviderService>();

            roleService.AddUsersToRoles(new string[] { "*****@*****.**", "*****@*****.**" }, new string[] { "USERS" }, AuthenticationContext.SystemPrincipal);
            roleService.AddUsersToRoles(new string[] { "*****@*****.**" }, new string[] { "ADMINISTRATORS" }, AuthenticationContext.SystemPrincipal);
        }
        public void ClassSetup()
        {
            AuthenticationContext.EnterSystemContext();

            IIdentityProviderService identityProvider = ApplicationServiceContext.Current.GetService <IIdentityProviderService>();
            var identity = identityProvider.CreateIdentity(nameof(SecurityRolePersistenceServiceTest), "password", AuthenticationContext.Current.Principal);

            // Give this identity the administrative functions group
            IRoleProviderService roleProvider = ApplicationServiceContext.Current.GetService <IRoleProviderService>();

            roleProvider.AddUsersToRoles(new string[] { identity.Name }, new string[] { "ADMINISTRATORS" }, AuthenticationContext.Current.Principal);

            // Authorize
            s_authorization = identityProvider.Authenticate(nameof(SecurityRolePersistenceServiceTest), "password");


            IDataPersistenceService <SecurityPolicy> policyService = ApplicationServiceContext.Current.GetService <IDataPersistenceService <SecurityPolicy> >();

            s_chickenCostumePolicy = new SecurityPolicy()
            {
                Name = "Allow wearing of chicken costume",
                Oid  = "2.3.23.543.25.2"
            };
            s_chickenCostumePolicy = policyService.Insert(s_chickenCostumePolicy, TransactionMode.Commit, s_authorization);
        }
        public static void ClassSetup(TestContext context)
        {
            AppDomain.CurrentDomain.SetData(
                "DataDirectory",
                Path.Combine(context.TestDeploymentDir, string.Empty));

            IIdentityProviderService identityProvider = ApplicationContext.Current.GetService <IIdentityProviderService>();
            var identity = identityProvider.CreateIdentity(nameof(SecurityRolePersistenceServiceTest), "password", AuthenticationContext.SystemPrincipal);

            // Give this identity the administrative functions group
            IRoleProviderService roleProvider = ApplicationContext.Current.GetService <IRoleProviderService>();

            roleProvider.AddUsersToRoles(new string[] { identity.Name }, new string[] { "ADMINISTRATORS" }, AuthenticationContext.SystemPrincipal);

            // Authorize
            s_authorization = identityProvider.Authenticate(nameof(SecurityRolePersistenceServiceTest), "password");


            IDataPersistenceService <SecurityPolicy> policyService = ApplicationContext.Current.GetService <IDataPersistenceService <SecurityPolicy> >();

            s_chickenCostumePolicy = new SecurityPolicy()
            {
                Name = "Allow wearing of chicken costume",
                Oid  = "2.3.23.543.25.2"
            };
            s_chickenCostumePolicy = policyService.Insert(s_chickenCostumePolicy, s_authorization, TransactionMode.Commit);
        }
Ejemplo n.º 4
0
        public static void ClassSetup(TestContext context)
        {
            IPasswordHashingService hashingService = ApplicationContext.Current.GetService <IPasswordHashingService>();
            var dataService = ApplicationContext.Current.GetService <IIdentityProviderService>();

            if (dataService.GetIdentity("*****@*****.**") == null)
            {
                dataService.CreateIdentity("*****@*****.**", "password", AuthenticationContext.SystemPrincipal);
            }
            if (dataService.GetIdentity("*****@*****.**") == null)
            {
                dataService.CreateIdentity("*****@*****.**", "password", AuthenticationContext.SystemPrincipal);
            }

            IRoleProviderService roleService = ApplicationContext.Current.GetService <IRoleProviderService>();

            roleService.AddUsersToRoles(new string[] { "*****@*****.**", "*****@*****.**" }, new string[] { "USERS" }, AuthenticationContext.SystemPrincipal);
            roleService.AddUsersToRoles(new string[] { "*****@*****.**" }, new string[] { "ADMINISTRATORS" }, AuthenticationContext.SystemPrincipal);
        }
Ejemplo n.º 5
0
        public static void ClassSetup(TestContext context)
        {
            TestApplicationContext.TestAssembly = typeof(AdoIdentityProviderTest).Assembly;
            TestApplicationContext.Initialize(context.DeploymentDirectory);
            IPasswordHashingService hashingService = ApplicationServiceContext.Current.GetService <IPasswordHashingService>();

            AuthenticationContext.Current = new AuthenticationContext(AuthenticationContext.SystemPrincipal);
            var dataService = ApplicationServiceContext.Current.GetService <IIdentityProviderService>();

            if (dataService.GetIdentity("*****@*****.**") == null)
            {
                dataService.CreateIdentity("*****@*****.**", "password", AuthenticationContext.Current.Principal);
            }
            if (dataService.GetIdentity("*****@*****.**") == null)
            {
                dataService.CreateIdentity("*****@*****.**", "password", AuthenticationContext.Current.Principal);
            }

            IRoleProviderService roleService = ApplicationServiceContext.Current.GetService <IRoleProviderService>();

            roleService.AddUsersToRoles(new string[] { "*****@*****.**", "*****@*****.**" }, new string[] { "USERS" }, AuthenticationContext.Current.Principal);
            roleService.AddUsersToRoles(new string[] { "*****@*****.**" }, new string[] { "ADMINISTRATORS" }, AuthenticationContext.Current.Principal);
        }
Ejemplo n.º 6
0
        public static void ClassSetup(TestContext context)
        {
            AppDomain.CurrentDomain.SetData(
                "DataDirectory",
                Path.Combine(context.TestDeploymentDir, string.Empty));
            IIdentityProviderService identityProvider = ApplicationContext.Current.GetService <IIdentityProviderService>();
            var identity = identityProvider.CreateIdentity(nameof(SqlRoleProviderTest), "password", AuthenticationContext.SystemPrincipal);

            // Give this identity the administrative functions group
            IRoleProviderService roleProvider = ApplicationContext.Current.GetService <IRoleProviderService>();

            roleProvider.AddUsersToRoles(new string[] { identity.Name }, new string[] { "ADMINISTRATORS" }, AuthenticationContext.SystemPrincipal);

            // Authorize
            s_authorization = identityProvider.Authenticate(nameof(SqlRoleProviderTest), "password");
        }