-
Notifications
You must be signed in to change notification settings - Fork 549
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support authenticating to the root namespace from within an auth_logi…
…n* (#2066) * Add new auth_login field for enforcing root namespace The additional field is a work around to deal with TF plugin SDK's evaluation of values in boolean context. There was no way to treat the "" as the default Vault namespace from the TF schema, since none of its Get*() public methods do what we need. So the new way is to set is_root_namespace to true, leave the namespace field unset in any auth_login* resource blocks. --------- Co-authored-by: Vinay Gopalan <[email protected]>
- Loading branch information
1 parent
b740f13
commit bff5e91
Showing
28 changed files
with
362 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package provider | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-provider-vault/internal/consts" | ||
) | ||
|
||
func TestAuthLoginGeneric_Namespace(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
params map[string]interface{} | ||
want string | ||
exists bool | ||
}{ | ||
{ | ||
name: "root-ns", | ||
params: map[string]interface{}{ | ||
consts.FieldUseRootNamespace: true, | ||
}, | ||
want: "", | ||
exists: true, | ||
}, | ||
{ | ||
name: "other-ns", | ||
params: map[string]interface{}{ | ||
consts.FieldNamespace: "ns1", | ||
}, | ||
want: "ns1", | ||
exists: true, | ||
}, | ||
{ | ||
name: "empty-ns", | ||
params: map[string]interface{}{ | ||
consts.FieldNamespace: "", | ||
}, | ||
want: "", | ||
exists: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
l := &AuthLoginGeneric{ | ||
AuthLoginCommon: AuthLoginCommon{ | ||
params: tt.params, | ||
initialized: true, | ||
}, | ||
} | ||
got, exists := l.Namespace() | ||
if got != tt.want { | ||
t.Errorf("Namespace() got = %v, want %v", got, tt.want) | ||
} | ||
if exists != tt.exists { | ||
t.Errorf("Namespace() exists = %v, want %v", exists, tt.exists) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.