本文整理汇总了C#中net.openstack.Providers.Rackspace.CloudIdentityProvider.GetUserAccess方法的典型用法代码示例。如果您正苦于以下问题:C# CloudIdentityProvider.GetUserAccess方法的具体用法?C# CloudIdentityProvider.GetUserAccess怎么用?C# CloudIdentityProvider.GetUserAccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.openstack.Providers.Rackspace.CloudIdentityProvider
的用法示例。
在下文中一共展示了CloudIdentityProvider.GetUserAccess方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGetUserAccess
public void TestGetUserAccess()
{
IIdentityProvider provider = new CloudIdentityProvider(Bootstrapper.Settings.TestIdentity);
UserAccess userAccess = provider.GetUserAccess();
Assert.IsNotNull(userAccess);
Assert.IsNotNull(userAccess.Token);
// ensure the provider is caching the access token
UserAccess cachedUserAccess = provider.GetUserAccess();
Assert.AreSame(userAccess, cachedUserAccess);
// ensure that the provider refreshes the userAccess upon request
UserAccess newUserAccess = provider.GetUserAccess(forceCacheRefresh: true);
Assert.AreNotSame(userAccess, newUserAccess);
// ensure the the refresh was applied to the cache
UserAccess newCachedUserAccess = provider.GetUserAccess();
Assert.AreSame(newUserAccess, newCachedUserAccess);
}
示例2: TestGetRolesByUser
public void TestGetRolesByUser()
{
IIdentityProvider provider = new CloudIdentityProvider(Bootstrapper.Settings.TestIdentity);
UserAccess userAccess = provider.GetUserAccess();
Assert.IsNotNull(userAccess);
Assert.IsNotNull(userAccess.User);
IEnumerable<Role> roles = provider.GetRolesByUser(userAccess.User.Id);
Assert.IsNotNull(roles);
Assert.IsTrue(roles.Any());
foreach (Role role in roles)
{
Console.WriteLine("Role \"{0}\" (id: {1})", role.Name, role.Id);
if (!string.IsNullOrEmpty(role.Description))
Console.WriteLine(" Description: {0}", role.Description);
}
}