|
24 | 24 | SCOPES_TO_URL_BASE_PATH, |
25 | 25 | ) |
26 | 26 |
|
| 27 | +import os |
| 28 | + |
27 | 29 | from hhs_oauth_server.settings.base import MOCK_FHIR_ENDPOINT_HOSTNAME |
28 | 30 |
|
29 | 31 |
|
@@ -576,16 +578,15 @@ def test_delete_token_success(self): |
576 | 578 |
|
577 | 579 | # This assertion is incorrectly crafted - it actually requires a local server started |
578 | 580 | # so that the fhir fetch data is called and hence generate cert file not found error. |
579 | | - # TODO: refactor test to not depend on a server up and running. |
580 | | - |
581 | | - # Post Django 2.2: An OSError exception is expected when trying to reach the |
582 | | - # backend FHIR server and proves authentication worked. |
583 | | - with self.assertRaisesRegexp( |
584 | | - OSError, 'Could not find the TLS certificate file' |
585 | | - ): |
586 | | - response = self.client.get( |
587 | | - '/v1/fhir/Patient', headers={'authorization': 'Bearer ' + anna_token.token} |
588 | | - ) |
| 581 | + # 20251120 This test is now gated on a variable; if the variable does not exist, or |
| 582 | + # is not set, the test will run. This is the desired behavior. |
| 583 | + if os.getenv("RUNNING_IN_LOCAL_STACK", None) != "true": |
| 584 | + with self.assertRaisesRegexp( |
| 585 | + OSError, 'Could not find the TLS certificate file' |
| 586 | + ): |
| 587 | + response = self.client.get( |
| 588 | + '/v1/fhir/Patient', headers={'authorization': 'Bearer ' + anna_token.token} |
| 589 | + ) |
589 | 590 |
|
590 | 591 | bob_tkn = self._create_test_token(bob, bob_application) |
591 | 592 | self.assertTrue( |
@@ -638,24 +639,26 @@ def test_delete_token_success(self): |
638 | 639 |
|
639 | 640 | # Post Django 2.2: An OSError exception is expected when trying to reach the |
640 | 641 | # backend FHIR server and proves authentication worked. |
641 | | - with self.assertRaisesRegexp( |
642 | | - OSError, 'Could not find the TLS certificate file' |
643 | | - ): |
644 | | - response = self.client.get( |
645 | | - '/v1/fhir/Patient', headers={'authorization': 'Bearer ' + bob_tkn.token} |
646 | | - ) |
| 642 | + if os.getenv("RUNNING_IN_LOCAL_STACK", None) != "true": |
| 643 | + with self.assertRaisesRegexp( |
| 644 | + OSError, 'Could not find the TLS certificate file' |
| 645 | + ): |
| 646 | + response = self.client.get( |
| 647 | + '/v1/fhir/Patient', headers={'authorization': 'Bearer ' + bob_tkn.token} |
| 648 | + ) |
647 | 649 |
|
648 | 650 | next_tkn = self._create_test_token(anna, anna_application) |
649 | 651 |
|
650 | 652 | # Post Django 2.2: An OSError exception is expected when trying to reach the |
651 | 653 | # backend FHIR server and proves authentication worked. |
652 | | - with self.assertRaisesRegexp( |
653 | | - OSError, 'Could not find the TLS certificate file' |
654 | | - ): |
655 | | - response = self.client.get( |
656 | | - '/v1/fhir/Patient', |
657 | | - headers={'authorization': 'Bearer ' + next_tkn.token}, |
658 | | - ) |
| 654 | + if os.getenv("RUNNING_IN_LOCAL_STACK", None) != "true": |
| 655 | + with self.assertRaisesRegexp( |
| 656 | + OSError, 'Could not find the TLS certificate file' |
| 657 | + ): |
| 658 | + response = self.client.get( |
| 659 | + '/v1/fhir/Patient', |
| 660 | + headers={'authorization': 'Bearer ' + next_tkn.token}, |
| 661 | + ) |
659 | 662 |
|
660 | 663 | # self.assertEqual(next_tkn.token, tkn.token) |
661 | 664 | self.assertTrue( |
|
0 commit comments