コード例 #1
0
        /// <summary>
        /// This method is used to initialize the shared test cases' context.
        /// </summary>
        /// <param name="requestFileUrl">A parameter represents the file URL.</param>
        /// <param name="userName">A parameter represents the user name we used.</param>
        /// <param name="password">A parameter represents the password of the user.</param>
        /// <param name="domain">A parameter represents the domain.</param>
        /// <param name="celloperationType">A parameter represents the type of CellStore operation which is used to determine different initialize logic.</param>
        /// <param name="site">A parameter represents the site.</param>
        public static void InitializeContextForShare(string requestFileUrl, string userName, string password, string domain, CellStoreOperationType celloperationType, ITestSite site)
        {
            SharedContext context         = SharedContext.Current;
            string        normalTargetUrl = string.Empty;

            switch (celloperationType)
            {
            case CellStoreOperationType.NormalCellStore:
            {
                normalTargetUrl       = requestFileUrl;
                context.OperationType = OperationType.WOPICellStorageRequest;
                break;
            }

            case CellStoreOperationType.RelativeAdd:
            {
                // For relative adding a file, the WOPI resource file URL should be an existed file, and the file should be added in a location where the relative source file is located.
                normalTargetUrl       = relativeSourceFileUrl;
                context.OperationType = OperationType.WOPICellStorageRelativeRequest;
                break;
            }

            case CellStoreOperationType.RealativeModified:
            {
                normalTargetUrl       = requestFileUrl;
                context.OperationType = OperationType.WOPICellStorageRelativeRequest;
                break;
            }
            }

            // Convert the request file url to WOPI format URL so that the MS-FSSHTTP test cases will use WOPI format URL to send request.
            string wopiTargetUrl = wopiSutManagedCodeControlAdapter.GetWOPIRootResourceUrl(normalTargetUrl, WOPIRootResourceUrlType.FileLevel, userName, password, domain);

            context.TargetUrl = wopiTargetUrl;
            context.IsMsFsshttpRequirementsCaptured = false;
            context.Site = site;

            // Only set the X-WOPI-RelativeTarget header value in relative CellStorage operation.
            if (CellStoreOperationType.NormalCellStore != celloperationType)
            {
                // Read the file name from the target resource URL.
                context.XWOPIRelativeTarget = GetFileNameFromFullUrl(requestFileUrl);
            }

            // Generate common headers
            WebHeaderCollection commonHeaders = HeadersHelper.GetCommonHeaders(wopiTargetUrl);

            context.XWOPIProof                = commonHeaders["X-WOPI-Proof"];
            context.XWOPIProofOld             = commonHeaders["X-WOPI-ProofOld"];
            context.XWOPITimeStamp            = commonHeaders["X-WOPI-TimeStamp"];
            context.XWOPIAuthorization        = commonHeaders["Authorization"];
            context.EndpointConfigurationName = currentSharedTestCasesEndpointName;
            context.UserName = userName;
            context.Password = password;
            context.Domain   = domain;
        }
コード例 #2
0
        /// <summary>
        /// This method is used to initialize the shared test cases' context.
        /// </summary>
        /// <param name="requestFileUrl">A parameter represents the file URL.</param>
        /// <param name="userName">A parameter represents the user name we used.</param>
        /// <param name="password">A parameter represents the password of the user.</param>
        /// <param name="domain">A parameter represents the domain.</param>
        /// <param name="celloperationType">A parameter represents the type of CellStore operation which is used to determine different initialize logic.</param>
        /// <param name="site">A parameter represents the site.</param>
        public static void InitializeContextForShare(string requestFileUrl, string userName, string password, string domain, CellStoreOperationType celloperationType, ITestSite site)
        {
            SharedContext context = SharedContext.Current;
            string normalTargetUrl = string.Empty;

            switch (celloperationType)
            {
                case CellStoreOperationType.NormalCellStore:
                    {
                        normalTargetUrl = requestFileUrl;
                        context.OperationType = OperationType.WOPICellStorageRequest;
                        break;
                    }

                case CellStoreOperationType.RelativeAdd:
                    {
                        // For relative adding a file, the WOPI resource file URL should be an existed file, and the file should be added in a location where the relative source file is located. 
                        normalTargetUrl = relativeSourceFileUrl;
                        context.OperationType = OperationType.WOPICellStorageRelativeRequest;
                        break;
                    }

                case CellStoreOperationType.RealativeModified:
                    {
                        normalTargetUrl = requestFileUrl;
                        context.OperationType = OperationType.WOPICellStorageRelativeRequest;
                        break;
                    }
            }

            // Convert the request file url to WOPI format URL so that the MS-FSSHTTP test cases will use WOPI format URL to send request.
            string wopiTargetUrl = wopiSutManagedCodeControlAdapter.GetWOPIRootResourceUrl(normalTargetUrl, WOPIRootResourceUrlType.FileLevel, userName, password, domain);

            context.TargetUrl = wopiTargetUrl;
            context.IsMsFsshttpRequirementsCaptured = false;
            context.Site = site;

            // Only set the X-WOPI-RelativeTarget header value in relative CellStorage operation.
            if (CellStoreOperationType.NormalCellStore != celloperationType)
            {
                // Read the file name from the target resource URL.
                context.XWOPIRelativeTarget = GetFileNameFromFullUrl(requestFileUrl);
            }

            // Generate common headers
            WebHeaderCollection commonHeaders = HeadersHelper.GetCommonHeaders(wopiTargetUrl);
            context.XWOPIProof = commonHeaders["X-WOPI-Proof"];
            context.XWOPIProofOld = commonHeaders["X-WOPI-ProofOld"];
            context.XWOPITimeStamp = commonHeaders["X-WOPI-TimeStamp"];
            context.XWOPIAuthorization = commonHeaders["Authorization"];
            context.EndpointConfigurationName = currentSharedTestCasesEndpointName;
            context.UserName = userName;
            context.Password = password;
            context.Domain = domain;
        }