|
7 | 7 | """ |
8 | 8 |
|
9 | 9 | from django.test import TestCase |
10 | | - |
| 10 | +from django.test.client import Client |
| 11 | +from django.urls import reverse |
| 12 | +import json |
11 | 13 | from apps.logging.sensitive_logging_filters import mask_mbi |
12 | 14 |
|
13 | 15 |
|
@@ -314,3 +316,42 @@ def test_mbi_match(self): |
314 | 316 | self.assertNotIn('***MBI***', masked_mbi_lowercase_text) |
315 | 317 | self.assertIn(mbi_value, masked_uppercase_text) |
316 | 318 | self.assertIn(mbi_value.lower(), masked_mbi_lowercase_text) |
| 319 | + |
| 320 | + |
| 321 | +class SmartConfigurationTestCase(TestCase): |
| 322 | + |
| 323 | + def setUp(self): |
| 324 | + self.client = Client() |
| 325 | + self.smart_url = reverse('smart_configuration') |
| 326 | + |
| 327 | + def test_valid_smart_config_response(self): |
| 328 | + CAPABILITIES = [ |
| 329 | + "client-confidential-symmetric", |
| 330 | + "context-standalone-patient", |
| 331 | + "launch-standalone", |
| 332 | + "permission-offline", |
| 333 | + "permission-patient", |
| 334 | + "permission-v1", |
| 335 | + "permission-v2", |
| 336 | + "authorize-post" |
| 337 | + ] |
| 338 | + |
| 339 | + SCOPES_SUPPORTED = [ |
| 340 | + "openid", |
| 341 | + "profile", |
| 342 | + "launch/patient", |
| 343 | + "patient/Patient.read", |
| 344 | + "patient/ExplanationOfBenefit.read", |
| 345 | + "patient/Coverage.read", |
| 346 | + "patient/Patient.rs", |
| 347 | + "patient/ExplanationOfBenefit.rs", |
| 348 | + "patient/Coverage.rs", |
| 349 | + ] |
| 350 | + response = self.client.get(self.smart_url) |
| 351 | + response_json = response.json() |
| 352 | + response_content = response.content |
| 353 | + response_content = str(response_content, encoding='utf8') |
| 354 | + self.assertEqual(response.status_code, 200) |
| 355 | + self.assertEqual(type(json.loads(response_content)), type({})) |
| 356 | + self.assertCountEqual(response_json['capabilities'], CAPABILITIES) |
| 357 | + self.assertCountEqual(response_json['scopes_supported'], SCOPES_SUPPORTED) |
0 commit comments