@@ -43,14 +43,17 @@ def test_connection_invalid_projects_and_projects(config_with_project_groups, re
43
43
)
44
44
45
45
46
- @pytest .mark .parametrize ("error_code, expected_status" , ((500 , False ), (401 , False )))
47
- def test_connection_fail_due_to_api_error (error_code , expected_status , config , mocker , requests_mock ):
46
+ def test_connection_fail_due_to_api_error (config , mocker , requests_mock ):
48
47
mocker .patch ("time.sleep" )
48
+ error_code = 401
49
49
requests_mock .get ("/api/v4/groups" , status_code = error_code )
50
50
source = SourceGitlab ()
51
51
status , msg = source .check_connection (logging .getLogger (), config )
52
52
assert status is False
53
- assert msg .startswith (f"Unable to connect to stream projects" )
53
+ assert msg == (
54
+ "Unable to connect to stream projects - Unable to refresh the `access_token`, "
55
+ "please re-authenticate in Sources > Settings."
56
+ )
54
57
55
58
56
59
def test_connection_fail_due_to_api_error_oauth (oauth_config , mocker , requests_mock ):
@@ -63,12 +66,13 @@ def test_connection_fail_due_to_api_error_oauth(oauth_config, mocker, requests_m
63
66
"refresh_token" : "new_refresh_token" ,
64
67
}
65
68
requests_mock .post ("https://gitlab.com/oauth/token" , status_code = 200 , json = test_response )
66
- requests_mock .get ("/api/v4/groups" , status_code = 500 )
69
+ requests_mock .get ("/api/v4/groups" , status_code = 401 )
67
70
source = SourceGitlab ()
68
71
status , msg = source .check_connection (logging .getLogger (), oauth_config )
69
72
assert status is False
70
- assert msg .startswith (
71
- "Unable to connect to stream projects - Unable to connect to Gitlab API with the provided credentials"
73
+ assert msg == (
74
+ "Unable to connect to stream projects - Unable to refresh the `access_token`, "
75
+ "please re-authenticate in Sources > Settings."
72
76
)
73
77
74
78
0 commit comments