Exemplo n.º 1
0
        public void GetUPNFromGroupWithSIDTest()
        {
            using (var targetClientContext = TestCommon.CreateClientContext(TestCommon.AppSetting("SPOTargetSiteUrl")))
            {
                using (var sourceClientContext = TestCommon.CreateOnPremisesClientContext())
                {
                    PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation()
                    {
                        // If target page exists, then overwrite it
                        Overwrite = true,
                        // Don't log test runs
                        SkipTelemetry = true,
                        //Permissions are should work given cross domain with mapping
                        KeepPageSpecificPermissions = true,
                        // Replace User Mapping
                        UserMappingFile = @"..\..\Transform\Mapping\usermapping_sample.csv"
                    };

                    UserTransformator userTransformator = new UserTransformator(pti, sourceClientContext, targetClientContext, null);

                    // SharePoint-Readers (note specific to PBs test rig)
                    var result = userTransformator.SearchSourceDomainForUPN(AccountType.Group, "s-1-5-21-2364077317-3999105188-691961326-1129");
                    Console.WriteLine(result);

                    Assert.IsTrue(!string.IsNullOrEmpty(result));
                }
            }
        }
Exemplo n.º 2
0
        public void PrincipalAccountTest()
        {
            using (var targetClientContext = TestCommon.CreateClientContext(TestCommon.AppSetting("SPOTargetSiteUrl")))
            {
                using (var sourceClientContext = TestCommon.CreateOnPremisesClientContext())
                {
                    PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation()
                    {
                        // If target page exists, then overwrite it
                        Overwrite = true,

                        // Don't log test runs
                        SkipTelemetry = true,

                        //Permissions are should work given cross domain with mapping
                        KeepPageSpecificPermissions = true,

                        SourceVersion = SPVersion.SP2010 //example only
                    };

                    UserTransformator userTransformator = new UserTransformator(pti, sourceClientContext, targetClientContext, null);

                    var result = userTransformator.RemapPrincipal("test.user3");
                    Console.WriteLine(result);

                    Assert.IsTrue(!string.IsNullOrEmpty(result));
                }
            }
        }
Exemplo n.º 3
0
        public void GetUPNFromAccountTest()
        {
            using (var targetClientContext = TestCommon.CreateClientContext(TestCommon.AppSetting("SPOTargetSiteUrl")))
            {
                using (var sourceClientContext = TestCommon.CreateOnPremisesClientContext())
                {
                    PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation()
                    {
                        // If target page exists, then overwrite it
                        Overwrite = true,

                        // Don't log test runs
                        SkipTelemetry = true,

                        //Permissions are should work given cross domain with mapping
                        KeepPageSpecificPermissions = true,

                        // Replace User Mapping
                        UserMappingFile = @"..\..\Transform\Mapping\usermapping_sample.csv"
                    };

                    UserTransformator userTransformator = new UserTransformator(pti, sourceClientContext, targetClientContext, null);

                    var result = userTransformator.SearchSourceDomainForUPN(AccountType.User, "test.user3");
                    Console.WriteLine(result);

                    Assert.IsTrue(!string.IsNullOrEmpty(result));
                }
            }
        }
Exemplo n.º 4
0
        public void GetUPNFromAccountWithCustomLDAPPositiveTest()
        {
            var ldap = "LDAP://OU=CDT,OU=Demo Users,DC=AlphaDelta,DC=Local";

            using (var targetClientContext = TestCommon.CreateClientContext(TestCommon.AppSetting("SPOTargetSiteUrl")))
            {
                using (var sourceClientContext = TestCommon.CreateOnPremisesClientContext())
                {
                    PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation()
                    {
                        // If target page exists, then overwrite it
                        Overwrite = true,

                        // Don't log test runs
                        SkipTelemetry = true,

                        //Permissions are should work given cross domain with mapping
                        KeepPageSpecificPermissions = true,

                        LDAPConnectionString = ldap
                    };

                    UserTransformator userTransformator = new UserTransformator(pti, sourceClientContext, targetClientContext, null);

                    var result = userTransformator.SearchSourceDomainForUPN(AccountType.User, "Cara.Irvine"); //User Outside of LDAP Connection String
                    Console.WriteLine(result);

                    Assert.IsTrue(!string.IsNullOrEmpty(result));
                }
            }
        }
