First, let’s validate that the secret was stored correctly in Google Cloud by calling a secret from your vault using the kong vault get command within the Data Plane container.
docker exec $KONNECT_DP_CONTAINER kong vault get {vault://gcp-sm-vault/test-secret}
docker exec kong-quickstart-gateway kong vault get {vault://gcp-sm-vault/test-secret}
If the vault was configured correctly, this command should return Bearer invalid.
Now, let’s validate that when we make a call to the Route associated with the AI Proxy plugin, that it is using this invalid API key stored in our secret:
curl -X POST "$KONNECT_PROXY_URL/anything" \
--no-progress-meter --fail-with-body \
-H "Accept: application/json"\
-H "Content-Type: application/json" \
--json '{
"messages": [
{
"role": "system",
"content": "You are a mathematician"
},
{
"role": "user",
"content": "What is 1+1?"
}
]
}'
You should see the following response:
curl -X POST "http://localhost:8000/anything" \
--no-progress-meter --fail-with-body \
-H "Accept: application/json"\
-H "Content-Type: application/json" \
--json '{
"messages": [
{
"role": "system",
"content": "You are a mathematician"
},
{
"role": "user",
"content": "What is 1+1?"
}
]
}'
You should see the following response:
You should get a 401 error with the message Unauthorized because we’re currently using an invalid API key.