@@ -118,3 +118,31 @@ def test_build_hook(self):
118118 self .assertIn ('release' , response .data )
119119 self .assertIn ('version' , response .data ['release' ])
120120 self .assertIn ('domains' , response .data )
121+
122+ def test_config_hook (self ):
123+ """Test reading Config via an API Hook"""
124+ url = '/api/apps'
125+ body = {'cluster' : 'autotest' }
126+ response = self .client .post (url , json .dumps (body ), content_type = 'application/json' )
127+ self .assertEqual (response .status_code , 201 )
128+ app_id = response .data ['id' ]
129+ url = '/api/apps/{app_id}/config' .format (** locals ())
130+ response = self .client .get (url )
131+ self .assertEqual (response .status_code , 200 )
132+ self .assertIn ('values' , response .data )
133+ values = response .data ['values' ]
134+ # prepare the config hook
135+ config = {'username' : 'autotest' , 'app' : app_id }
136+ url = '/api/hooks/config' .format (** locals ())
137+ body = {'receive_user' : 'autotest' ,
138+ 'receive_repo' : app_id }
139+ # post without a session
140+ self .assertIsNone (self .client .logout ())
141+ response = self .client .post (url , json .dumps (body ), content_type = 'application/json' )
142+ self .assertEqual (response .status_code , 403 )
143+ # post with the builder auth key
144+ response = self .client .post (url , json .dumps (body ), content_type = 'application/json' ,
145+ HTTP_X_DEIS_BUILDER_AUTH = settings .BUILDER_KEY )
146+ self .assertEqual (response .status_code , 200 )
147+ self .assertIn ('values' , response .data )
148+ self .assertEqual (values , response .data ['values' ])
0 commit comments