mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-17 12:07:02 +02:00
* Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License. Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUS-1.1 * Fix test that expected exact offset on hcl file --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Sarah Thompson <sthompson@hashicorp.com> Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
88 lines
2.4 KiB
Go
88 lines
2.4 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package kerberos
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hashicorp/go-hclog"
|
|
"github.com/hashicorp/vault/command/agentproxyshared/auth"
|
|
)
|
|
|
|
func TestNewKerberosAuthMethod(t *testing.T) {
|
|
if _, err := NewKerberosAuthMethod(nil); err == nil {
|
|
t.Fatal("err should be returned for nil input")
|
|
}
|
|
if _, err := NewKerberosAuthMethod(&auth.AuthConfig{}); err == nil {
|
|
t.Fatal("err should be returned for nil config map")
|
|
}
|
|
|
|
authConfig := simpleAuthConfig()
|
|
delete(authConfig.Config, "username")
|
|
if _, err := NewKerberosAuthMethod(authConfig); err == nil {
|
|
t.Fatal("err should be returned for missing username")
|
|
}
|
|
|
|
authConfig = simpleAuthConfig()
|
|
delete(authConfig.Config, "service")
|
|
if _, err := NewKerberosAuthMethod(authConfig); err == nil {
|
|
t.Fatal("err should be returned for missing service")
|
|
}
|
|
|
|
authConfig = simpleAuthConfig()
|
|
delete(authConfig.Config, "realm")
|
|
if _, err := NewKerberosAuthMethod(authConfig); err == nil {
|
|
t.Fatal("err should be returned for missing realm")
|
|
}
|
|
|
|
authConfig = simpleAuthConfig()
|
|
delete(authConfig.Config, "keytab_path")
|
|
if _, err := NewKerberosAuthMethod(authConfig); err == nil {
|
|
t.Fatal("err should be returned for missing keytab_path")
|
|
}
|
|
|
|
authConfig = simpleAuthConfig()
|
|
delete(authConfig.Config, "krb5conf_path")
|
|
if _, err := NewKerberosAuthMethod(authConfig); err == nil {
|
|
t.Fatal("err should be returned for missing krb5conf_path")
|
|
}
|
|
|
|
authConfig = simpleAuthConfig()
|
|
authMethod, err := NewKerberosAuthMethod(authConfig)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// False by default
|
|
if actual := authMethod.(*kerberosMethod).loginCfg.DisableFASTNegotiation; actual {
|
|
t.Fatalf("disable_fast_negotation should be false, it wasn't: %t", actual)
|
|
}
|
|
|
|
authConfig.Config["disable_fast_negotiation"] = "true"
|
|
authMethod, err = NewKerberosAuthMethod(authConfig)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// True from override
|
|
if actual := authMethod.(*kerberosMethod).loginCfg.DisableFASTNegotiation; !actual {
|
|
t.Fatalf("disable_fast_negotation should be true, it wasn't: %t", actual)
|
|
}
|
|
}
|
|
|
|
func simpleAuthConfig() *auth.AuthConfig {
|
|
return &auth.AuthConfig{
|
|
Logger: hclog.NewNullLogger(),
|
|
MountPath: "kerberos",
|
|
WrapTTL: 20,
|
|
Config: map[string]interface{}{
|
|
"username": "grace",
|
|
"service": "HTTP/05a65fad28ef.matrix.lan:8200",
|
|
"realm": "MATRIX.LAN",
|
|
"keytab_path": "grace.keytab",
|
|
"krb5conf_path": "krb5.conf",
|
|
},
|
|
}
|
|
}
|