Skip to content

Commit

Permalink
Add tests for port forwarding API endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Seese <[email protected]>
  • Loading branch information
mikeseese committed Apr 5, 2024
1 parent 8190ebc commit 098259e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions bats/tests/k8s/wasm.bats
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,21 @@ EOF
assert_success
assert_output "Hello world from Spin!"
}

@test 'fail to connect to the service on localhost without port forwarding' {
run try curl --silent --fail "http://localhost:8080/hello"
assert_failure
}

@test 'connect to the service on localhost with port forwarding' {
rdctl api -X POST -b '{ "namespace": "default", "service": "hello-spin", "k8sPort": 80, "hostPort": 8080 }' port_forwarding
run try curl --silent --fail "http://localhost:8080/hello"
assert_success
assert_output "Hello world from Spin!"
}

@test 'fail to connect to the service on localhost after removing port forwarding' {
rdctl api -X DELETE "port_forwarding?namespace=default&service=hello-spin&k8sPort=80"
run try curl --silent --fail "http://localhost:8080/hello"
assert_failure
}

0 comments on commit 098259e

Please sign in to comment.