* 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
88 lines
2.0 KiB
Bash
88 lines
2.0 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load _accounts
|
|
load _auth
|
|
load _users
|
|
load _helpers
|
|
|
|
export NEW_USER='test'
|
|
|
|
@test "boundary/login: can login as default user" {
|
|
run login $DEFAULT_LOGIN
|
|
[ "$status" -eq 0 ]
|
|
}
|
|
|
|
@test "boundary/users: can add $NEW_USER user" {
|
|
run create_user $NEW_USER
|
|
[ "$status" -eq 0 ]
|
|
}
|
|
|
|
@test "boundary/users: can not add already created $NEW_USER user" {
|
|
run create_user $NEW_USER
|
|
[ "$status" -eq 1 ]
|
|
}
|
|
|
|
@test "boundary/users: can read $NEW_USER user" {
|
|
local uid=$(user_id $NEW_USER)
|
|
run read_user $uid
|
|
[ "$status" -eq 0 ]
|
|
}
|
|
|
|
@test "boundary/users: the $NEW_USER user contains default authorized-actions" {
|
|
local uid=$(user_id $NEW_USER)
|
|
local out=$(read_user $uid)
|
|
|
|
run has_default_user_actions "$out"
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
}
|
|
|
|
@test "boundary/account/password: can add $NEW_USER account" {
|
|
run create_account $NEW_USER
|
|
[ "$status" -eq 0 ]
|
|
}
|
|
|
|
@test "boundary/account/password: can not add already created $NEW_USER account" {
|
|
run create_account $NEW_USER
|
|
[ "$status" -eq 1 ]
|
|
}
|
|
|
|
@test "boundary/account/password: can read created $NEW_USER account" {
|
|
local aid=$(account_id $NEW_USER)
|
|
run read_account $aid
|
|
[ "$status" -eq 0 ]
|
|
}
|
|
|
|
@test "boundary/user/account-add: can associate $NEW_USER account with $NEW_USER user" {
|
|
local uid=$(user_id $NEW_USER)
|
|
local aid=$(account_id $NEW_USER)
|
|
run assoc_user_acct $aid $uid
|
|
[ "$status" -eq 0 ]
|
|
}
|
|
|
|
@test "boundary/login: can login as $NEW_USER user" {
|
|
run login $NEW_USER
|
|
[ "$status" -eq 0 ]
|
|
}
|
|
|
|
@test "boundary/user: can delete $NEW_USER user" {
|
|
login $DEFAULT_LOGIN
|
|
local uid=$(user_id $NEW_USER)
|
|
run delete_user $uid
|
|
echo $output
|
|
run has_status_code "$output" "204"
|
|
[ "$status" -eq 0 ]
|
|
}
|
|
|
|
@test "boundary/users: can not read deleted $NEW_USER user" {
|
|
local uid=$(user_id $NEW_USER)
|
|
run read_user $uid
|
|
[ "$status" -eq 1 ]
|
|
}
|
|
|
|
@test "boundary/account/password: can delete $NEW_USER account" {
|
|
local aid=$(account_id $NEW_USER)
|
|
run delete_account $aid
|
|
[ "$status" -eq 0 ]
|
|
}
|