28
28
29
29
30
30
class TestGetAssetByName :
31
- def test_get_asset_by_name (self , client , session ):
31
+ def test_get_asset_by_name (self , test_client , session ):
32
32
asset = AssetModel (
33
33
id = 1 ,
34
34
name = "test_get_asset_by_name" ,
@@ -44,7 +44,7 @@ def test_get_asset_by_name(self, client, session):
44
44
session .add_all ([asset , asset_active ])
45
45
session .commit ()
46
46
47
- response = client .get ("/execution/assets/by-name" , params = {"name" : "test_get_asset_by_name" })
47
+ response = test_client .get ("/execution/assets/by-name" , params = {"name" : "test_get_asset_by_name" })
48
48
49
49
assert response .status_code == 200
50
50
assert response .json () == {
@@ -58,8 +58,8 @@ def test_get_asset_by_name(self, client, session):
58
58
session .delete (asset_active )
59
59
session .commit ()
60
60
61
- def test_asset_name_not_found (self , client ):
62
- response = client .get ("/execution/assets/by-name" , params = {"name" : "non_existent" })
61
+ def test_asset_name_not_found (self , test_client ):
62
+ response = test_client .get ("/execution/assets/by-name" , params = {"name" : "non_existent" })
63
63
64
64
assert response .status_code == 404
65
65
assert response .json () == {
@@ -69,9 +69,21 @@ def test_asset_name_not_found(self, client):
69
69
}
70
70
}
71
71
72
+ def test_get_config_should_response_401 (self , unauthenticated_test_client ):
73
+ response = unauthenticated_test_client .get (
74
+ "/execution/assets/by-name" , params = {"name" : "test_get_asset_by_name" }
75
+ )
76
+ assert response .status_code == 401
77
+
78
+ def test_get_config_should_response_403 (self , unauthorized_test_client ):
79
+ response = unauthorized_test_client .get (
80
+ "/execution/assets/by-name" , params = {"name" : "test_get_asset_by_name" }
81
+ )
82
+ assert response .status_code == 403
83
+
72
84
73
85
class TestGetAssetByUri :
74
- def test_get_asset_by_uri (self , client , session ):
86
+ def test_get_asset_by_uri (self , test_client , session ):
75
87
asset = AssetModel (
76
88
name = "test_get_asset_by_uri" ,
77
89
uri = "s3://bucket/key" ,
@@ -84,7 +96,7 @@ def test_get_asset_by_uri(self, client, session):
84
96
session .add_all ([asset , asset_active ])
85
97
session .commit ()
86
98
87
- response = client .get ("/execution/assets/by-uri" , params = {"uri" : "s3://bucket/key" })
99
+ response = test_client .get ("/execution/assets/by-uri" , params = {"uri" : "s3://bucket/key" })
88
100
89
101
assert response .status_code == 200
90
102
assert response .json () == {
@@ -98,8 +110,8 @@ def test_get_asset_by_uri(self, client, session):
98
110
session .delete (asset_active )
99
111
session .commit ()
100
112
101
- def test_asset_uri_not_found (self , client ):
102
- response = client .get ("/execution/assets/by-uri" , params = {"uri" : "non_existent" })
113
+ def test_asset_uri_not_found (self , test_client ):
114
+ response = test_client .get ("/execution/assets/by-uri" , params = {"uri" : "non_existent" })
103
115
104
116
assert response .status_code == 404
105
117
assert response .json () == {
@@ -108,3 +120,13 @@ def test_asset_uri_not_found(self, client):
108
120
"reason" : "not_found" ,
109
121
}
110
122
}
123
+
124
+ def test_get_config_should_response_401 (self , unauthenticated_test_client ):
125
+ response = unauthenticated_test_client .get (
126
+ "/execution/assets/by-uri" , params = {"uri" : "s3://bucket/key" }
127
+ )
128
+ assert response .status_code == 401
129
+
130
+ def test_get_config_should_response_403 (self , unauthorized_test_client ):
131
+ response = unauthorized_test_client .get ("/execution/assets/by-uri" , params = {"uri" : "s3://bucket/key" })
132
+ assert response .status_code == 403
0 commit comments