Commit 6a08eca9 authored by Daniel Scholl's avatar Daniel Scholl
Browse files

Merge branch 'master' into 'fix-context-path-entitlement'

# Conflicts:
#   devops/development-pipeline.yml
parents d828676b 4173a41b
Pipeline #3445 passed with stages
in 45 minutes and 54 seconds
...@@ -170,6 +170,8 @@ The following table lists the properties that are required when you create a use ...@@ -170,6 +170,8 @@ The following table lists the properties that are required when you create a use
##### Response ##### Response
If successful, this method returns 201 response code and user object in the response body. If successful, this method returns 201 response code and user object in the response body.
If the user profile already exists, this method returns a 409 response code and an error message in the response body.
##### Example: Create a user ##### Example: Create a user
##### Request ##### Request
......
...@@ -381,15 +381,6 @@ public class EntitlementsApiTests { ...@@ -381,15 +381,6 @@ public class EntitlementsApiTests {
assertEquals(HttpStatus.SC_BAD_REQUEST, response.getStatus()); assertEquals(HttpStatus.SC_BAD_REQUEST, response.getStatus());
} }
@Test
public void givenValidIntegrationTesterAndUserInfoExists_whenCallCreateProfile_thenBadRequest() throws Exception {
String path = "profile";
String json = TestUserInfoData.getJsonFromTestFile("test_userinfo_OneTenantItem");
ClientResponse response = TestUtils.send(path, "POST",
TestUtils.getHeaders(), json, "");
assertEquals(HttpStatus.SC_BAD_REQUEST, response.getStatus());
}
@Test @Test
public void givenAnonymous_whenCallDeleteProfile_thenForbidden() throws Exception { public void givenAnonymous_whenCallDeleteProfile_thenForbidden() throws Exception {
String path = "profile/" + TEST_REGULAR_USER_ID; String path = "profile/" + TEST_REGULAR_USER_ID;
...@@ -538,7 +529,7 @@ public class EntitlementsApiTests { ...@@ -538,7 +529,7 @@ public class EntitlementsApiTests {
} }
@Test @Test
public void givenValidIntegrationTesterAndServicePrincipalExists_whenCallCreateProfile_thenBadRequest() throws Exception { public void givenValidIntegrationTesterAndServicePrincipalExists_whenCallCreateProfile_thenConflict() throws Exception {
String path = "profile"; String path = "profile";
if (isSetupEnabled()) { if (isSetupEnabled()) {
setUp(TEST_SP_ID, TestType.DELETE); setUp(TEST_SP_ID, TestType.DELETE);
...@@ -548,7 +539,7 @@ public class EntitlementsApiTests { ...@@ -548,7 +539,7 @@ public class EntitlementsApiTests {
ClientResponse response = TestUtils.send(path, "POST", ClientResponse response = TestUtils.send(path, "POST",
TestUtils.getHeaders(), json, ""); TestUtils.getHeaders(), json, "");
assertEquals(HttpStatus.SC_BAD_REQUEST, response.getStatus()); assertEquals(HttpStatus.SC_CONFLICT, response.getStatus());
if (isTeardownEnabled()) { if (isTeardownEnabled()) {
tearDown(TEST_SP_ID, TestType.DELETE); tearDown(TEST_SP_ID, TestType.DELETE);
......
...@@ -51,6 +51,7 @@ public class EntitlementsAzure ...@@ -51,6 +51,7 @@ public class EntitlementsAzure
private static final String SC_BAD_REQUEST_REASON = "bad request"; private static final String SC_BAD_REQUEST_REASON = "bad request";
private static final String SC_NOT_FOUND_REASON = "not found"; private static final String SC_NOT_FOUND_REASON = "not found";
private static final String SC_FORBIDDEN_REASON = "forbidden"; private static final String SC_FORBIDDEN_REASON = "forbidden";
private static final String SC_CONFLICT_REASON = "resource already existed";
protected enum UserType { protected enum UserType {
REGULAR_USER, REGULAR_USER,
...@@ -316,7 +317,7 @@ public class EntitlementsAzure ...@@ -316,7 +317,7 @@ public class EntitlementsAzure
userInfoRepository.create(userInfoDoc); userInfoRepository.create(userInfoDoc);
return userInfoDoc; return userInfoDoc;
} else } else
throw new AppException(HttpStatus.SC_BAD_REQUEST, SC_BAD_REQUEST_REASON, String.format("user profile already exists for '%s'",userInfoDoc.getUid())); throw new AppException(HttpStatus.SC_CONFLICT, SC_CONFLICT_REASON, String.format("user profile already exists for '%s'",userInfoDoc.getUid()));
} }
/** /**
......
...@@ -206,7 +206,7 @@ public class EntitlementsAzureTests { ...@@ -206,7 +206,7 @@ public class EntitlementsAzureTests {
} }
@Test @Test
public void givenServicePrincipalInJwtAndProfileExists_whenCreateProfile_thenBadRequest() { public void givenServicePrincipalInJwtAndProfileExists_whenCreateProfile_thenConflict() {
setField(sut, TestUtils.SERVICE_DOMAIN_NAME, TestUtils.getDomain()); setField(sut, TestUtils.SERVICE_DOMAIN_NAME, TestUtils.getDomain());
//serviceprincipal in JWT //serviceprincipal in JWT
createAADUserPrincipalSetSecurityContext(TestUtils.APPID, TestUtils.getAppId(), TestUtils.OID, TestUtils.getOid()); createAADUserPrincipalSetSecurityContext(TestUtils.APPID, TestUtils.getAppId(), TestUtils.OID, TestUtils.getOid());
...@@ -222,7 +222,7 @@ public class EntitlementsAzureTests { ...@@ -222,7 +222,7 @@ public class EntitlementsAzureTests {
sut.createUserInfo(userInfoDoc); sut.createUserInfo(userInfoDoc);
} catch (AppException ae) } catch (AppException ae)
{ {
assertEquals(HttpStatus.SC_BAD_REQUEST, ae.getError().getCode()); assertEquals(HttpStatus.SC_CONFLICT, ae.getError().getCode());
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment