-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adjust /token to create a user if one doesn't exist. Only works with password auth. * Add timezone to schedule for future-use (because we're collecting it right now..) * Gate the first time registration for password auth behind an env var.
- Loading branch information
1 parent
eb48fe6
commit e907487
Showing
13 changed files
with
122 additions
and
31 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
25 changes: 25 additions & 0 deletions
25
.../appointment/migrations/versions/2024_10_08_1615-502d0217a555_add_timezone_to_schedule.py
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"""add timezone to schedule | ||
Revision ID: 502d0217a555 | ||
Revises: 01d80f00243f | ||
Create Date: 2024-10-08 16:15:22.157158 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
from appointment.database.models import encrypted_type | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '502d0217a555' | ||
down_revision = '01d80f00243f' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.add_column('schedules', sa.Column('timezone', encrypted_type(sa.String), nullable=True, index=True)) | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_column('schedules', 'timezone') |
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 |
---|---|---|
|
@@ -87,6 +87,48 @@ def test_token(self, with_db, with_client, make_pro_subscriber): | |
) | ||
assert response.status_code == 403, response.text | ||
|
||
def test_token_creates_user(self, with_db, with_client): | ||
with with_db() as db: | ||
# Remove all subscribers | ||
for sub in db.query(models.Subscriber).all(): | ||
db.delete(sub) | ||
db.commit() | ||
|
||
email = '[email protected]' | ||
password = 'test' | ||
|
||
email2 = '[email protected]' | ||
|
||
# Disable first time registering | ||
os.environ['APP_ALLOW_FIRST_TIME_REGISTER'] = '' | ||
|
||
# Fails with improper env set | ||
response = with_client.post( | ||
'/token', | ||
data={'username': email2, 'password': password}, | ||
) | ||
assert response.status_code == 403, response.text | ||
|
||
# Enable first time registering | ||
os.environ['APP_ALLOW_FIRST_TIME_REGISTER'] = 'True' | ||
|
||
# Test non-user credentials | ||
response = with_client.post( | ||
'/token', | ||
data={'username': email, 'password': password}, | ||
) | ||
assert response.status_code == 200, response.text | ||
data = response.json() | ||
assert data['access_token'] | ||
assert data['token_type'] == 'bearer' | ||
|
||
# Test second non-user credentials | ||
response = with_client.post( | ||
'/token', | ||
data={'username': email2, 'password': password}, | ||
) | ||
assert response.status_code == 403, response.text | ||
|
||
|
||
class TestFXA: | ||
def test_fxa_login(self, with_client): | ||
|
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