Skip to content

Commit

Permalink
1832 error parent user creation (#1834)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Sachs <adam@Adams-MBP.hsd1.ma.comcast.net>
  • Loading branch information
adamsachs and Adam Sachs authored Nov 21, 2022
1 parent 0d36ef7 commit ba9aad0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ The types of changes are:

## [Unreleased](https://github.com/ethyca/fides/compare/2.1.0...main)

### Added
* Add authenticated privacy request route. [#1819](https://github.com/ethyca/fides/pull/1819)

### Fixed
* Fix error in parent user creation seeding. [#1832](https://github.com/ethyca/fides/issues/1832)

### Docs

* Remove documentation about no-longer used connection string override [#1824](https://github.com/ethyca/fides/pull/1824)
Expand All @@ -39,7 +45,6 @@ The types of changes are:
* Privacy-Center-Cypress workflow for CI checks of the Privacy Center. [#1722](https://github.com/ethyca/fides/pull/1722)
* Privacy Center `fides-consent.js` script for accessing consent on external pages. [Details](/clients/privacy-center/packages/fides-consent/README.md)
* Erasure support for Twilio Conversations API [#1673](https://github.com/ethyca/fides/pull/1673)
* Add authenticated privacy request route. [#1819](https://github.com/ethyca/fides/pull/1819)

### Changed

Expand Down
2 changes: 2 additions & 0 deletions src/fides/api/ctl/database/seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def create_or_update_parent_user() -> None:
log.info("Updating parent user")
user.update_password(db_session, CONFIG.security.parent_server_password)
return
# clean exit if parent user already exists and credentials match
return

log.info("Creating parent user")
user = FidesUser.create(
Expand Down
6 changes: 5 additions & 1 deletion src/fides/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,11 @@ async def setup_server() -> None:

await configure_db(CONFIG.database.sync_database_uri)

create_or_update_parent_user()
try:
create_or_update_parent_user()
except Exception as e:
log.error(f"Error creating parent user: {str(e)}")
raise FidesError(f"Error creating parent user: {str(e)}")

log.info("Validating SaaS connector templates...")
try:
Expand Down
22 changes: 22 additions & 0 deletions tests/ctl/api/test_seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,28 @@ def test_create_or_update_parent_user(db):
user.delete(db)


@pytest.mark.usefixtures("parent_server_config")
def test_create_or_update_parent_user_called_twice(db):
"""
Ensure seed method can be called twice with same parent user config,
since this is effectively what happens on server restart.
"""
seed.create_or_update_parent_user()
user = FidesUser.get_by(
db, field="username", value=CONFIG.security.parent_server_username
)

assert user is not None

seed.create_or_update_parent_user()
user = FidesUser.get_by(
db, field="username", value=CONFIG.security.parent_server_username
)

assert user is not None
user.delete(db)


@pytest.mark.usefixtures("parent_server_config")
def test_create_or_update_parent_user_change_password(db):
user = FidesUser.create(
Expand Down

0 comments on commit ba9aad0

Please sign in to comment.