Skip to content

Commit d059190

Browse files
committed
Update code to not ignore the Domain property of RackspaceCloudIdentity
1 parent 0e7d717 commit d059190

4 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/corelib/Providers/Rackspace/CloudIdentityProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ public UserAccess GetUserAccess(CloudIdentity identity, bool forceCacheRefresh =
686686
if (rackspaceCloudIdentity == null)
687687
rackspaceCloudIdentity = new RackspaceCloudIdentity(identity);
688688

689-
var userAccess = _userAccessCache.Get(string.Format("{0}", rackspaceCloudIdentity.Username), () =>
689+
var userAccess = _userAccessCache.Get(string.Format("{0}/{1}", rackspaceCloudIdentity.Domain, rackspaceCloudIdentity.Username), () =>
690690
{
691691
var auth = new AuthRequest(identity);
692692
var response = ExecuteRESTRequest<AuthenticationResponse>(identity, new Uri(_urlBase, "/v2.0/tokens"), HttpMethod.POST, auth, isTokenRequest: true);
@@ -723,7 +723,7 @@ public UserAccess Impersonate(RackspaceImpersonationIdentity identity, bool forc
723723
if (identity == null)
724724
throw new ArgumentNullException("identity");
725725

726-
var impToken = _userAccessCache.Get(string.Format("imp/{0}", identity.UserToImpersonate.Username), () => {
726+
var impToken = _userAccessCache.Get(string.Format("imp/{0}/{1}", identity.UserToImpersonate.Domain, identity.UserToImpersonate.Username), () => {
727727
const string urlPath = "/v2.0/RAX-AUTH/impersonation-tokens";
728728
var request = BuildImpersonationRequestJson(urlPath, identity.UserToImpersonate.Username, 600);
729729
var response = ExecuteRESTRequest<UserImpersonationResponse>(identity, new Uri(_urlBase, urlPath), HttpMethod.POST, request);

src/corelib/Providers/Rackspace/Objects/RackspaceCloudIdentity.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ public RackspaceCloudIdentity(CloudIdentity cloudIdentity) : this()
3333
this.Username = cloudIdentity.Username;
3434
this.Password = cloudIdentity.Password;
3535
this.APIKey = cloudIdentity.APIKey;
36+
37+
RackspaceCloudIdentity raxIdentity = cloudIdentity as RackspaceCloudIdentity;
38+
if (raxIdentity != null)
39+
this.Domain = raxIdentity.Domain;
3640
}
3741

3842
/// <summary>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public void Test004_Should_Successfully_Authenticate_With_New_Password_For_Admin
112112
{
113113
Username = _testAdminIdentity.Username,
114114
Password = AdminNewPassword,
115+
Domain = _testAdminIdentity.Domain,
115116
});
116117

117118
Assert.IsNotNull(userAcess);
@@ -158,6 +159,7 @@ public void Test008_Should_Successfully_Authenticate_With_New_Password_For_Non_A
158159
{
159160
Username = _testAdminIdentity.Username,
160161
Password = AdminNewPassword,
162+
Domain = _testAdminIdentity.Domain,
161163
});
162164

163165
Assert.IsNotNull(userAcess);

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ public void Should_Throw_Error_When_Authenticating_With_Invalid_Password()
6868
var identity = new RackspaceCloudIdentity()
6969
{
7070
Username = _testIdentity.Username,
71-
Password = "bad password"
71+
Password = "bad password",
72+
Domain = _testIdentity.Domain,
7273
};
7374
IIdentityProvider serviceProvider = new CloudIdentityProvider(identity);
7475

@@ -90,7 +91,8 @@ public void Should_Throw_Error_When_Authenticating_With_Invalid_API_Key()
9091
var identity = new RackspaceCloudIdentity()
9192
{
9293
Username = _testIdentity.Username,
93-
APIKey = "bad api key"
94+
APIKey = "bad api key",
95+
Domain = _testIdentity.Domain,
9496
};
9597
IIdentityProvider serviceProvider = new CloudIdentityProvider(identity);
9698

0 commit comments

Comments
 (0)