|
17 | 17 |
|
18 | 18 | @override_settings( |
19 | 19 | COLLABORATION_SERVER_URL="http://testcollab/", |
| 20 | + CRISP_WEBSITE_ID="123", |
20 | 21 | FRONTEND_THEME="test-theme", |
21 | 22 | MEDIA_BASE_URL="http://testserver/", |
22 | 23 | SENTRY_DSN="https://sentry.test/123", |
23 | 24 | ) |
24 | | -def test_api_config_anonymous(): |
| 25 | +@pytest.mark.parametrize("is_authenticated", [False, True]) |
| 26 | +def test_api_config(is_authenticated): |
25 | 27 | """Anonymous users should be allowed to get the configuration.""" |
26 | 28 | client = APIClient() |
27 | | - response = client.get("/api/v1.0/config/") |
28 | | - assert response.status_code == HTTP_200_OK |
29 | | - assert response.json() == { |
30 | | - "COLLABORATION_SERVER_URL": "http://testcollab/", |
31 | | - "ENVIRONMENT": "test", |
32 | | - "FRONTEND_THEME": "test-theme", |
33 | | - "LANGUAGES": [["en-us", "English"], ["fr-fr", "French"], ["de-de", "German"]], |
34 | | - "LANGUAGE_CODE": "en-us", |
35 | | - "MEDIA_BASE_URL": "http://testserver/", |
36 | | - "SENTRY_DSN": "https://sentry.test/123", |
37 | | - } |
38 | 29 |
|
39 | | - |
40 | | -@override_settings( |
41 | | - COLLABORATION_SERVER_URL="http://testcollab/", |
42 | | - FRONTEND_THEME="test-theme", |
43 | | - MEDIA_BASE_URL="http://testserver/", |
44 | | - SENTRY_DSN="https://sentry.test/123", |
45 | | -) |
46 | | -def test_api_config_authenticated(): |
47 | | - """Authenticated users should be allowed to get the configuration.""" |
48 | | - user = factories.UserFactory() |
49 | | - |
50 | | - client = APIClient() |
51 | | - client.force_login(user) |
| 30 | + if is_authenticated: |
| 31 | + user = factories.UserFactory() |
| 32 | + client.force_login(user) |
52 | 33 |
|
53 | 34 | response = client.get("/api/v1.0/config/") |
54 | 35 | assert response.status_code == HTTP_200_OK |
55 | 36 | assert response.json() == { |
56 | 37 | "COLLABORATION_SERVER_URL": "http://testcollab/", |
| 38 | + "CRISP_WEBSITE_ID": "123", |
57 | 39 | "ENVIRONMENT": "test", |
58 | 40 | "FRONTEND_THEME": "test-theme", |
59 | | - "MEDIA_BASE_URL": "http://testserver/", |
60 | 41 | "LANGUAGES": [["en-us", "English"], ["fr-fr", "French"], ["de-de", "German"]], |
61 | 42 | "LANGUAGE_CODE": "en-us", |
| 43 | + "MEDIA_BASE_URL": "http://testserver/", |
62 | 44 | "SENTRY_DSN": "https://sentry.test/123", |
63 | 45 | } |
0 commit comments