Skip to content

Commit 56e4b62

Browse files
committed
Improved integration testing for identity roles
1 parent ca20e73 commit 56e4b62

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,26 @@ public void TestGetToken()
166166
Assert.AreSame(newToken, newCachedToken);
167167
}
168168

169+
[TestMethod]
170+
[TestCategory(TestCategories.User)]
171+
[TestCategory(TestCategories.Identity)]
172+
public void TestListRoles()
173+
{
174+
IIdentityProvider provider = Bootstrapper.CreateIdentityProvider();
175+
IExtendedCloudIdentityProvider extendedProvider = provider as IExtendedCloudIdentityProvider;
176+
if (extendedProvider == null)
177+
Assert.Inconclusive("The current identity provider does not implement {0}", typeof(IExtendedCloudIdentityProvider).Name);
178+
179+
IEnumerable<Role> roles = extendedProvider.ListRoles(limit: 500);
180+
Console.WriteLine("Roles:");
181+
foreach (Role role in roles)
182+
{
183+
Console.WriteLine(" Role \"{0}\" (id: {1})", role.Name, role.Id);
184+
if (!string.IsNullOrEmpty(role.Description))
185+
Console.WriteLine(" Description: {0}", role.Description);
186+
}
187+
}
188+
169189
[TestMethod]
170190
[TestCategory(TestCategories.User)]
171191
[TestCategory(TestCategories.Identity)]
@@ -300,6 +320,13 @@ public void TestAddUserUpdateUserDeleteUser()
300320
Assert.IsFalse(string.IsNullOrEmpty(user.Id));
301321
Assert.IsFalse(string.IsNullOrEmpty(user.Password));
302322

323+
IEnumerable<Role> roles = provider.GetRolesByUser(user.Id);
324+
Console.WriteLine("Roles for the created user:");
325+
foreach (Role role in roles)
326+
Console.WriteLine(" {0} ({1}) # {2}", role.Name, role.Id, role.Description);
327+
328+
Assert.IsTrue(roles.Any(i => string.Equals(i.Name, "identity:default", StringComparison.OrdinalIgnoreCase)));
329+
303330
try
304331
{
305332
// make sure we can't add the same user twice

0 commit comments

Comments
 (0)