Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

domain scoped authentication with tests #503

Merged
merged 1 commit into from
Nov 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
public class KeystoneTests extends AbstractTest {

private static final String JSON_AUTH_PROJECT = "/identity.v3/authv3_project.json";
private static final String JSON_AUTH_DOMAINID_USERID = "/identity.v3/authv3_domainId_userId.json";
private static final String JSON_AUTH_DOMAINID_USERNAME = "/identity.v3/authv3_domainId_userName.json";
private static final String JSON_AUTH_DOMAINNAME_USERID = "/identity.v3/authv3_domainName_userId.json";
private static final String JSON_AUTH_UNSCOPED = "/identity.v3/authv3_unscoped.json";
private static final String JSON_AUTH_TOKEN = "/identity.v3/authv3_token.json";
private static final ImmutableMap<String, String> HEADER_AUTH_PROJECT_RESPONSE = ImmutableMap.of("X-Subject-Token", "763fd7e197ab4e00b2e6e0a8d22a8e87", "Content-Type", "application/json");
private static final ImmutableMap<String, String> HEADER_AUTH_TOKEN_RESPONSE = ImmutableMap.of("X-Subject-Token", "3ecb5c2063904566be4b10406c0f7568", "Content-Type", "application/json");
Expand All @@ -27,6 +31,8 @@ public class KeystoneTests extends AbstractTest {
private String userName = "admin";
private String userId = "aa9f25defa6d4cafb48466df83106065";
private String projectId = "123ac695d4db400a9001b91bb3b8aa46";
private String domainId = "default";
private String domainName = "Default";
private String projectDomainId = "default";
private String password = "test";

Expand All @@ -45,7 +51,6 @@ protected Service service() {
*
* @throws Exception
*/
@Test(enabled = true)
public void authenticate_userId_password_projectId_projectDomainId_Test() throws Exception {

respondWith(JSON_AUTH_PROJECT);
Expand All @@ -65,27 +70,102 @@ public void authenticate_userId_password_projectId_projectDomainId_Test() throws
*
* @throws Exception
*/
@Test(enabled = true)
public void authenticate_userName_password_projectId_projectDomainId_Test() throws Exception {

respondWith(JSON_AUTH_PROJECT);

associateClient(OSFactory.builderV3()
.endpoint(authURL("/v3"))
.credentials(userName, password)
.credentials(userName, password, Identifier.byId(projectDomainId))
.scopeToProject(Identifier.byId(projectId), Identifier.byId(projectDomainId))
.authenticate());

assertEquals(osv3().getToken().getVersion(), AuthVersion.V3);
assertEquals(osv3().getAccess().getUser().getId(), userId);
}

/**
* authenticates with userId+password+domainId
*
* @throws Exception
*/
public void authenticate_userId_password_domainId_Test() throws Exception {

respondWith(JSON_AUTH_DOMAINID_USERID);

associateClient(OSFactory.builderV3()
.endpoint(authURL("/v3"))
.credentials(userId, password)
.scopeToDomain(Identifier.byId(domainId))
.authenticate());

assertEquals(osv3().getToken().getVersion(), AuthVersion.V3);
assertEquals(osv3().getAccess().getUser().getId(), userId);

}

/**
* authenticates with userName+password+domainId
*
* @throws Exception
*/
public void authenticate_userName_password_domainId_Test() throws Exception {

respondWith(JSON_AUTH_DOMAINID_USERNAME);

associateClient(OSFactory.builderV3()
.endpoint(authURL("/v3"))
.credentials(userId, password, Identifier.byId(domainId))
.scopeToDomain(Identifier.byId(domainId))
.authenticate());

assertEquals(osv3().getToken().getVersion(), AuthVersion.V3);
assertEquals(osv3().getAccess().getUser().getId(), userId);

}

/**
* authenticates with userId+password+domainName
*
* @throws Exception
*/
public void authenticate_userId_password_domainName_Test() throws Exception {

respondWith(JSON_AUTH_DOMAINNAME_USERID);

associateClient(OSFactory.builderV3()
.endpoint(authURL("/v3"))
.credentials(userId, password)
.scopeToDomain(Identifier.byName(domainName))
.authenticate());

assertEquals(osv3().getToken().getVersion(), AuthVersion.V3);
assertEquals(osv3().getAccess().getUser().getId(), userId);

}

/**
* try to authenticate unscoped. should return an UnsupportedOperationException saying it's not implemented yet.
*
* @throws Exception
*/
@Test(expectedExceptions={UnsupportedOperationException.class})
public void authenticate_unscoped_exception_Test() throws Exception {

respondWith(JSON_AUTH_UNSCOPED);

OSFactory.builderV3()
.endpoint(authURL("/v3"))
.credentials(userId, password)
.authenticate();

}

/**
* authenticates with a token+projectId+projectDomainId
*
* @throws Exception
*/
@Test(enabled = true)
public void auth_Token_Test() throws Exception {

respondWithHeaderAndResource(HEADER_AUTH_PROJECT_RESPONSE, 201, JSON_AUTH_PROJECT);
Expand Down Expand Up @@ -113,4 +193,5 @@ public void auth_Token_Test() throws Exception {
assertEquals(osv3().getAccess().getUser().getId(), userId);
}


}
101 changes: 101 additions & 0 deletions core-test/src/main/resources/identity.v3/authv3_domainId_userId.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"token": {
"domain": {
"id": "default",
"name": "Default"
},
"methods": ["password"],
"roles": [{
"id": "6ead57f8ae124996af8b0beb72ff1007",
"name": "admin"
}],
"expires_at": "2015-08-26T14:14:09.200971Z",
"catalog": [
{
"endpoints":[{
"region_id": "RegionOne",
"url": "http://devstack.openstack.stack:9292",
"region": "RegionOne",
"interface": "public",
"id": "6e82c8912d3f49a09df51035681d564c"
},
{
"region_id": "RegionOne",
"url": "http://devstack.openstack.stack:9292",
"region": "RegionOne",
"interface": "admin",
"id": "7e44d321ae80457abc3728fa1e6feb32"
},
{
"region_id": "RegionOne",
"url": "http://devstack.openstack.stack:9292",
"region": "RegionOne",
"interface": "internal",
"id": "c9a090a4597040849c03bc13588167f6"
}],
"type": "image",
"id": "0d56500210a24c38a3702b6825e24164",
"name": "glance"
},
{
"endpoints": [],
"type": "volumev2",
"id": "2b92e79c45254516932c633229cd0e8b",
"name": "cinderv2"
},
{
"endpoints": [
{
"region_id": "RegionOne",
"url": "http://devstack.openstack.stack:8773/",
"region": "RegionOne",
"interface": "admin",
"id": "1ce26a6fffd0424bac135b9c68055b6e"
},
{
"region_id": "RegionOne",
"url": "http://devstack.openstack.stack:8773/",
"region": "RegionOne",
"interface": "public",
"id": "98db699b9ffa4dffb027d78163aad8cc"
},
{
"region_id": "RegionOne",
"url": "http://devstack.openstack.stack:8773/",
"region": "RegionOne",
"interface": "internal",
"id": "ece52860cf1e4eb6a8fed05c47a30147"
}],
"type": "ec2",
"id": "3364a7b95c664bf89a7a8db081576364",
"name": "ec2"
},
{
"endpoints":
[], "type": "volume", "id": "511b94ce0482484ea09028091dd5e9a5", "name": "cinder"},
{"endpoints": [], "type": "compute", "id": "5b7028751ed045d79467c7845ecb8c58",
"name": "nova"}, {"endpoints": [], "type": "computev21", "id": "97e665cbada043718180c5a6316df76a",
"name": "novav21"}, {"endpoints": [{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:35357/v3",
"region": "RegionOne", "interface": "admin", "id": "185eda94de9340e58245062f75d7f80e"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:5000/v3", "region":
"RegionOne", "interface": "internal", "id": "9abd6797844d455f875af9537325cba4"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:5000/v3", "region":
"RegionOne", "interface": "public", "id": "d3b31f24e4ea40699f731e29e625c187"}],
"type": "identity", "id": "b577d8f7c7074d04a1165fcca638b600", "name": "keystone_v3x"},
{"endpoints": [{"region_id": "europe", "url": "http://devstack.openstack.stack:35357/v3",
"region": "europe", "interface": "admin", "id": "32bb2c6aea944ea6b4956eb24142d2e2"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:5000/v3", "region":
"RegionOne", "interface": "public", "id": "480ea71dc8cf4c959df1c6304be87056"},
{"region_id": "europe", "url": "http://devstack.openstack.stack:5000/v3", "region":
"europe", "interface": "public", "id": "600638643d22494fad4f30e3b22ae124"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:5000/v3", "region":
"RegionOne", "interface": "internal", "id": "8a254651925e4a3e9505c863a00c017e"},
{"region_id": "europe", "url": "http://devstack.openstack.stack:5000/v3", "region":
"europe", "interface": "internal", "id": "b93da6aaba654d8cb451ff8378d7d2a5"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:35357/v3", "region":
"RegionOne", "interface": "admin", "id": "d5f8e0da0f3345529a5fb324d735d4a3"}],
"type": "identity_v3", "id": "cd9002bbadfe495d81b5ee4c50768009", "name": "keystone_v3"}],
"extras": {}, "user": {"domain": {"id": "default", "name": "Default"}, "id":
"aa9f25defa6d4cafb48466df83106065", "name": "admin"}, "audit_ids": ["gdkPX0P8RfChxa18M4Y2Tg"],
"issued_at": "2015-08-26T13:14:09.201023Z"}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"token": {"domain": {"id": "default", "name": "Default"}, "methods":
["password"], "roles": [{"id": "6ead57f8ae124996af8b0beb72ff1007", "name":
"admin"}], "expires_at": "2015-08-26T14:14:09.335998Z", "catalog": [{"endpoints":
[{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:9292", "region":
"RegionOne", "interface": "public", "id": "6e82c8912d3f49a09df51035681d564c"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:9292", "region":
"RegionOne", "interface": "admin", "id": "7e44d321ae80457abc3728fa1e6feb32"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:9292", "region":
"RegionOne", "interface": "internal", "id": "c9a090a4597040849c03bc13588167f6"}],
"type": "image", "id": "0d56500210a24c38a3702b6825e24164", "name": "glance"},
{"endpoints": [], "type": "volumev2", "id": "2b92e79c45254516932c633229cd0e8b",
"name": "cinderv2"}, {"endpoints": [{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8773/",
"region": "RegionOne", "interface": "admin", "id": "1ce26a6fffd0424bac135b9c68055b6e"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8773/", "region":
"RegionOne", "interface": "public", "id": "98db699b9ffa4dffb027d78163aad8cc"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:8773/", "region":
"RegionOne", "interface": "internal", "id": "ece52860cf1e4eb6a8fed05c47a30147"}],
"type": "ec2", "id": "3364a7b95c664bf89a7a8db081576364", "name": "ec2"}, {"endpoints":
[], "type": "volume", "id": "511b94ce0482484ea09028091dd5e9a5", "name": "cinder"},
{"endpoints": [], "type": "compute", "id": "5b7028751ed045d79467c7845ecb8c58",
"name": "nova"}, {"endpoints": [], "type": "computev21", "id": "97e665cbada043718180c5a6316df76a",
"name": "novav21"}, {"endpoints": [{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:35357/v3",
"region": "RegionOne", "interface": "admin", "id": "185eda94de9340e58245062f75d7f80e"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:5000/v3", "region":
"RegionOne", "interface": "internal", "id": "9abd6797844d455f875af9537325cba4"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:5000/v3", "region":
"RegionOne", "interface": "public", "id": "d3b31f24e4ea40699f731e29e625c187"}],
"type": "identity", "id": "b577d8f7c7074d04a1165fcca638b600", "name": "keystone_v3x"},
{"endpoints": [{"region_id": "europe", "url": "http://devstack.openstack.stack:35357/v3",
"region": "europe", "interface": "admin", "id": "32bb2c6aea944ea6b4956eb24142d2e2"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:5000/v3", "region":
"RegionOne", "interface": "public", "id": "480ea71dc8cf4c959df1c6304be87056"},
{"region_id": "europe", "url": "http://devstack.openstack.stack:5000/v3", "region":
"europe", "interface": "public", "id": "600638643d22494fad4f30e3b22ae124"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:5000/v3", "region":
"RegionOne", "interface": "internal", "id": "8a254651925e4a3e9505c863a00c017e"},
{"region_id": "europe", "url": "http://devstack.openstack.stack:5000/v3", "region":
"europe", "interface": "internal", "id": "b93da6aaba654d8cb451ff8378d7d2a5"},
{"region_id": "RegionOne", "url": "http://devstack.openstack.stack:35357/v3", "region":
"RegionOne", "interface": "admin", "id": "d5f8e0da0f3345529a5fb324d735d4a3"}],
"type": "identity_v3", "id": "cd9002bbadfe495d81b5ee4c50768009", "name": "keystone_v3"}],
"extras": {}, "user": {"domain": {"id": "default", "name": "Default"}, "id":
"aa9f25defa6d4cafb48466df83106065", "name": "admin"}, "audit_ids": ["m5vsr2xgRuKNQezeN78VAw"],
"issued_at": "2015-08-26T13:14:09.336033Z"}
}
Loading