OLD | NEW |
(Empty) | |
| 1 /* |
| 2 Copyright 2013 Google Inc |
| 3 |
| 4 Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 you may not use this file except in compliance with the License. |
| 6 You may obtain a copy of the License at |
| 7 |
| 8 http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
| 10 Unless required by applicable law or agreed to in writing, software |
| 11 distributed under the License is distributed on an "AS IS" BASIS, |
| 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 See the License for the specific language governing permissions and |
| 14 limitations under the License. |
| 15 */ |
| 16 |
| 17 using System; |
| 18 |
| 19 using NUnit.Framework; |
| 20 |
| 21 namespace Google.Apis.Auth.OAuth2.Requests |
| 22 { |
| 23 /// <summary> |
| 24 /// Tests for <seealso cref="Google.Apis.Auth.OAuth2.Requests.AuthorizationC
odeRequestUrl"/>.· |
| 25 /// It tests that the constructor sets the default values and the building U
RI method. |
| 26 /// </summary> |
| 27 [TestFixture] |
| 28 public class AuthorizationCodeRequestUrlTests |
| 29 { |
| 30 private readonly Uri AuthorizationCodeUrl = new Uri("http://www.authoriz
ation-server.com"); |
| 31 |
| 32 [Test] |
| 33 public void TestConstructor() |
| 34 { |
| 35 var request = new AuthorizationCodeRequestUrl(AuthorizationCodeUrl); |
| 36 Assert.That(request.AuthorizationServerUrl, Is.EqualTo(Authorization
CodeUrl)); |
| 37 Assert.Null(request.ClientId); |
| 38 Assert.Null(request.RedirectUri); |
| 39 Assert.That(request.ResponseType, Is.EqualTo("code")); |
| 40 Assert.Null(request.Scope); |
| 41 Assert.Null(request.State); |
| 42 } |
| 43 |
| 44 [Test] |
| 45 public void TestBuild_DefaultValues() |
| 46 { |
| 47 var request = new AuthorizationCodeRequestUrl(AuthorizationCodeUrl); |
| 48 var uri = request.Build(); |
| 49 Assert.That(uri, Is.EqualTo(new Uri(AuthorizationCodeUrl.ToString()
"?response_type=code"))); |
| 50 } |
| 51 |
| 52 [Test] |
| 53 public void TestBuild() |
| 54 { |
| 55 var request = new AuthorizationCodeRequestUrl(AuthorizationCodeUrl) |
| 56 { |
| 57 ClientId = "100", |
| 58 RedirectUri = "200", |
| 59 Scope = "SCOPE", |
| 60 State = "state", |
| 61 }; |
| 62 var uri = request.Build(); |
| 63 Assert.That(uri, Is.EqualTo(new Uri(AuthorizationCodeUrl.ToString()
|
| 64 "?response_type=code&client_id=100&redirect_uri=200&scope=SCOPE&
state=state"))); |
| 65 } |
| 66 |
| 67 [Test] |
| 68 public void TestBuild_EscapeValues() |
| 69 { |
| 70 var request = new AuthorizationCodeRequestUrl(AuthorizationCodeUrl) |
| 71 { |
| 72 ClientId = "pa$$word", |
| 73 RedirectUri = "???", |
| 74 Scope = "SC@PE", |
| 75 State = "!", |
| 76 }; |
| 77 var uri = request.Build(); |
| 78 Assert.That(uri, Is.EqualTo(new Uri(AuthorizationCodeUrl.ToString()
|
| 79 "?response_type=code&client_id=pa$$word&redirect_uri=??%
3F&scope=SC@PE&state=!"))); |
| 80 } |
| 81 } |
| 82 } |
OLD | NEW |