@@ -27,7 +27,7 @@ public void Authenticate_ShouldAddAuthorizationAsTextValueToRequest_OnHttpAuthor
2727 const string url = "https://no-query.string" ;
2828
2929 using var client = new RestClient ( url ) ;
30- var request = new RestRequest ( ) ;
30+ var request = new RestRequest ( ) ;
3131
3232 _auth . ParameterHandling = OAuthParameterHandling . HttpAuthorizationHeader ;
3333
@@ -57,7 +57,7 @@ public void Authenticate_ShouldAddSignatureToRequestAsSeparateParameters_OnUrlOr
5757 const string url = "https://no-query.string" ;
5858
5959 using var client = new RestClient ( url ) ;
60- var request = new RestRequest ( ) ;
60+ var request = new RestRequest ( ) ;
6161 request . AddQueryParameter ( "queryparameter" , "foobartemp" ) ;
6262
6363 _auth . ParameterHandling = OAuthParameterHandling . UrlOrPostParameters ;
@@ -98,7 +98,7 @@ public void Authenticate_ShouldEncodeOAuthTokenParameter(OAuthType type, string
9898 const string url = "https://no-query.string" ;
9999
100100 using var client = new RestClient ( url ) ;
101- var request = new RestRequest ( ) ;
101+ var request = new RestRequest ( ) ;
102102 _auth . Type = type ;
103103 _auth . Token = value ;
104104
@@ -125,7 +125,7 @@ public void Authenticate_ShouldAllowEmptyConsumerSecret_OnHttpAuthorizationHeade
125125 const string url = "https://no-query.string" ;
126126
127127 using var client = new RestClient ( url ) ;
128- var request = new RestRequest ( ) ;
128+ var request = new RestRequest ( ) ;
129129 _auth . Type = type ;
130130 _auth . ConsumerSecret = null ;
131131
@@ -141,4 +141,26 @@ public void Authenticate_ShouldAllowEmptyConsumerSecret_OnHttpAuthorizationHeade
141141 Assert . Contains ( "OAuth" , value ! ) ;
142142 Assert . Contains ( $ "oauth_signature=\" { OAuthTools . UrlEncodeStrict ( "&" ) } ", value ) ;
143143 }
144- }
144+
145+ [ Fact ]
146+ public async Task Authenticate_ShouldUriEncodeConsumerKey_OnHttpAuthorizationHeaderHandling ( ) {
147+ // Arrange
148+ const string url = "https://no-query.string" ;
149+
150+ var client = new RestClient ( url ) ;
151+ var request = new RestRequest ( ) ;
152+ _auth . Type = OAuthType . ProtectedResource ;
153+ _auth . ConsumerKey = "my@consumer!key" ;
154+ _auth . ConsumerSecret = null ;
155+
156+ // Act
157+ await _auth . Authenticate ( client , request ) ;
158+
159+ // Assert
160+ var authParameter = request . Parameters . Single ( x => x . Name == KnownHeaders . Authorization ) ;
161+ var value = ( string ) authParameter . Value ;
162+
163+ value . Should ( ) . Contain ( "OAuth" ) ;
164+ value . Should ( ) . Contain ( "oauth_consumer_key=\" my%40consumer%21key" ) ;
165+ }
166+ }
0 commit comments