Exemplo n.º 5
0
        public IEnumerable <UserDto> GetAll()
        {
            using (var sqlConnection = new SqlConnection(_connectionString))
            {
                var query    = new SqlCommand(@"
                SELECT [Id],
                       [FirstName],
                       [LastName]
                FROM [TravelMapAppDb].[dbo].[Users]");
                var allUsers = sqlConnection.Query <UserEntity>(query.CommandText, query.ToDynamicParameters()).ToList();

                return(allUsers.Select(user => UserTransformator.Map(user)));
            }
        }
Exemplo n.º 6
0
        public UserDto Get(int id)
        {
            using (var sqlConnection = new SqlConnection(_connectionString))
            {
                var query = new SqlCommand(@"
                SELECT [Id],
                       [FirstName],
                       [LastName]
                FROM [TravelMapAppDb].[dbo].[Users]
                WHERE @Id = Id");
                query.Parameters.AddWithValue("Id", id);
                var user = sqlConnection.QueryFirstOrDefault <UserEntity>(query.CommandText, query.ToDynamicParameters());

                return(UserTransformator.Map(user));
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Instantiates the base builtin function library
        /// </summary>
        /// <param name="pageClientContext">ClientContext object for the site holding the page being transformed</param>
        /// <param name="sourceClientContext">The ClientContext for the source </param>
        /// <param name="clientSidePage">Reference to the client side page</param>
        public PublishingBuiltIn(BaseTransformationInformation baseTransformationInformation, ClientContext sourceClientContext, ClientContext targetClientContext, IList <ILogObserver> logObservers = null) : base(sourceClientContext)
        {
            if (logObservers != null)
            {
                foreach (var observer in logObservers)
                {
                    base.RegisterObserver(observer);
                }
            }

            this.sourceClientContext           = sourceClientContext;
            this.targetClientContext           = targetClientContext;
            this.baseTransformationInformation = baseTransformationInformation;
            this.parser            = new HtmlParser();
            this.builtIn           = new BuiltIn(this.baseTransformationInformation, targetClientContext, sourceClientContext, logObservers: logObservers);
            this.userTransformator = new UserTransformator(baseTransformationInformation, this.sourceClientContext, this.targetClientContext, base.RegisteredLogObservers);
        }
Exemplo n.º 8
0
        public void GetLDAPConnectingStringTest()
        {
            //Doesnt matter what the settings are.
            PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation()
            {
                // Don't log test runs
                SkipTelemetry = true,
            };

            UserTransformator userTransformator = new UserTransformator(pti, null, null, null);

            var result = userTransformator.GetLDAPConnectionString();

            Console.WriteLine(result);

            Assert.IsTrue(!string.IsNullOrEmpty(result));
        }
Exemplo n.º 9
0
        public MyCustomFunctions(BaseTransformationInformation baseTransformationInformation, ClientContext pageClientContext, ClientContext sourceClientContext, ClientSidePage clientSidePage, IList <ILogObserver> logObservers) : base(pageClientContext)
        {
            if (logObservers != null)
            {
                foreach (var observer in logObservers)
                {
                    base.RegisterObserver(observer);
                }
            }

            // This is an optional property, in cross site transfer the two contexts would be different.
            this.sourceClientContext           = sourceClientContext;
            this.clientSidePage                = clientSidePage;
            this.baseTransformationInformation = baseTransformationInformation;
            this.urlTransformator              = new UrlTransformator(baseTransformationInformation, this.sourceClientContext, this.clientContext, base.RegisteredLogObservers);
            this.userTransformator             = new UserTransformator(baseTransformationInformation, this.sourceClientContext, this.clientContext, base.RegisteredLogObservers);
        }
Exemplo n.º 10
0
        public int Add(UserDto user)
        {
            var userToAdd = new UserDto
            {
                Id               = _allUsers.Max(x => x.Id) + 1,
                FirstName        = user.FirstName,
                LastName         = user.LastName,
                VisitedCountries = user.VisitedCountries.Select(y => new TravelDestinationDto
                {
                    CountryId = y.CountryId,
                    Name      = y.Name
                }).ToList()
            };

            _allUsers.Add(UserTransformator.Map(userToAdd));

            return(userToAdd.Id);
        }
Exemplo n.º 11
0
        public PublishingMetadataTransformator(PublishingPageTransformationInformation publishingPageTransformationInformation, ClientContext sourceClientContext,
                                               ClientContext targetClientContext, ClientSidePage page, PageLayout publishingPageLayoutModel, PublishingPageTransformation publishingPageTransformation,
                                               UserTransformator userTransformator, IList <ILogObserver> logObservers = null)
        {
            // Register observers
            if (logObservers != null)
            {
                foreach (var observer in logObservers)
                {
                    base.RegisterObserver(observer);
                }
            }

            this.publishingPageTransformationInformation = publishingPageTransformationInformation;
            this.sourceClientContext = sourceClientContext;
            this.targetClientContext = targetClientContext;
            this.page = page;
            this.pageLayoutMappingModel       = publishingPageLayoutModel;
            this.publishingPageTransformation = publishingPageTransformation;
            this.functionProcessor            = new PublishingFunctionProcessor(publishingPageTransformationInformation.SourcePage, sourceClientContext, targetClientContext, this.publishingPageTransformation, publishingPageTransformationInformation as BaseTransformationInformation, base.RegisteredLogObservers);
            this.userTransformator            = userTransformator;
        }
Exemplo n.º 12
0
        public void GetLDAPConnectingStringProvidedByParamTest()
        {
            var ldap = "LDAP://OU=CDT,OU=Demo Users,DC=AlphaDelta,DC=Local";

            //Doesnt matter what the settings are.
            PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation()
            {
                // Don't log test runs
                SkipTelemetry = true,

                LDAPConnectionString = ldap
            };

            UserTransformator userTransformator = new UserTransformator(pti, null, null, null);

            var result = userTransformator.GetLDAPConnectionString();

            Console.WriteLine(result);

            Assert.IsTrue(!string.IsNullOrEmpty(result));
            Assert.IsTrue(result.Equals(ldap, StringComparison.InvariantCultureIgnoreCase));
        }
Exemplo n.º 13
0
        public void GetComputerDomainTest()
        {
            using (var targetClientContext = TestCommon.CreateClientContext(TestCommon.AppSetting("SPOTargetSiteUrl")))
            {
                using (var sourceClientContext = TestCommon.CreateOnPremisesClientContext())
                {
                    //Doesnt matter what the settings are.
                    PublishingPageTransformationInformation pti = new PublishingPageTransformationInformation()
                    {
                        // Don't log test runs
                        SkipTelemetry = true,
                    };


                    UserTransformator userTransformator = new UserTransformator(pti, sourceClientContext, targetClientContext, null);

                    var result = userTransformator.GetFriendlyComputerDomain();
                    Console.WriteLine(result);

                    Assert.IsTrue(!string.IsNullOrEmpty(result));
                }
            }
        }
Exemplo n.º 14
0
        public void Edit(UserDto user)
        {
            var originalUser = _allUsers.Find(x => x.Id == user.Id);

            UserTransformator.Map(originalUser);
        }
Exemplo n.º 15
0
        public UserDto Get(int id)
        {
            var user = _allUsers.SingleOrDefault(x => x.Id == id);

            return(UserTransformator.Map(user));
        }
Exemplo n.º 16
0
 public IEnumerable <UserDto> GetAll()
 {
     return(_allUsers.Select((userDto) => UserTransformator.Map(userDto)));
 }