Skip to content

Commit 9fbe302

Browse files
committed
Updated documentation and tests for ValidateToken
1 parent 051f9b1 commit 9fbe302

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

src/corelib/Providers/Rackspace/IExtendedCloudIdentityProvider.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,14 +354,16 @@ public interface IExtendedCloudIdentityProvider : IIdentityProvider
354354
/// Validates a given token.
355355
/// </summary>
356356
/// <param name="token">The token to be authenticated.</param>
357-
/// <param name="tenantId">The Id of the Tenant to vaidate in scope.</param>
357+
/// <param name="tenantId">If specified, the validation ensures that the specified tenant is in scope. This is obtained from <see cref="Tenant.Id"/>.</param>
358358
/// <param name="identity">The cloud identity to use for this request. If not specified, the default identity for the current provider instance will be used.</param>
359-
/// <returns>A <see cref="UserAccess"/> object containing the authentication token and user data.</returns>
359+
/// <returns>A <see cref="UserAccess"/> object containing the authentication token and user data. The <see cref="UserAccess.ServiceCatalog"/> property of the result may be <c>null</c>.</returns>
360360
/// <exception cref="ArgumentNullException">If <paramref name="token"/> is <c>null</c>.</exception>
361361
/// <exception cref="ArgumentException">If <paramref name="token"/> is empty.</exception>
362362
/// <exception cref="NotSupportedException">If the provider does not support the given <paramref name="identity"/> type.</exception>
363363
/// <exception cref="InvalidOperationException">If <paramref name="identity"/> is <c>null</c> and no default identity is available for the provider.</exception>
364+
/// <exception cref="ItemNotFoundException">If <paramref name="tenantId"/> is specified and the token is not valid within the specified tenant.</exception>
364365
/// <exception cref="ResponseException">If the authentication request failed or the token does not exist.</exception>
366+
/// <seealso href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/GET_validateToken_v2.0_tokens__tokenId__Token_Operations.html">Validate Token (OpenStack Identity Service API v2.0 Reference)</seealso>
365367
UserAccess ValidateToken(string token, string tenantId = null, CloudIdentity identity = null);
366368
}
367369
}

src/testing/integration/Providers/Rackspace/UserIdentityTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,33 @@ public void TestAuthenticate()
6868
Console.WriteLine(JsonConvert.SerializeObject(userAccess, Formatting.Indented));
6969
}
7070

71+
/// <summary>
72+
/// This method tests the basic functionality of the <see cref="IExtendedCloudIdentityProvider.ValidateToken"/>
73+
/// method for a validated token.
74+
/// </summary>
75+
[TestMethod]
76+
[TestCategory(TestCategories.User)]
77+
[TestCategory(TestCategories.Identity)]
78+
public void TestValidateToken()
79+
{
80+
IExtendedCloudIdentityProvider provider = new CloudIdentityProvider(Bootstrapper.Settings.TestIdentity);
81+
UserAccess userAccess = provider.Authenticate();
82+
83+
Assert.IsNotNull(userAccess);
84+
Assert.IsNotNull(userAccess.Token);
85+
Assert.IsNotNull(userAccess.Token.Id);
86+
87+
UserAccess validated = provider.ValidateToken(userAccess.Token.Id);
88+
Assert.IsNotNull(validated);
89+
Assert.IsNotNull(validated.Token);
90+
Assert.AreEqual(userAccess.Token.Id, validated.Token.Id);
91+
92+
Assert.IsNotNull(validated.User);
93+
Assert.AreEqual(userAccess.User.Id, validated.User.Id);
94+
Assert.AreEqual(userAccess.User.Name, validated.User.Name);
95+
Assert.AreEqual(userAccess.User.DefaultRegion, validated.User.DefaultRegion);
96+
}
97+
7198
[TestMethod]
7299
[TestCategory(TestCategories.User)]
73100
[TestCategory(TestCategories.Identity)]

0 commit comments

Comments
 (0)