@@ -192,103 +192,3 @@ pub async fn start_webhook_server(
192192
193193 Ok ( ( ) )
194194}
195-
196- #[ cfg( test) ]
197- mod tests {
198- use super :: * ;
199- use axum:: body:: Body ;
200- use axum:: http:: Request ;
201- use tower:: ServiceExt ;
202-
203- // Helper to create a test handler
204- async fn create_test_handler ( ) -> GenericCloudHandler {
205- // For unit tests, we'll need a mock or test handler
206- // This would require mocking infrastructure
207- // For now, these tests are commented out - use integration tests instead
208- unimplemented ! ( "Use integration tests in integration-tests/tests/operator.rs" )
209- }
210-
211- #[ tokio:: test]
212- #[ ignore] // Requires test infrastructure setup
213- async fn test_health_endpoint ( ) {
214- let handler = create_test_handler ( ) . await ;
215- let app = create_webhook_router ( handler) ;
216-
217- let response = app
218- . oneshot (
219- Request :: builder ( )
220- . uri ( "/health" )
221- . method ( "GET" )
222- . body ( Body :: empty ( ) )
223- . unwrap ( ) ,
224- )
225- . await
226- . unwrap ( ) ;
227-
228- assert_eq ! ( response. status( ) , StatusCode :: OK ) ;
229- }
230-
231- #[ tokio:: test]
232- #[ ignore] // Requires test infrastructure setup
233- async fn test_validate_endpoint ( ) {
234- let handler = create_test_handler ( ) . await ;
235- let app = create_webhook_router ( handler) ;
236-
237- let admission_review = serde_json:: json!( {
238- "apiVersion" : "admission.k8s.io/v1" ,
239- "kind" : "AdmissionReview" ,
240- "request" : {
241- "uid" : "test-uid-123" ,
242- "kind" : {
243- "group" : "infraweave.io" ,
244- "version" : "v1" ,
245- "kind" : "S3Bucket"
246- } ,
247- "resource" : {
248- "group" : "infraweave.io" ,
249- "version" : "v1" ,
250- "resource" : "s3buckets"
251- } ,
252- "operation" : "CREATE" ,
253- "object" : {
254- "apiVersion" : "infraweave.io/v1" ,
255- "kind" : "S3Bucket" ,
256- "metadata" : {
257- "name" : "test-bucket" ,
258- "namespace" : "default"
259- } ,
260- "spec" : {
261- "moduleVersion" : "1.0.0" ,
262- "region" : "us-west-2" ,
263- "variables" : {
264- "bucketName" : "my-test-bucket"
265- }
266- }
267- }
268- }
269- } ) ;
270-
271- let response = app
272- . oneshot (
273- Request :: builder ( )
274- . uri ( "/validate" )
275- . method ( "POST" )
276- . header ( "content-type" , "application/json" )
277- . body ( Body :: from (
278- serde_json:: to_string ( & admission_review) . unwrap ( ) ,
279- ) )
280- . unwrap ( ) ,
281- )
282- . await
283- . unwrap ( ) ;
284-
285- assert_eq ! ( response. status( ) , StatusCode :: OK ) ;
286-
287- let body = axum:: body:: to_bytes ( response. into_body ( ) , usize:: MAX )
288- . await
289- . unwrap ( ) ;
290- let review_response: AdmissionReviewResponse = serde_json:: from_slice ( & body) . unwrap ( ) ;
291-
292- assert_eq ! ( review_response. response. uid, "test-uid-123" ) ;
293- }
294- }
0 commit comments