GetPolicyKeyFromSendString() public static method

Get policy key from Provision string response.
public static GetPolicyKeyFromSendString ( ActiveSyncResponseBase provisionResponseString ) : string
provisionResponseString ActiveSyncResponseBase The SendStringResponse instance of Provision command.
return string
Exemplo n.º 1
0
        public void MSASHTTP_S03_TC03_SetPolicyKeyRequestHeader()
        {
            #region Change the query value type to PlainText.
            // Call ConfigureRequestPrefixFields to set the QueryValueType to PlainText.
            IDictionary <HTTPPOSTRequestPrefixField, string> requestPrefix = new Dictionary <HTTPPOSTRequestPrefixField, string>();
            requestPrefix.Add(HTTPPOSTRequestPrefixField.QueryValueType, QueryValueType.PlainText.ToString());
            this.HTTPAdapter.ConfigureRequestPrefixFields(requestPrefix);
            #endregion

            #region Call Provision command without setting X-MS-PolicyKey header.
            SendStringResponse provisionResponse = this.CallProvisionCommand(string.Empty);

            // Get the policy key from the response of Provision command.
            string policyKey = TestSuiteHelper.GetPolicyKeyFromSendString(provisionResponse);
            #endregion

            #region Call Provision command with setting X-MS-PolicyKey header of the PlainText encoded query value type.
            // Set the X-MS-PolicyKey header.
            requestPrefix.Add(HTTPPOSTRequestPrefixField.PolicyKey, policyKey);
            this.HTTPAdapter.ConfigureRequestPrefixFields(requestPrefix);

            this.CallProvisionCommand(policyKey);

            // Reset the X-MS-PolicyKey header.
            requestPrefix[HTTPPOSTRequestPrefixField.PolicyKey] = string.Empty;
            this.HTTPAdapter.ConfigureRequestPrefixFields(requestPrefix);
            #endregion

            #region Change the query value type to Base64.
            // Call ConfigureRequestPrefixFields to set the QueryValueType to Base64.
            requestPrefix[HTTPPOSTRequestPrefixField.QueryValueType] = QueryValueType.Base64.ToString();
            this.HTTPAdapter.ConfigureRequestPrefixFields(requestPrefix);
            #endregion

            #region Call Provision command without setting Policy key field.
            provisionResponse = this.CallProvisionCommand(string.Empty);

            // Get the policy key from the response of Provision command.
            policyKey = TestSuiteHelper.GetPolicyKeyFromSendString(provisionResponse);
            #endregion

            #region Call Provision command with setting Policy key field of the base64 encoded query value type.
            // Set the Policy key field.
            requestPrefix[HTTPPOSTRequestPrefixField.PolicyKey] = policyKey;
            this.HTTPAdapter.ConfigureRequestPrefixFields(requestPrefix);

            this.CallProvisionCommand(policyKey);

            // Reset the Policy key field.
            requestPrefix[HTTPPOSTRequestPrefixField.PolicyKey] = string.Empty;
            this.HTTPAdapter.ConfigureRequestPrefixFields(requestPrefix);
            #endregion

            #region Reset the query value type.
            requestPrefix[HTTPPOSTRequestPrefixField.QueryValueType] = Common.GetConfigurationPropertyValue("HeaderEncodingType", this.Site);
            this.HTTPAdapter.ConfigureRequestPrefixFields(requestPrefix);
            #endregion
        }