-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ISSUE-16503] Fix createUser to use EntityResource (#16549)
* Fix createUser to use EntityResource * fix broken tests * Fix Tests - 3
- Loading branch information
1 parent
38e2793
commit aeb020a
Showing
9 changed files
with
103 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ | |
import static org.openmetadata.service.exception.CatalogExceptionMessage.PASSWORD_INVALID_FORMAT; | ||
import static org.openmetadata.service.exception.CatalogExceptionMessage.entityNotFound; | ||
import static org.openmetadata.service.exception.CatalogExceptionMessage.notAdmin; | ||
import static org.openmetadata.service.exception.CatalogExceptionMessage.operationNotAllowed; | ||
import static org.openmetadata.service.exception.CatalogExceptionMessage.permissionNotAllowed; | ||
import static org.openmetadata.service.resources.teams.UserResource.USER_PROTECTED_FIELDS; | ||
import static org.openmetadata.service.security.SecurityUtil.authHeaders; | ||
|
@@ -51,6 +52,8 @@ | |
import static org.openmetadata.service.util.TestUtils.INGESTION_BOT; | ||
import static org.openmetadata.service.util.TestUtils.TEST_AUTH_HEADERS; | ||
import static org.openmetadata.service.util.TestUtils.TEST_USER_NAME; | ||
import static org.openmetadata.service.util.TestUtils.USER_WITH_CREATE_HEADERS; | ||
import static org.openmetadata.service.util.TestUtils.USER_WITH_CREATE_PERMISSION_NAME; | ||
import static org.openmetadata.service.util.TestUtils.UpdateType.CHANGE_CONSOLIDATED; | ||
import static org.openmetadata.service.util.TestUtils.UpdateType.MINOR_UPDATE; | ||
import static org.openmetadata.service.util.TestUtils.UpdateType.REVERT; | ||
|
@@ -153,6 +156,14 @@ public UserResourceTest() { | |
} | ||
|
||
public void setupUsers(TestInfo test) throws HttpResponseException { | ||
CreateUser createUserWithAccess = | ||
new CreateUser() | ||
.withName(USER_WITH_CREATE_PERMISSION_NAME) | ||
.withEmail(USER_WITH_CREATE_PERMISSION_NAME + "@open-metadata.org") | ||
.withProfile(PROFILE) | ||
.withRoles(List.of(CREATE_ACCESS_ROLE.getId())) | ||
.withIsBot(false); | ||
USER_WITH_CREATE_ACCESS = createEntity(createUserWithAccess, ADMIN_AUTH_HEADERS); | ||
CreateUser create = createRequest(test).withRoles(List.of(DATA_CONSUMER_ROLE.getId())); | ||
USER1 = createEntity(create, ADMIN_AUTH_HEADERS); | ||
USER1_REF = USER1.getEntityReference(); | ||
|
@@ -317,7 +328,9 @@ void post_validAdminUser_Non_Admin_401(TestInfo test) { | |
.withIsAdmin(true); | ||
|
||
assertResponse( | ||
() -> createAndCheckEntity(create, TEST_AUTH_HEADERS), FORBIDDEN, notAdmin(TEST_USER_NAME)); | ||
() -> createAndCheckEntity(create, TEST_AUTH_HEADERS), | ||
FORBIDDEN, | ||
operationNotAllowed(TEST_USER_NAME, MetadataOperation.CREATE)); | ||
} | ||
|
||
@Test | ||
|
@@ -613,7 +626,7 @@ void patch_makeAdmin_as_nonAdmin_user_401(TestInfo test) throws HttpResponseExce | |
User user = | ||
createEntity( | ||
createRequest(test, 6).withName("test2").withEmail("[email protected]"), | ||
authHeaders("[email protected]")); | ||
USER_WITH_CREATE_HEADERS); | ||
String userJson = JsonUtils.pojoToJson(user); | ||
user.setIsAdmin(Boolean.TRUE); | ||
assertResponse( | ||
|
@@ -871,7 +884,7 @@ void put_generateToken_bot_user_200_ok() throws HttpResponseException { | |
.withEmail("[email protected]") | ||
.withRoles(List.of(ROLE1_REF.getId())) | ||
.withAuthenticationMechanism(authMechanism); | ||
User user = createEntity(create, authHeaders("[email protected]")); | ||
User user = createEntity(create, USER_WITH_CREATE_HEADERS); | ||
user = getEntity(user.getId(), "*", ADMIN_AUTH_HEADERS); | ||
assertEquals(1, user.getRoles().size()); | ||
TestUtils.put( | ||
|
@@ -922,7 +935,7 @@ void post_createUser_BasicAuth_AdminCreate_login_200_ok(TestInfo test) | |
.withCreatePasswordType(CreateUser.CreatePasswordType.ADMIN_CREATE) | ||
.withPassword("Test@1234") | ||
.withConfirmPassword("Test@1234"), | ||
authHeaders("[email protected]")); | ||
USER_WITH_CREATE_HEADERS); | ||
|
||
// jwtAuth Response should be null always | ||
user = getEntity(user.getId(), ADMIN_AUTH_HEADERS); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters