@@ -27,7 +27,7 @@ public void Authenticate_ShouldAddAuthorizationAsTextValueToRequest_OnHttpAuthor
27
27
const string url = "https://no-query.string" ;
28
28
29
29
using var client = new RestClient ( url ) ;
30
- var request = new RestRequest ( ) ;
30
+ var request = new RestRequest ( ) ;
31
31
32
32
_auth . ParameterHandling = OAuthParameterHandling . HttpAuthorizationHeader ;
33
33
@@ -57,7 +57,7 @@ public void Authenticate_ShouldAddSignatureToRequestAsSeparateParameters_OnUrlOr
57
57
const string url = "https://no-query.string" ;
58
58
59
59
using var client = new RestClient ( url ) ;
60
- var request = new RestRequest ( ) ;
60
+ var request = new RestRequest ( ) ;
61
61
request . AddQueryParameter ( "queryparameter" , "foobartemp" ) ;
62
62
63
63
_auth . ParameterHandling = OAuthParameterHandling . UrlOrPostParameters ;
@@ -98,7 +98,7 @@ public void Authenticate_ShouldEncodeOAuthTokenParameter(OAuthType type, string
98
98
const string url = "https://no-query.string" ;
99
99
100
100
using var client = new RestClient ( url ) ;
101
- var request = new RestRequest ( ) ;
101
+ var request = new RestRequest ( ) ;
102
102
_auth . Type = type ;
103
103
_auth . Token = value ;
104
104
@@ -125,7 +125,7 @@ public void Authenticate_ShouldAllowEmptyConsumerSecret_OnHttpAuthorizationHeade
125
125
const string url = "https://no-query.string" ;
126
126
127
127
using var client = new RestClient ( url ) ;
128
- var request = new RestRequest ( ) ;
128
+ var request = new RestRequest ( ) ;
129
129
_auth . Type = type ;
130
130
_auth . ConsumerSecret = null ;
131
131
@@ -141,4 +141,26 @@ public void Authenticate_ShouldAllowEmptyConsumerSecret_OnHttpAuthorizationHeade
141
141
Assert . Contains ( "OAuth" , value ! ) ;
142
142
Assert . Contains ( $ "oauth_signature=\" { OAuthTools . UrlEncodeStrict ( "&" ) } ", value ) ;
143
143
}
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