You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I want to run HTTP Requests inside a KIND cluster using Terratest without creating a Port-Forward first. With a simple GET request this works easily using something like
However when doing a POST Request with some JSON data this fails, although the request works when I do this manually in kubectl.
To Reproduce
I am using ArgoCD here, but I guess this should be the same for all services that unmarshal some JSON they receive from curl. I reckon this has to do with the way the JSON string is passed through Go until it reaches kubectl...
While this works
k run curl-argocd-session-token --image alpine/curl --rm -it --restart=Never -- curl -X POST -H "Content-Type: application/json", -iLk argocd-server.argocd.svc.cluster.local:443/api/v1/session -d "{\"username\":\"test-user\",\"password\":\"somePassword\"}"
Output: "{\"username\":\"test-user\",\"password\":\"somePassword\"}" Terratest Output in Console: Running command kubectl with args [--namespace argocd run curl-argocd-session-token --image alpine/curl --rm -it --restart=Never -- curl -X POST -H Content-Type: application/json -iLk argocd-server.argocd.svc.cluster.local:443/api/v1/session -d "{\"username\":\"test-user\",\"password\":\"somePassword\"}"] Error Message: {"error":"json: cannot unmarshal string into Go value of type session.SessionCreateRequest","code":3,"message":"json: cannot unmarshal string into Go value of type session.SessionCreateRequest"}
Expected behavior
The POST Request using a Curl POD works the same as if I would execute the command from a local shell using Kubectl
Versions
Terratest version: v0.43.13
Environment details (Ubuntu 20.04, Windows 10, etc.): OS X newest version
Additional context
I also tried other ways to format the String, e.g. by using backticks or even more obscure ways. No luck. I only see the option to create a Port-Forwarding or start the tests in a Docker Container inside the K8s Cluster
The text was updated successfully, but these errors were encountered:
Describe the bug
I want to run HTTP Requests inside a KIND cluster using Terratest without creating a Port-Forward first. With a simple GET request this works easily using something like
However when doing a POST Request with some JSON data this fails, although the request works when I do this manually in kubectl.
To Reproduce
I am using ArgoCD here, but I guess this should be the same for all services that unmarshal some JSON they receive from curl. I reckon this has to do with the way the JSON string is passed through Go until it reaches kubectl...
While this works
This doesn't
The following happens depending on what I format in Go
1. Input
Output:
{\"username\":\"test-user\",\"password\":\"somePassword\"}
Terratest Output in Console:
Running command kubectl with args [--namespace argocd run curl-argocd-session-token --image alpine/curl --rm -it --restart=Never -- curl -X POST -H Content-Type: application/json -iLk argocd-server.argocd.svc.cluster.local:443/api/v1/session -d {\"username\":\"test-user\",\"password\":\"somePassword\"}]
Error Message:
{"error":"invalid character '\\\\' looking for beginning of object key string","code":3,"message":"invalid character '\\\\' looking for beginning of object key string"}
2. Input
Output:
"{\"username\":\"test-user\",\"password\":\"somePassword\"}"
Terratest Output in Console:
Running command kubectl with args [--namespace argocd run curl-argocd-session-token --image alpine/curl --rm -it --restart=Never -- curl -X POST -H Content-Type: application/json -iLk argocd-server.argocd.svc.cluster.local:443/api/v1/session -d "{\"username\":\"test-user\",\"password\":\"somePassword\"}"]
Error Message:
{"error":"json: cannot unmarshal string into Go value of type session.SessionCreateRequest","code":3,"message":"json: cannot unmarshal string into Go value of type session.SessionCreateRequest"}
Expected behavior
The POST Request using a Curl POD works the same as if I would execute the command from a local shell using Kubectl
Versions
Additional context
I also tried other ways to format the String, e.g. by using backticks or even more obscure ways. No luck. I only see the option to create a Port-Forwarding or start the tests in a Docker Container inside the K8s Cluster
The text was updated successfully, but these errors were encountered: