@@ -122,65 +122,6 @@ def test_key_hook(self, mock_requests):
122122 response = self .client .get (url , HTTP_X_DEIS_BUILDER_AUTH = settings .BUILDER_KEY )
123123 self .assertEqual (response .status_code , 404 )
124124
125- def test_push_hook (self , mock_requests ):
126- """Test creating a Push via the API"""
127- app_id = self .create_app ()
128-
129- # prepare a push body
130- body = {
131- 'sha' : 'df1e628f2244b73f9cdf944f880a2b3470a122f4' ,
132- 'fingerprint' : '88:25:ed:67:56:91:3d:c6:1b:7f:42:c6:9b:41:24:80' ,
133- 'receive_user' : 'autotest' ,
134- 'receive_repo' : '{app_id}' .format (** locals ()),
135- 'ssh_connection' : '10.0.1.10 50337 172.17.0.143 22' ,
136- 'ssh_original_command' : "git-receive-pack '{app_id}.git'" .format (** locals ()),
137- }
138- # post a request without the auth header
139- url = "/v2/hooks/push" .format (** locals ())
140- response = self .client .post (url , body )
141- self .assertEqual (response .status_code , 403 )
142- # now try with the builder key in the special auth header
143- response = self .client .post (url , body ,
144- HTTP_X_DEIS_BUILDER_AUTH = settings .BUILDER_KEY )
145- self .assertEqual (response .status_code , 201 , response .data )
146- for k in ('owner' , 'app' , 'sha' , 'fingerprint' , 'receive_repo' , 'receive_user' ,
147- 'ssh_connection' , 'ssh_original_command' ):
148- self .assertIn (k , response .data )
149-
150- def test_push_abuse (self , mock_requests ):
151- """Test a user pushing to an unauthorized application"""
152- # create a legit app as "autotest"
153- app_id = self .create_app ()
154-
155- # register an evil user
156- username , password = 'eviluser' , 'password'
157- first_name , last_name = 'Evil' , 'User'
158- email = 'evil@deis.io'
159- submit = {
160- 'username' : username ,
161- 'password' : password ,
162- 'first_name' : first_name ,
163- 'last_name' : last_name ,
164- 'email' : email ,
165- }
166- url = '/v2/auth/register'
167- response = self .client .post (url , submit )
168- self .assertEqual (response .status_code , 201 , response .data )
169- # prepare a push body that simulates a git push
170- body = {
171- 'sha' : 'df1e628f2244b73f9cdf944f880a2b3470a122f4' ,
172- 'fingerprint' : '88:25:ed:67:56:91:3d:c6:1b:7f:42:c6:9b:41:24:99' ,
173- 'receive_user' : 'eviluser' ,
174- 'receive_repo' : '{app_id}' .format (** locals ()),
175- 'ssh_connection' : '10.0.1.10 50337 172.17.0.143 22' ,
176- 'ssh_original_command' : "git-receive-pack '{app_id}.git'" .format (** locals ()),
177- }
178- # try to push as "eviluser"
179- url = "/v2/hooks/push" .format (** locals ())
180- response = self .client .post (url , body ,
181- HTTP_X_DEIS_BUILDER_AUTH = settings .BUILDER_KEY )
182- self .assertEqual (response .status_code , 403 )
183-
184125 def test_build_hook (self , mock_requests ):
185126 """Test creating a Build via an API Hook"""
186127 app_id = self .create_app ()
0 commit comments