enable change password
This commit is contained in:
@@ -15,7 +15,7 @@ from sentence_api.store import BoundaryStore
|
||||
VIDEO_HASH = "a" * 64
|
||||
|
||||
|
||||
def make_client(tmp_path):
|
||||
def make_client(tmp_path, admin_api_key=""):
|
||||
index_path = tmp_path / "boundaries.json"
|
||||
index_path.write_text(
|
||||
json.dumps({
|
||||
@@ -36,6 +36,7 @@ def make_client(tmp_path):
|
||||
Settings.from_env(),
|
||||
data_dir=tmp_path / "data",
|
||||
legacy_boundaries_file=index_path,
|
||||
admin_api_key=admin_api_key,
|
||||
)
|
||||
settings.ensure_directories()
|
||||
client = TestClient(
|
||||
@@ -116,6 +117,27 @@ def test_adhoc_audio_boundaries_require_login(tmp_path):
|
||||
assert response.status_code == 401
|
||||
|
||||
|
||||
def test_admin_can_reset_sso_user_password(tmp_path):
|
||||
client = make_client(tmp_path, admin_api_key="test-admin-key")
|
||||
repository = client.app.state.video_repository
|
||||
created = repository.create_sso_user(
|
||||
username="bobcoc",
|
||||
nickname="Bob",
|
||||
sso_provider="d1kt",
|
||||
)
|
||||
assert created is not None
|
||||
assert repository.authenticate_user("bobcoc", "anything-123") is None
|
||||
|
||||
response = client.put(
|
||||
"/api/v1/admin/users/password",
|
||||
json={"username": "bobcoc", "password": "new-password-123"},
|
||||
headers={"X-Admin-Key": "test-admin-key"},
|
||||
)
|
||||
|
||||
assert response.status_code == 204
|
||||
assert repository.authenticate_user("bobcoc", "new-password-123") is not None
|
||||
|
||||
|
||||
def test_sentence_explanation_requires_login(tmp_path):
|
||||
index_path = tmp_path / "boundaries.json"
|
||||
index_path.write_text("{}", encoding="utf-8")
|
||||
|
||||
Reference in New Issue
Block a user