@@ -10,11 +10,16 @@ class TestApp(unittest.TestCase):
1010 def setUp (self ):
1111 """Set up the test environment."""
1212 app .testing = True
13+ app .config ['BASIC_AUTH_USERNAME' ] = 'user'
14+ app .config ['BASIC_AUTH_PASSWORD' ] = 'pass'
1315 self .client = app .test_client ()
16+ self .headers = {
17+ 'Authorization' : 'Basic dXNlcjpwYXNz'
18+ }
1419
1520 def test_index_missing_parameters (self ):
1621 """Test handling missing parameters in the index route."""
17- response = self .client .get ('/' )
22+ response = self .client .get ('/' , headers = self . headers )
1823 self .assertEqual (response .status_code , 400 )
1924 self .assertIn (b"Missing parameter(s)" , response .data )
2025
@@ -30,7 +35,7 @@ def test_index_successful_response(self, mock_get_all_workflow_runs):
3035 "html_url" : "https://github.com/owner/repo/actions/runs/1234"
3136 }
3237 ]
33- response = self .client .get ('/?owner=owner&repo=repo' )
38+ response = self .client .get ('/?owner=owner&repo=repo' , headers = self . headers )
3439 self .assertEqual (response .status_code , 200 )
3540 self .assertIn (b'<Project' , response .data )
3641 self .assertIn (b'name="repo/CI"' , response .data )
@@ -50,7 +55,7 @@ def test_index_unknown_build_status(self, mock_get_all_workflow_runs):
5055 "html_url" : "https://github.com/owner/repo/actions/runs/1234"
5156 }
5257 ]
53- response = self .client .get ('/?owner=owner&repo=repo' )
58+ response = self .client .get ('/?owner=owner&repo=repo' , headers = self . headers )
5459 self .assertEqual (response .status_code , 200 )
5560 self .assertIn (b'<Project' , response .data )
5661 self .assertIn (b'lastBuildStatus="Unknown"' , response .data )
@@ -59,7 +64,7 @@ def test_index_unknown_build_status(self, mock_get_all_workflow_runs):
5964 def test_index_failed_response (self , mock_get_all_workflow_runs ):
6065 """Test failed response in the index route."""
6166 mock_get_all_workflow_runs .return_value = []
62- response = self .client .get ('/?owner=owner&repo=repo' )
67+ response = self .client .get ('/?owner=owner&repo=repo' , headers = self . headers )
6368 self .assertEqual (response .status_code , 200 )
6469 self .assertIn (b'<Projects />' , response .data )
6570
0 commit comments