refactor (controller): Use a grpc server for the grpc-gateway (#1576)

* refactor (controller): Use a grpc server for the grpc-gateway

This starts a grpc server for the grpc-gateway.  The new gateway
server uses an in-memory listener which also supports "dialing", so
the http proxy can connect to the in-memory listener.

This change allows us to use all grpc server features and was in part
motivated by a need for an interceptor of inbound requests.  With that
said, having a "proper" grpc server for the gateway will provide a lot
more flexibility and capabilities moving forward.

The request context will still be verified via middleware in the
http proxy (see wrapHandlerWithCommonFuncs).  This verified context
will be serialized into a protobuf and sent along to the grpc-gateway
via metadata where an interceptor will add the verified request
info to the request's context (see requestCtxInterceptor).  The
interceptor will verify the serialized request info via a shared ticket
with it's companion in-memory http proxy.  FYI: the ticket is simply
random base62 string (see db.NewPrivateId).

This change also necessitated a minor change to services.  We need to
return an empty response instead of nil, nil when there are no errors
and the response is empty.

* refactor (handlers): Rename gRPC Gateway filter

Originally, this was called an OutgoingInterceptor, which is an
unfortunate name since it's not an interceptor.  Now that we're
refactoring the gateway stuff and have proper interceptors, renaming
this should remove ambiguity

* refactor: Rework how 204 with empty msg is handled

Recent changes to grpc gateway has necessitated a change to how
204s are handled by the gateway

* tests (bats): Check status codes for delete operations
This commit is contained in:
Jim authored and GitHub committed 2021-10-19 17:21:41 -04:00
1 parent 55ba24499a
commit 769416c2ff
50 files changed
+2625 -370

No files matched your search

@@ -22,3 +22,11 @@ function strip_all() {
echo "$1" | tr -d '"' | tr -d '\'\'
}
function has_status_code() {
local json=$1
local code=$2
if [ echo "$json"|jq -c ".status_code == $code" ]; then
return 1
fi
}
+1
View File
@@ -59,6 +59,7 @@ export NEW_GROUP='test'
local gid=$(group_id $NEW_GROUP)
run delete_group $gid
echo "$output"
run has_status_code "$output" "204"
[ "$status" -eq 0 ]
}
@@ -44,6 +44,7 @@ export NEW_HOST_CATALOG='test'
local hid=$(host_catalog_id $NEW_HOST_CATALOG $DEFAULT_P_ID)
run delete_host_catalog $hid
echo "$output"
run has_status_code "$output" "204"
[ "$status" -eq 0 ]
}
@@ -58,6 +58,7 @@ export NEW_HOST_SET='test'
local hsid=$(host_set_id $NEW_HOST_SET $DEFAULT_HOST_CATALOG)
run delete_host_set $hsid
echo "$output"
run has_status_code "$output" "204"
[ "$status" -eq 0 ]
}
+1
View File
@@ -44,6 +44,7 @@ export NEW_HOST='test'
local hid=$(host_id $NEW_HOST $DEFAULT_HOST_CATALOG)
run delete_host $hid
echo "$output"
run has_status_code "$output" "204"
[ "$status" -eq 0 ]
}
+1
View File
@@ -102,6 +102,7 @@ export NEW_GRANT='id=*;type=*;actions=create,read,update,delete,list'
local rid=$(role_id $NEW_ROLE $DEFAULT_GLOBAL)
run delete_role $rid
echo "$output"
run has_status_code "$output" "204"
[ "$status" -eq 0 ]
}
+2
View File
@@ -64,6 +64,7 @@ export NEW_PROJECT='test_project'
local sid=$(scope_id $NEW_PROJECT $parent)
run delete_scope $sid
echo "$output"
run has_status_code "$output" "204"
[ "$status" -eq 0 ]
}
@@ -79,6 +80,7 @@ export NEW_PROJECT='test_project'
local sid=$(scope_id $NEW_ORG $DEFAULT_GLOBAL)
run delete_scope $sid
echo "$output"
run has_status_code "$output" "204"
[ "$status" -eq 0 ]
}
+1
View File
@@ -92,6 +92,7 @@ load _helpers
@test "boundary/target: default user can delete target" {
local id=$(target_id_from_name $DEFAULT_P_ID $TGT_NAME)
run delete_target $id
run has_status_code "$output" "204"
[ "$status" -eq 0 ]
}
+4 -2
View File
@@ -68,7 +68,9 @@ export NEW_USER='test'
@test "boundary/user: can delete $NEW_USER user" {
login $DEFAULT_LOGIN
local uid=$(user_id $NEW_USER)
run delete_user $uid
run delete_user $uid
echo $output
run has_status_code "$output" "204"
[ "$status" -eq 0 ]
}
@@ -82,4 +84,4 @@ export NEW_USER='test'
local aid=$(account_id $NEW_USER)
run delete_account $aid
[ "$status" -eq 0 ]
}
}