Vault KV backend returns a nil secret and no error if the secret does not
exist. This caused a panic in during Issue:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x1388279]
goroutine 2639 [running]:
github.com/hashicorp/boundary/internal/credential/vault.(*Repository).Issue(0xc001222200, {0x3b932d0, 0xc001203350}, {0xc000dc6e90, 0xc}, {0xc0010e5e40, 0x0, 0x0})
/home/louis/boundary/internal/credential/vault/repository_credentials.go:67 +0x2d9
github.com/hashicorp/boundary/internal/servers/controller/handlers/targets.Service.AuthorizeSession({{}, 0xc000cd4a38, 0xc000cd4840, 0xc000cd48d0, 0xc000cd4a50, 0xc000cd4870, 0xc000cd4858, 0xc000cd48b8, 0xc0001a8880}, {0x3b932d0, ...}, ...)
/home/louis/boundary/internal/servers/controller/handlers/targets/target_service.go:1059 +0x1525
github.com/hashicorp/boundary/internal/gen/controller/api/services._TargetService_AuthorizeSession_Handler.func1({0x3b932d0, 0xc001203350}, {0x1a0dd40, 0xc000dc8880})
/home/louis/boundary/internal/gen/controller/api/services/target_service_grpc.pb.go:631 +0x78
github.com/hashicorp/boundary/internal/servers/controller.auditResponseInterceptor.func1({0x3b932d0, 0xc001203350}, {0x1a0dd40, 0xc000dc8880}, 0x461279, 0x40d234)
/home/louis/boundary/internal/servers/controller/interceptor.go:262 +0x4e
github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1.1({0x3b932d0, 0xc001203350}, {0x1a0dd40, 0xc000dc8880})
/home/louis/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.3.0/chain.go:25 +0x3a
github.com/hashicorp/boundary/internal/servers/controller.statusCodeInterceptor.func1({0x3b932d0, 0xc001203350}, {0x1a0dd40, 0xc000dc8880}, 0x203000, 0x203000)
/home/louis/boundary/internal/servers/controller/interceptor.go:207 +0x34
github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1.1({0x3b932d0, 0xc001203350}, {0x1a0dd40, 0xc000dc8880})
/home/louis/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.3.0/chain.go:25 +0x3a
github.com/hashicorp/boundary/internal/servers/controller.errorInterceptor.func1({0x3b932d0, 0xc001203350}, {0x1a0dd40, 0xc000dc8880}, 0x18e2b40, 0x0)
/home/louis/boundary/internal/servers/controller/interceptor.go:156 +0x4e
github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1.1({0x3b932d0, 0xc001203350}, {0x1a0dd40, 0xc000dc8880})
/home/louis/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.3.0/chain.go:25 +0x3a
github.com/hashicorp/boundary/internal/servers/controller.auditRequestInterceptor.func1({0x3b932d0, 0xc001203350}, {0x1a0dd40, 0xc000dc8880}, 0x1a1c860, 0xc0010e5280)
/home/louis/boundary/internal/servers/controller/interceptor.go:248 +0x198
github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1.1({0x3b932d0, 0xc001203350}, {0x1a0dd40, 0xc000dc8880})
/home/louis/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.3.0/chain.go:25 +0x3a
github.com/hashicorp/boundary/internal/servers/controller.requestCtxInterceptor.func1({0x3b932d0, 0xc001203260}, {0x1a0dd40, 0xc000dc8880}, 0x18, 0xc0010e52a0)
/home/louis/boundary/internal/servers/controller/interceptor.go:140 +0x5de
github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1.1({0x3b932d0, 0xc001203260}, {0x1a0dd40, 0xc000dc8880})
/home/louis/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.3.0/chain.go:25 +0x3a
github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1({0x3b932d0, 0xc001203260}, {0x1a0dd40, 0xc000dc8880}, 0xc00331abb8, 0x18675e0)
/home/louis/go/pkg/mod/github.com/grpc-ecosystem/go-grpc-middleware@v1.3.0/chain.go:34 +0xbf
github.com/hashicorp/boundary/internal/gen/controller/api/services._TargetService_AuthorizeSession_Handler({0x1ada420, 0xc00093a180}, {0x3b932d0, 0xc001203260}, 0xc001200840, 0xc000465260)
/home/louis/boundary/internal/gen/controller/api/services/target_service_grpc.pb.go:633 +0x138
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000cca540, {0x3bb4c58, 0xc0005a9c80}, 0xc001208480, 0xc0004a7440, 0x499e2b8, 0x0)
/home/louis/go/pkg/mod/google.golang.org/grpc@v1.40.0/server.go:1297 +0xccf
google.golang.org/grpc.(*Server).handleStream(0xc000cca540, {0x3bb4c58, 0xc0005a9c80}, 0xc001208480, 0x0)
/home/louis/go/pkg/mod/google.golang.org/grpc@v1.40.0/server.go:1626 +0xa2a
google.golang.org/grpc.(*Server).serveStreams.func1.2()
/home/louis/go/pkg/mod/google.golang.org/grpc@v1.40.0/server.go:941 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
/home/louis/go/pkg/mod/google.golang.org/grpc@v1.40.0/server.go:939 +0x294
314 lines
5.4 KiB
Go
314 lines
5.4 KiB
Go
package errors
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCode_Both_String_Info(t *testing.T) {
|
|
t.Parallel()
|
|
tests := []struct {
|
|
name string
|
|
c Code
|
|
want Code
|
|
}{
|
|
{
|
|
name: "undefined-code",
|
|
c: Code(4294967295),
|
|
want: Unknown,
|
|
},
|
|
{
|
|
name: "default-value",
|
|
want: Unknown,
|
|
},
|
|
{
|
|
name: "Unknown",
|
|
c: Unknown,
|
|
want: Unknown,
|
|
},
|
|
{
|
|
name: "InvalidParameter",
|
|
c: InvalidParameter,
|
|
want: InvalidParameter,
|
|
},
|
|
{
|
|
name: "InvalidAddress",
|
|
c: InvalidAddress,
|
|
want: InvalidAddress,
|
|
},
|
|
{
|
|
name: "InvalidPublicId",
|
|
c: InvalidPublicId,
|
|
want: InvalidPublicId,
|
|
},
|
|
{
|
|
name: "InvalidFieldMask",
|
|
c: InvalidFieldMask,
|
|
want: InvalidFieldMask,
|
|
},
|
|
{
|
|
name: "EmptyFieldMask",
|
|
c: EmptyFieldMask,
|
|
want: EmptyFieldMask,
|
|
},
|
|
{
|
|
name: "KeyNotFound",
|
|
c: KeyNotFound,
|
|
want: KeyNotFound,
|
|
},
|
|
{
|
|
name: "TicketAlreadyRedeemed",
|
|
c: TicketAlreadyRedeemed,
|
|
want: TicketAlreadyRedeemed,
|
|
},
|
|
{
|
|
name: "TicketNotFound",
|
|
c: TicketNotFound,
|
|
want: TicketNotFound,
|
|
},
|
|
{
|
|
name: "Io",
|
|
c: Io,
|
|
want: Io,
|
|
},
|
|
{
|
|
name: "InvalidTimeStamp",
|
|
c: InvalidTimeStamp,
|
|
want: InvalidTimeStamp,
|
|
},
|
|
{
|
|
name: "SessionNotFound",
|
|
c: SessionNotFound,
|
|
want: SessionNotFound,
|
|
},
|
|
{
|
|
name: "InvalidSessionState",
|
|
c: InvalidSessionState,
|
|
want: InvalidSessionState,
|
|
},
|
|
{
|
|
name: "TokenMismatch",
|
|
c: TokenMismatch,
|
|
want: TokenMismatch,
|
|
},
|
|
{
|
|
name: "TooShort",
|
|
c: TooShort,
|
|
want: TooShort,
|
|
},
|
|
{
|
|
name: "AccountAlreadyAssociated",
|
|
c: AccountAlreadyAssociated,
|
|
want: AccountAlreadyAssociated,
|
|
},
|
|
{
|
|
name: "InvalidJobRunState",
|
|
c: InvalidJobRunState,
|
|
want: InvalidJobRunState,
|
|
},
|
|
{
|
|
name: "JobAlreadyRunning",
|
|
c: JobAlreadyRunning,
|
|
want: JobAlreadyRunning,
|
|
},
|
|
{
|
|
name: "SubtypeAlreadyRegistered",
|
|
c: SubtypeAlreadyRegistered,
|
|
want: SubtypeAlreadyRegistered,
|
|
},
|
|
{
|
|
name: "InvalidDynamicCredential",
|
|
c: InvalidDynamicCredential,
|
|
want: InvalidDynamicCredential,
|
|
},
|
|
{
|
|
name: "InternalError",
|
|
c: Internal,
|
|
want: Internal,
|
|
},
|
|
{
|
|
name: "Forbidden",
|
|
c: Forbidden,
|
|
want: Forbidden,
|
|
},
|
|
{
|
|
name: "AuthMethodInactive",
|
|
c: AuthMethodInactive,
|
|
want: AuthMethodInactive,
|
|
},
|
|
{
|
|
name: "AuthAttemptExpired",
|
|
c: AuthAttemptExpired,
|
|
want: AuthAttemptExpired,
|
|
},
|
|
{
|
|
name: "PasswordTooShort",
|
|
c: PasswordTooShort,
|
|
want: PasswordTooShort,
|
|
},
|
|
{
|
|
name: "PasswordUnsupportedConfiguration",
|
|
c: PasswordUnsupportedConfiguration,
|
|
want: PasswordUnsupportedConfiguration,
|
|
},
|
|
{
|
|
name: "PasswordInvalidConfiguration",
|
|
c: PasswordInvalidConfiguration,
|
|
want: PasswordInvalidConfiguration,
|
|
},
|
|
{
|
|
name: "PasswordsEqual",
|
|
c: PasswordsEqual,
|
|
want: PasswordsEqual,
|
|
},
|
|
{
|
|
name: "Encrypt",
|
|
c: Encrypt,
|
|
want: Encrypt,
|
|
},
|
|
{
|
|
name: "Decrypt",
|
|
c: Decrypt,
|
|
want: Decrypt,
|
|
},
|
|
{
|
|
name: "Encode",
|
|
c: Encode,
|
|
want: Encode,
|
|
},
|
|
{
|
|
name: "Decode",
|
|
c: Decode,
|
|
want: Decode,
|
|
},
|
|
{
|
|
name: "GenKey",
|
|
c: GenKey,
|
|
want: GenKey,
|
|
},
|
|
{
|
|
name: "GenCert",
|
|
c: GenCert,
|
|
want: GenCert,
|
|
},
|
|
{
|
|
name: "CheckConstraint",
|
|
c: CheckConstraint,
|
|
want: CheckConstraint,
|
|
},
|
|
{
|
|
name: "NotNull",
|
|
c: NotNull,
|
|
want: NotNull,
|
|
},
|
|
{
|
|
name: "NotUnique",
|
|
c: NotUnique,
|
|
want: NotUnique,
|
|
},
|
|
{
|
|
name: "RecordNotFound",
|
|
c: RecordNotFound,
|
|
want: RecordNotFound,
|
|
},
|
|
{
|
|
name: "ColumnNotFound",
|
|
c: ColumnNotFound,
|
|
want: ColumnNotFound,
|
|
},
|
|
{
|
|
name: "MaxRetries",
|
|
c: MaxRetries,
|
|
want: MaxRetries,
|
|
},
|
|
{
|
|
name: "Exception",
|
|
c: Exception,
|
|
want: Exception,
|
|
},
|
|
{
|
|
name: "VersionMismatch",
|
|
c: VersionMismatch,
|
|
want: VersionMismatch,
|
|
},
|
|
{
|
|
name: "MultipleRecords",
|
|
c: MultipleRecords,
|
|
want: MultipleRecords,
|
|
},
|
|
{
|
|
name: "NotSpecificIntegrity",
|
|
c: NotSpecificIntegrity,
|
|
want: NotSpecificIntegrity,
|
|
},
|
|
{
|
|
name: "MissingTable",
|
|
c: MissingTable,
|
|
want: MissingTable,
|
|
},
|
|
{
|
|
name: "MigrationIntegrity",
|
|
c: MigrationIntegrity,
|
|
want: MigrationIntegrity,
|
|
},
|
|
{
|
|
name: "MigrationLock",
|
|
c: MigrationLock,
|
|
want: MigrationLock,
|
|
},
|
|
{
|
|
name: "Unavailable",
|
|
c: Unavailable,
|
|
want: Unavailable,
|
|
},
|
|
{
|
|
name: "VaultTokenNotOrphan",
|
|
c: VaultTokenNotOrphan,
|
|
want: VaultTokenNotOrphan,
|
|
},
|
|
{
|
|
name: "VaultTokenNotPeriodic",
|
|
c: VaultTokenNotPeriodic,
|
|
want: VaultTokenNotPeriodic,
|
|
},
|
|
{
|
|
name: "VaultTokenNotRenewable",
|
|
c: VaultTokenNotRenewable,
|
|
want: VaultTokenNotRenewable,
|
|
},
|
|
{
|
|
name: "VaultCredentialRequest",
|
|
c: VaultCredentialRequest,
|
|
want: VaultCredentialRequest,
|
|
},
|
|
{
|
|
name: "VaultEmptySecret",
|
|
c: VaultEmptySecret,
|
|
want: VaultEmptySecret,
|
|
},
|
|
{
|
|
name: "OidcProviderCallbackError",
|
|
c: OidcProviderCallbackError,
|
|
want: OidcProviderCallbackError,
|
|
},
|
|
{
|
|
name: "GracefullyAborted",
|
|
c: GracefullyAborted,
|
|
want: GracefullyAborted,
|
|
},
|
|
{
|
|
name: "UnexpectedRowsAffected",
|
|
c: UnexpectedRowsAffected,
|
|
want: UnexpectedRowsAffected,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
assert := assert.New(t)
|
|
assert.Equal(errorCodeInfo[tt.want], tt.c.Info())
|
|
assert.Equal(errorCodeInfo[tt.want].Message, tt.c.String())
|
|
})
|
|
}
|
|
}
|