Example #1
0
        public void GetHeaderParametersWhenKeysValueIsEmpty()
        {
            List <QueryParameter> parameters =
                UriUtility.GetHeaderParameters("OAuth realm=\"http:\\somerealm.com\", oauth_consumer_key=\"\"");

            Assert.Equal("", parameters.Single(p => p.Key == "oauth_consumer_key").Value);
        }
Example #2
0
        public void GetHeaderParametersWhenAuthorizationHeaderDoesNotContainOAuthReturnsEmptyCollection()
        {
            List <QueryParameter> parameters =
                UriUtility.GetHeaderParameters("realm=\"http:\\somerealm.com\", oauth_consumer_key=\"\"");

            Assert.Equal(0, parameters.Count);
        }
 /// <summary>
 /// Parse Authorization Header
 /// </summary>
 /// <param name="headers">The name value headers</param>
 /// <param name="context">The OAuth context</param>
 static void ParseAuthorizationHeader(NameValueCollection headers, OAuthContext context)
 {
     if (headers.AllKeys.Contains("Authorization"))
     {
         context.AuthorizationHeaderParameters = UriUtility.GetHeaderParameters(headers["Authorization"]).ToNameValueCollection();
         context.UseAuthorizationHeader        = true;
     }
 }
        public void GetHeaderParameters()
        {
            List <QueryParameter> parameters =
                UriUtility.GetHeaderParameters("OAuth realm=\"http:\\somerealm.com\", oauth_consumer_key=\"consumerKey\"");

            Assert.AreEqual(1, parameters.Count);
            Assert.AreEqual("consumerKey", parameters.Single(p => p.Key == "oauth_consumer_key").Value);
        }