Revert the WithContext changes to vault tests (#14947)

This commit is contained in:
Anton Averchenkov 2022-04-07 15:12:58 -04:00 committed by GitHub
parent 8f54282828
commit 23a3f950e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
104 changed files with 1093 additions and 1167 deletions

View File

@ -63,10 +63,10 @@ func TestBackend_E2E_Initialize(t *testing.T) {
"policies": "default",
"bound_subnet_id": "subnet-abcdef",
}
if _, err := core.Client.Logical().WriteWithContext(context.Background(), "auth/aws/role/test-role", data); err != nil {
if _, err := core.Client.Logical().Write("auth/aws/role/test-role", data); err != nil {
t.Fatal(err)
}
role, err := core.Client.Logical().ReadWithContext(context.Background(), "auth/aws/role/test-role")
role, err := core.Client.Logical().Read("auth/aws/role/test-role")
if err != nil {
t.Fatal(err)
}

View File

@ -272,7 +272,7 @@ func TestBackend_PermittedDNSDomainsIntermediateCA(t *testing.T) {
var err error
// Mount /pki as a root CA
err = client.Sys().MountWithContext(context.Background(), "pki", &api.MountInput{
err = client.Sys().Mount("pki", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -285,7 +285,7 @@ func TestBackend_PermittedDNSDomainsIntermediateCA(t *testing.T) {
// Set the cluster's certificate as the root CA in /pki
pemBundleRootCA := string(cluster.CACertPEM) + string(cluster.CAKeyPEM)
_, err = client.Logical().WriteWithContext(context.Background(), "pki/config/ca", map[string]interface{}{
_, err = client.Logical().Write("pki/config/ca", map[string]interface{}{
"pem_bundle": pemBundleRootCA,
})
if err != nil {
@ -293,7 +293,7 @@ func TestBackend_PermittedDNSDomainsIntermediateCA(t *testing.T) {
}
// Mount /pki2 to operate as an intermediate CA
err = client.Sys().MountWithContext(context.Background(), "pki2", &api.MountInput{
err = client.Sys().Mount("pki2", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -305,14 +305,14 @@ func TestBackend_PermittedDNSDomainsIntermediateCA(t *testing.T) {
}
// Create a CSR for the intermediate CA
secret, err := client.Logical().WriteWithContext(context.Background(), "pki2/intermediate/generate/internal", nil)
secret, err := client.Logical().Write("pki2/intermediate/generate/internal", nil)
if err != nil {
t.Fatal(err)
}
intermediateCSR := secret.Data["csr"].(string)
// Sign the intermediate CSR using /pki
secret, err = client.Logical().WriteWithContext(context.Background(), "pki/root/sign-intermediate", map[string]interface{}{
secret, err = client.Logical().Write("pki/root/sign-intermediate", map[string]interface{}{
"permitted_dns_domains": ".myvault.com",
"csr": intermediateCSR,
})
@ -322,7 +322,7 @@ func TestBackend_PermittedDNSDomainsIntermediateCA(t *testing.T) {
intermediateCertPEM := secret.Data["certificate"].(string)
// Configure the intermediate cert as the CA in /pki2
_, err = client.Logical().WriteWithContext(context.Background(), "pki2/intermediate/set-signed", map[string]interface{}{
_, err = client.Logical().Write("pki2/intermediate/set-signed", map[string]interface{}{
"certificate": intermediateCertPEM,
})
if err != nil {
@ -330,7 +330,7 @@ func TestBackend_PermittedDNSDomainsIntermediateCA(t *testing.T) {
}
// Create a role on the intermediate CA mount
_, err = client.Logical().WriteWithContext(context.Background(), "pki2/roles/myvault-dot-com", map[string]interface{}{
_, err = client.Logical().Write("pki2/roles/myvault-dot-com", map[string]interface{}{
"allowed_domains": "myvault.com",
"allow_subdomains": "true",
"max_ttl": "5m",
@ -340,7 +340,7 @@ func TestBackend_PermittedDNSDomainsIntermediateCA(t *testing.T) {
}
// Issue a leaf cert using the intermediate CA
secret, err = client.Logical().WriteWithContext(context.Background(), "pki2/issue/myvault-dot-com", map[string]interface{}{
secret, err = client.Logical().Write("pki2/issue/myvault-dot-com", map[string]interface{}{
"common_name": "cert.myvault.com",
"format": "pem",
"ip_sans": "127.0.0.1",
@ -360,7 +360,7 @@ func TestBackend_PermittedDNSDomainsIntermediateCA(t *testing.T) {
}
// Set the intermediate CA cert as a trusted certificate in the backend
_, err = client.Logical().WriteWithContext(context.Background(), "auth/cert/certs/myvault-dot-com", map[string]interface{}{
_, err = client.Logical().Write("auth/cert/certs/myvault-dot-com", map[string]interface{}{
"display_name": "myvault.com",
"policies": "default",
"certificate": intermediateCertPEM,
@ -447,7 +447,7 @@ func TestBackend_PermittedDNSDomainsIntermediateCA(t *testing.T) {
// Create a new api client with the desired TLS configuration
newClient := getAPIClient(cores[0].Listeners[0].Address.Port, cores[0].TLSConfig)
secret, err = newClient.Logical().WriteWithContext(context.Background(), "auth/cert/login", map[string]interface{}{
secret, err = newClient.Logical().Write("auth/cert/login", map[string]interface{}{
"name": "myvault-dot-com",
})
if err != nil {

View File

@ -67,7 +67,7 @@ func TestPKI_RequireCN(t *testing.T) {
client := cluster.Cores[0].Client
var err error
err = client.Sys().MountWithContext(context.Background(), "pki", &api.MountInput{
err = client.Sys().Mount("pki", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -78,7 +78,7 @@ func TestPKI_RequireCN(t *testing.T) {
t.Fatal(err)
}
resp, err := client.Logical().WriteWithContext(context.Background(), "pki/root/generate/internal", map[string]interface{}{
resp, err := client.Logical().Write("pki/root/generate/internal", map[string]interface{}{
"common_name": "myvault.com",
})
if err != nil {
@ -89,7 +89,7 @@ func TestPKI_RequireCN(t *testing.T) {
}
// Create a role which does require CN (default)
_, err = client.Logical().WriteWithContext(context.Background(), "pki/roles/example", map[string]interface{}{
_, err = client.Logical().Write("pki/roles/example", map[string]interface{}{
"allowed_domains": "foobar.com,zipzap.com,abc.com,xyz.com",
"allow_bare_domains": true,
"allow_subdomains": true,
@ -101,7 +101,7 @@ func TestPKI_RequireCN(t *testing.T) {
// Issue a cert with require_cn set to true and with common name supplied.
// It should succeed.
resp, err = client.Logical().WriteWithContext(context.Background(), "pki/issue/example", map[string]interface{}{
resp, err = client.Logical().Write("pki/issue/example", map[string]interface{}{
"common_name": "foobar.com",
})
if err != nil {
@ -110,13 +110,13 @@ func TestPKI_RequireCN(t *testing.T) {
// Issue a cert with require_cn set to true and with out supplying the
// common name. It should error out.
resp, err = client.Logical().WriteWithContext(context.Background(), "pki/issue/example", map[string]interface{}{})
resp, err = client.Logical().Write("pki/issue/example", map[string]interface{}{})
if err == nil {
t.Fatalf("expected an error due to missing common_name")
}
// Modify the role to make the common name optional
_, err = client.Logical().WriteWithContext(context.Background(), "pki/roles/example", map[string]interface{}{
_, err = client.Logical().Write("pki/roles/example", map[string]interface{}{
"allowed_domains": "foobar.com,zipzap.com,abc.com,xyz.com",
"allow_bare_domains": true,
"allow_subdomains": true,
@ -129,7 +129,7 @@ func TestPKI_RequireCN(t *testing.T) {
// Issue a cert with require_cn set to false and without supplying the
// common name. It should succeed.
resp, err = client.Logical().WriteWithContext(context.Background(), "pki/issue/example", map[string]interface{}{})
resp, err = client.Logical().Write("pki/issue/example", map[string]interface{}{})
if err != nil {
t.Fatal(err)
}
@ -140,7 +140,7 @@ func TestPKI_RequireCN(t *testing.T) {
// Issue a cert with require_cn set to false and with a common name. It
// should succeed.
resp, err = client.Logical().WriteWithContext(context.Background(), "pki/issue/example", map[string]interface{}{})
resp, err = client.Logical().Write("pki/issue/example", map[string]interface{}{})
if err != nil {
t.Fatal(err)
}
@ -164,7 +164,7 @@ func TestPKI_DeviceCert(t *testing.T) {
client := cluster.Cores[0].Client
var err error
err = client.Sys().MountWithContext(context.Background(), "pki", &api.MountInput{
err = client.Sys().Mount("pki", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -175,7 +175,7 @@ func TestPKI_DeviceCert(t *testing.T) {
t.Fatal(err)
}
resp, err := client.Logical().WriteWithContext(context.Background(), "pki/root/generate/internal", map[string]interface{}{
resp, err := client.Logical().Write("pki/root/generate/internal", map[string]interface{}{
"common_name": "myvault.com",
"not_after": "9999-12-31T23:59:59Z",
})
@ -202,7 +202,7 @@ func TestPKI_DeviceCert(t *testing.T) {
}
// Create a role which does require CN (default)
_, err = client.Logical().WriteWithContext(context.Background(), "pki/roles/example", map[string]interface{}{
_, err = client.Logical().Write("pki/roles/example", map[string]interface{}{
"allowed_domains": "foobar.com,zipzap.com,abc.com,xyz.com",
"allow_bare_domains": true,
"allow_subdomains": true,
@ -214,7 +214,7 @@ func TestPKI_DeviceCert(t *testing.T) {
// Issue a cert with require_cn set to true and with common name supplied.
// It should succeed.
resp, err = client.Logical().WriteWithContext(context.Background(), "pki/issue/example", map[string]interface{}{
resp, err = client.Logical().Write("pki/issue/example", map[string]interface{}{
"common_name": "foobar.com",
})
if err != nil {
@ -250,7 +250,7 @@ func TestBackend_InvalidParameter(t *testing.T) {
client := cluster.Cores[0].Client
var err error
err = client.Sys().MountWithContext(context.Background(), "pki", &api.MountInput{
err = client.Sys().Mount("pki", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -261,7 +261,7 @@ func TestBackend_InvalidParameter(t *testing.T) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "pki/root/generate/internal", map[string]interface{}{
_, err = client.Logical().Write("pki/root/generate/internal", map[string]interface{}{
"common_name": "myvault.com",
"not_after": "9999-12-31T23:59:59Z",
"ttl": "25h",
@ -270,7 +270,7 @@ func TestBackend_InvalidParameter(t *testing.T) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "pki/root/generate/internal", map[string]interface{}{
_, err = client.Logical().Write("pki/root/generate/internal", map[string]interface{}{
"common_name": "myvault.com",
"not_after": "9999-12-31T23:59:59",
})
@ -2278,7 +2278,7 @@ func TestBackend_Root_Idempotency(t *testing.T) {
client := cluster.Cores[0].Client
var err error
err = client.Sys().MountWithContext(context.Background(), "pki", &api.MountInput{
err = client.Sys().Mount("pki", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -2289,7 +2289,7 @@ func TestBackend_Root_Idempotency(t *testing.T) {
t.Fatal(err)
}
resp, err := client.Logical().WriteWithContext(context.Background(), "pki/root/generate/internal", map[string]interface{}{
resp, err := client.Logical().Write("pki/root/generate/internal", map[string]interface{}{
"common_name": "myvault.com",
})
if err != nil {
@ -2298,7 +2298,7 @@ func TestBackend_Root_Idempotency(t *testing.T) {
if resp == nil {
t.Fatal("expected ca info")
}
resp, err = client.Logical().ReadWithContext(context.Background(), "pki/cert/ca_chain")
resp, err = client.Logical().Read("pki/cert/ca_chain")
if err != nil {
t.Fatalf("error reading ca_chain: %v", err)
}
@ -2306,7 +2306,7 @@ func TestBackend_Root_Idempotency(t *testing.T) {
r1Data := resp.Data
// Try again, make sure it's a 204 and same CA
resp, err = client.Logical().WriteWithContext(context.Background(), "pki/root/generate/internal", map[string]interface{}{
resp, err = client.Logical().Write("pki/root/generate/internal", map[string]interface{}{
"common_name": "myvault.com",
})
if err != nil {
@ -2318,7 +2318,7 @@ func TestBackend_Root_Idempotency(t *testing.T) {
if resp.Data != nil || len(resp.Warnings) == 0 {
t.Fatalf("bad response: %#v", *resp)
}
resp, err = client.Logical().ReadWithContext(context.Background(), "pki/cert/ca_chain")
resp, err = client.Logical().Read("pki/cert/ca_chain")
if err != nil {
t.Fatalf("error reading ca_chain: %v", err)
}
@ -2327,7 +2327,7 @@ func TestBackend_Root_Idempotency(t *testing.T) {
t.Fatal("got different ca certs")
}
resp, err = client.Logical().DeleteWithContext(context.Background(), "pki/root")
resp, err = client.Logical().Delete("pki/root")
if err != nil {
t.Fatal(err)
}
@ -2335,7 +2335,7 @@ func TestBackend_Root_Idempotency(t *testing.T) {
t.Fatal("expected nil response")
}
// Make sure it behaves the same
resp, err = client.Logical().DeleteWithContext(context.Background(), "pki/root")
resp, err = client.Logical().Delete("pki/root")
if err != nil {
t.Fatal(err)
}
@ -2343,12 +2343,12 @@ func TestBackend_Root_Idempotency(t *testing.T) {
t.Fatal("expected nil response")
}
_, err = client.Logical().ReadWithContext(context.Background(), "pki/cert/ca_chain")
_, err = client.Logical().Read("pki/cert/ca_chain")
if err == nil {
t.Fatal("expected error")
}
resp, err = client.Logical().WriteWithContext(context.Background(), "pki/root/generate/internal", map[string]interface{}{
resp, err = client.Logical().Write("pki/root/generate/internal", map[string]interface{}{
"common_name": "myvault.com",
})
if err != nil {
@ -2358,7 +2358,7 @@ func TestBackend_Root_Idempotency(t *testing.T) {
t.Fatal("expected ca info")
}
_, err = client.Logical().ReadWithContext(context.Background(), "pki/cert/ca_chain")
_, err = client.Logical().Read("pki/cert/ca_chain")
if err != nil {
t.Fatal(err)
}
@ -2378,7 +2378,7 @@ func TestBackend_SignIntermediate_AllowedPastCA(t *testing.T) {
client := cluster.Cores[0].Client
var err error
err = client.Sys().MountWithContext(context.Background(), "root", &api.MountInput{
err = client.Sys().Mount("root", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -2388,7 +2388,7 @@ func TestBackend_SignIntermediate_AllowedPastCA(t *testing.T) {
if err != nil {
t.Fatal(err)
}
err = client.Sys().MountWithContext(context.Background(), "int", &api.MountInput{
err = client.Sys().Mount("int", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "4h",
@ -2400,7 +2400,7 @@ func TestBackend_SignIntermediate_AllowedPastCA(t *testing.T) {
}
// Direct issuing from root
_, err = client.Logical().WriteWithContext(context.Background(), "root/root/generate/internal", map[string]interface{}{
_, err = client.Logical().Write("root/root/generate/internal", map[string]interface{}{
"ttl": "40h",
"common_name": "myvault.com",
})
@ -2408,7 +2408,7 @@ func TestBackend_SignIntermediate_AllowedPastCA(t *testing.T) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "root/roles/test", map[string]interface{}{
_, err = client.Logical().Write("root/roles/test", map[string]interface{}{
"allow_bare_domains": true,
"allow_subdomains": true,
})
@ -2416,7 +2416,7 @@ func TestBackend_SignIntermediate_AllowedPastCA(t *testing.T) {
t.Fatal(err)
}
resp, err := client.Logical().WriteWithContext(context.Background(), "int/intermediate/generate/internal", map[string]interface{}{
resp, err := client.Logical().Write("int/intermediate/generate/internal", map[string]interface{}{
"common_name": "myint.com",
})
if err != nil {
@ -2425,7 +2425,7 @@ func TestBackend_SignIntermediate_AllowedPastCA(t *testing.T) {
csr := resp.Data["csr"]
_, err = client.Logical().WriteWithContext(context.Background(), "root/sign/test", map[string]interface{}{
_, err = client.Logical().Write("root/sign/test", map[string]interface{}{
"common_name": "myint.com",
"csr": csr,
"ttl": "60h",
@ -2434,7 +2434,7 @@ func TestBackend_SignIntermediate_AllowedPastCA(t *testing.T) {
t.Fatal("expected error")
}
_, err = client.Logical().WriteWithContext(context.Background(), "root/sign-verbatim/test", map[string]interface{}{
_, err = client.Logical().Write("root/sign-verbatim/test", map[string]interface{}{
"common_name": "myint.com",
"other_sans": "1.3.6.1.4.1.311.20.2.3;utf8:caadmin@example.com",
"csr": csr,
@ -2444,7 +2444,7 @@ func TestBackend_SignIntermediate_AllowedPastCA(t *testing.T) {
t.Fatal("expected error")
}
resp, err = client.Logical().WriteWithContext(context.Background(), "root/root/sign-intermediate", map[string]interface{}{
resp, err = client.Logical().Write("root/root/sign-intermediate", map[string]interface{}{
"common_name": "myint.com",
"other_sans": "1.3.6.1.4.1.311.20.2.3;utf8:caadmin@example.com",
"csr": csr,
@ -2772,7 +2772,7 @@ func TestBackend_OID_SANs(t *testing.T) {
client := cluster.Cores[0].Client
var err error
err = client.Sys().MountWithContext(context.Background(), "root", &api.MountInput{
err = client.Sys().Mount("root", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -2788,7 +2788,7 @@ func TestBackend_OID_SANs(t *testing.T) {
var block *pem.Block
var cert *x509.Certificate
_, err = client.Logical().WriteWithContext(context.Background(), "root/root/generate/internal", map[string]interface{}{
_, err = client.Logical().Write("root/root/generate/internal", map[string]interface{}{
"ttl": "40h",
"common_name": "myvault.com",
})
@ -2796,7 +2796,7 @@ func TestBackend_OID_SANs(t *testing.T) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "root/roles/test", map[string]interface{}{
_, err = client.Logical().Write("root/roles/test", map[string]interface{}{
"allowed_domains": []string{"foobar.com", "zipzap.com"},
"allow_bare_domains": true,
"allow_subdomains": true,
@ -2810,7 +2810,7 @@ func TestBackend_OID_SANs(t *testing.T) {
// Get a baseline before adding OID SANs. In the next sections we'll verify
// that the SANs are all added even as the OID SAN inclusion forces other
// adding logic (custom rather than built-in Golang logic)
resp, err = client.Logical().WriteWithContext(context.Background(), "root/issue/test", map[string]interface{}{
resp, err = client.Logical().Write("root/issue/test", map[string]interface{}{
"common_name": "foobar.com",
"ip_sans": "1.2.3.4",
"alt_names": "foobar.com,foo.foobar.com,bar.foobar.com",
@ -2836,7 +2836,7 @@ func TestBackend_OID_SANs(t *testing.T) {
}
// First test some bad stuff that shouldn't work
resp, err = client.Logical().WriteWithContext(context.Background(), "root/issue/test", map[string]interface{}{
resp, err = client.Logical().Write("root/issue/test", map[string]interface{}{
"common_name": "foobar.com",
"ip_sans": "1.2.3.4",
"alt_names": "foo.foobar.com,bar.foobar.com",
@ -2848,7 +2848,7 @@ func TestBackend_OID_SANs(t *testing.T) {
t.Fatal("expected error")
}
resp, err = client.Logical().WriteWithContext(context.Background(), "root/issue/test", map[string]interface{}{
resp, err = client.Logical().Write("root/issue/test", map[string]interface{}{
"common_name": "foobar.com",
"ip_sans": "1.2.3.4",
"alt_names": "foo.foobar.com,bar.foobar.com",
@ -2860,7 +2860,7 @@ func TestBackend_OID_SANs(t *testing.T) {
t.Fatal("expected error")
}
resp, err = client.Logical().WriteWithContext(context.Background(), "root/issue/test", map[string]interface{}{
resp, err = client.Logical().Write("root/issue/test", map[string]interface{}{
"common_name": "foobar.com",
"ip_sans": "1.2.3.4",
"alt_names": "foo.foobar.com,bar.foobar.com",
@ -2872,7 +2872,7 @@ func TestBackend_OID_SANs(t *testing.T) {
t.Fatal("expected error")
}
resp, err = client.Logical().WriteWithContext(context.Background(), "root/issue/test", map[string]interface{}{
resp, err = client.Logical().Write("root/issue/test", map[string]interface{}{
"common_name": "foobar.com",
"ip_sans": "1.2.3.4",
"alt_names": "foo.foobar.com,bar.foobar.com",
@ -2884,7 +2884,7 @@ func TestBackend_OID_SANs(t *testing.T) {
t.Fatal("expected error")
}
resp, err = client.Logical().WriteWithContext(context.Background(), "root/issue/test", map[string]interface{}{
resp, err = client.Logical().Write("root/issue/test", map[string]interface{}{
"common_name": "foobar.com",
"ip_sans": "1.2.3.4",
"alt_names": "foo.foobar.com,bar.foobar.com",
@ -2897,7 +2897,7 @@ func TestBackend_OID_SANs(t *testing.T) {
}
// Valid for first possibility
resp, err = client.Logical().WriteWithContext(context.Background(), "root/issue/test", map[string]interface{}{
resp, err = client.Logical().Write("root/issue/test", map[string]interface{}{
"common_name": "foobar.com",
"ip_sans": "1.2.3.4",
"alt_names": "foo.foobar.com,bar.foobar.com",
@ -2927,7 +2927,7 @@ func TestBackend_OID_SANs(t *testing.T) {
}
// Valid for second possibility
resp, err = client.Logical().WriteWithContext(context.Background(), "root/issue/test", map[string]interface{}{
resp, err = client.Logical().Write("root/issue/test", map[string]interface{}{
"common_name": "foobar.com",
"ip_sans": "1.2.3.4",
"alt_names": "foo.foobar.com,bar.foobar.com",
@ -2963,7 +2963,7 @@ func TestBackend_OID_SANs(t *testing.T) {
fmt.Sprintf("%s;%s:%s", oid1, type1, val1),
fmt.Sprintf("%s;%s:%s", oid2, type2, val2),
}
resp, err = client.Logical().WriteWithContext(context.Background(), "root/issue/test", map[string]interface{}{
resp, err = client.Logical().Write("root/issue/test", map[string]interface{}{
"common_name": "foobar.com",
"ip_sans": "1.2.3.4",
"alt_names": "foo.foobar.com,bar.foobar.com",
@ -3015,7 +3015,7 @@ func TestBackend_AllowedSerialNumbers(t *testing.T) {
client := cluster.Cores[0].Client
var err error
err = client.Sys().MountWithContext(context.Background(), "root", &api.MountInput{
err = client.Sys().Mount("root", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -3031,7 +3031,7 @@ func TestBackend_AllowedSerialNumbers(t *testing.T) {
var block *pem.Block
var cert *x509.Certificate
_, err = client.Logical().WriteWithContext(context.Background(), "root/root/generate/internal", map[string]interface{}{
_, err = client.Logical().Write("root/root/generate/internal", map[string]interface{}{
"ttl": "40h",
"common_name": "myvault.com",
})
@ -3040,7 +3040,7 @@ func TestBackend_AllowedSerialNumbers(t *testing.T) {
}
// First test that Serial Numbers are not allowed
_, err = client.Logical().WriteWithContext(context.Background(), "root/roles/test", map[string]interface{}{
_, err = client.Logical().Write("root/roles/test", map[string]interface{}{
"allow_any_name": true,
"enforce_hostnames": false,
})
@ -3048,7 +3048,7 @@ func TestBackend_AllowedSerialNumbers(t *testing.T) {
t.Fatal(err)
}
resp, err = client.Logical().WriteWithContext(context.Background(), "root/issue/test", map[string]interface{}{
resp, err = client.Logical().Write("root/issue/test", map[string]interface{}{
"common_name": "foobar",
"ttl": "1h",
})
@ -3056,7 +3056,7 @@ func TestBackend_AllowedSerialNumbers(t *testing.T) {
t.Fatal(err)
}
resp, err = client.Logical().WriteWithContext(context.Background(), "root/issue/test", map[string]interface{}{
resp, err = client.Logical().Write("root/issue/test", map[string]interface{}{
"common_name": "foobar",
"ttl": "1h",
"serial_number": "foobar",
@ -3066,7 +3066,7 @@ func TestBackend_AllowedSerialNumbers(t *testing.T) {
}
// Update the role to allow serial numbers
_, err = client.Logical().WriteWithContext(context.Background(), "root/roles/test", map[string]interface{}{
_, err = client.Logical().Write("root/roles/test", map[string]interface{}{
"allow_any_name": true,
"enforce_hostnames": false,
"allowed_serial_numbers": "f00*,b4r*",
@ -3075,7 +3075,7 @@ func TestBackend_AllowedSerialNumbers(t *testing.T) {
t.Fatal(err)
}
resp, err = client.Logical().WriteWithContext(context.Background(), "root/issue/test", map[string]interface{}{
resp, err = client.Logical().Write("root/issue/test", map[string]interface{}{
"common_name": "foobar",
"ttl": "1h",
// Not a valid serial number
@ -3086,7 +3086,7 @@ func TestBackend_AllowedSerialNumbers(t *testing.T) {
}
// Valid for first possibility
resp, err = client.Logical().WriteWithContext(context.Background(), "root/issue/test", map[string]interface{}{
resp, err = client.Logical().Write("root/issue/test", map[string]interface{}{
"common_name": "foobar",
"serial_number": "f00bar",
})
@ -3107,7 +3107,7 @@ func TestBackend_AllowedSerialNumbers(t *testing.T) {
}
// Valid for second possibility
resp, err = client.Logical().WriteWithContext(context.Background(), "root/issue/test", map[string]interface{}{
resp, err = client.Logical().Write("root/issue/test", map[string]interface{}{
"common_name": "foobar",
"serial_number": "b4rf00",
})
@ -3142,7 +3142,7 @@ func TestBackend_URI_SANs(t *testing.T) {
client := cluster.Cores[0].Client
var err error
err = client.Sys().MountWithContext(context.Background(), "root", &api.MountInput{
err = client.Sys().Mount("root", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -3153,7 +3153,7 @@ func TestBackend_URI_SANs(t *testing.T) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "root/root/generate/internal", map[string]interface{}{
_, err = client.Logical().Write("root/root/generate/internal", map[string]interface{}{
"ttl": "40h",
"common_name": "myvault.com",
})
@ -3161,7 +3161,7 @@ func TestBackend_URI_SANs(t *testing.T) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "root/roles/test", map[string]interface{}{
_, err = client.Logical().Write("root/roles/test", map[string]interface{}{
"allowed_domains": []string{"foobar.com", "zipzap.com"},
"allow_bare_domains": true,
"allow_subdomains": true,
@ -3173,7 +3173,7 @@ func TestBackend_URI_SANs(t *testing.T) {
}
// First test some bad stuff that shouldn't work
_, err = client.Logical().WriteWithContext(context.Background(), "root/issue/test", map[string]interface{}{
_, err = client.Logical().Write("root/issue/test", map[string]interface{}{
"common_name": "foobar.com",
"ip_sans": "1.2.3.4",
"alt_names": "foo.foobar.com,bar.foobar.com",
@ -3185,7 +3185,7 @@ func TestBackend_URI_SANs(t *testing.T) {
}
// Test valid single entry
_, err = client.Logical().WriteWithContext(context.Background(), "root/issue/test", map[string]interface{}{
_, err = client.Logical().Write("root/issue/test", map[string]interface{}{
"common_name": "foobar.com",
"ip_sans": "1.2.3.4",
"alt_names": "foo.foobar.com,bar.foobar.com",
@ -3197,7 +3197,7 @@ func TestBackend_URI_SANs(t *testing.T) {
}
// Test globed entry
_, err = client.Logical().WriteWithContext(context.Background(), "root/issue/test", map[string]interface{}{
_, err = client.Logical().Write("root/issue/test", map[string]interface{}{
"common_name": "foobar.com",
"ip_sans": "1.2.3.4",
"alt_names": "foo.foobar.com,bar.foobar.com",
@ -3209,7 +3209,7 @@ func TestBackend_URI_SANs(t *testing.T) {
}
// Test multiple entries
resp, err := client.Logical().WriteWithContext(context.Background(), "root/issue/test", map[string]interface{}{
resp, err := client.Logical().Write("root/issue/test", map[string]interface{}{
"common_name": "foobar.com",
"ip_sans": "1.2.3.4",
"alt_names": "foo.foobar.com,bar.foobar.com",
@ -3258,7 +3258,7 @@ func TestBackend_AllowedURISANsTemplate(t *testing.T) {
client := cluster.Cores[0].Client
// Write test policy for userpass auth method.
err := client.Sys().PutPolicyWithContext(context.Background(), "test", `
err := client.Sys().PutPolicy("test", `
path "pki/*" {
capabilities = ["update"]
}`)
@ -3272,7 +3272,7 @@ func TestBackend_AllowedURISANsTemplate(t *testing.T) {
}
// Configure test role for userpass.
if _, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/userpassname", map[string]interface{}{
if _, err := client.Logical().Write("auth/userpass/users/userpassname", map[string]interface{}{
"password": "test",
"policies": "test",
}); err != nil {
@ -3280,7 +3280,7 @@ func TestBackend_AllowedURISANsTemplate(t *testing.T) {
}
// Login userpass for test role and keep client token.
secret, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/login/userpassname", map[string]interface{}{
secret, err := client.Logical().Write("auth/userpass/login/userpassname", map[string]interface{}{
"password": "test",
})
if err != nil || secret == nil {
@ -3289,14 +3289,14 @@ func TestBackend_AllowedURISANsTemplate(t *testing.T) {
userpassToken := secret.Auth.ClientToken
// Get auth accessor for identity template.
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}
userpassAccessor := auths["userpass/"].Accessor
// Mount PKI.
err = client.Sys().MountWithContext(context.Background(), "pki", &api.MountInput{
err = client.Sys().Mount("pki", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -3308,7 +3308,7 @@ func TestBackend_AllowedURISANsTemplate(t *testing.T) {
}
// Generate internal CA.
_, err = client.Logical().WriteWithContext(context.Background(), "pki/root/generate/internal", map[string]interface{}{
_, err = client.Logical().Write("pki/root/generate/internal", map[string]interface{}{
"ttl": "40h",
"common_name": "myvault.com",
})
@ -3317,7 +3317,7 @@ func TestBackend_AllowedURISANsTemplate(t *testing.T) {
}
// Write role PKI.
_, err = client.Logical().WriteWithContext(context.Background(), "pki/roles/test", map[string]interface{}{
_, err = client.Logical().Write("pki/roles/test", map[string]interface{}{
"allowed_uri_sans": []string{
"spiffe://domain/{{identity.entity.aliases." + userpassAccessor + ".name}}",
"spiffe://domain/{{identity.entity.aliases." + userpassAccessor + ".name}}/*", "spiffe://domain/foo",
@ -3331,27 +3331,27 @@ func TestBackend_AllowedURISANsTemplate(t *testing.T) {
// Issue certificate with identity templating
client.SetToken(userpassToken)
_, err = client.Logical().WriteWithContext(context.Background(), "pki/issue/test", map[string]interface{}{"uri_sans": "spiffe://domain/userpassname, spiffe://domain/foo"})
_, err = client.Logical().Write("pki/issue/test", map[string]interface{}{"uri_sans": "spiffe://domain/userpassname, spiffe://domain/foo"})
if err != nil {
t.Fatal(err)
}
// Issue certificate with identity templating and glob
client.SetToken(userpassToken)
_, err = client.Logical().WriteWithContext(context.Background(), "pki/issue/test", map[string]interface{}{"uri_sans": "spiffe://domain/userpassname/bar"})
_, err = client.Logical().Write("pki/issue/test", map[string]interface{}{"uri_sans": "spiffe://domain/userpassname/bar"})
if err != nil {
t.Fatal(err)
}
// Issue certificate with non-matching identity template parameter
client.SetToken(userpassToken)
_, err = client.Logical().WriteWithContext(context.Background(), "pki/issue/test", map[string]interface{}{"uri_sans": "spiffe://domain/unknownuser"})
_, err = client.Logical().Write("pki/issue/test", map[string]interface{}{"uri_sans": "spiffe://domain/unknownuser"})
if err == nil {
t.Fatal(err)
}
// Set allowed_uri_sans_template to false.
_, err = client.Logical().WriteWithContext(context.Background(), "pki/roles/test", map[string]interface{}{
_, err = client.Logical().Write("pki/roles/test", map[string]interface{}{
"allowed_uri_sans_template": false,
})
if err != nil {
@ -3359,7 +3359,7 @@ func TestBackend_AllowedURISANsTemplate(t *testing.T) {
}
// Issue certificate with userpassToken.
_, err = client.Logical().WriteWithContext(context.Background(), "pki/issue/test", map[string]interface{}{"uri_sans": "spiffe://domain/users/userpassname"})
_, err = client.Logical().Write("pki/issue/test", map[string]interface{}{"uri_sans": "spiffe://domain/users/userpassname"})
if err == nil {
t.Fatal("expected error")
}
@ -3382,7 +3382,7 @@ func TestBackend_AllowedDomainsTemplate(t *testing.T) {
client := cluster.Cores[0].Client
// Write test policy for userpass auth method.
err := client.Sys().PutPolicyWithContext(context.Background(), "test", `
err := client.Sys().PutPolicy("test", `
path "pki/*" {
capabilities = ["update"]
}`)
@ -3396,7 +3396,7 @@ func TestBackend_AllowedDomainsTemplate(t *testing.T) {
}
// Configure test role for userpass.
if _, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/userpassname", map[string]interface{}{
if _, err := client.Logical().Write("auth/userpass/users/userpassname", map[string]interface{}{
"password": "test",
"policies": "test",
}); err != nil {
@ -3410,14 +3410,14 @@ func TestBackend_AllowedDomainsTemplate(t *testing.T) {
}
// Get auth accessor for identity template.
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}
userpassAccessor := auths["userpass/"].Accessor
// Mount PKI.
err = client.Sys().MountWithContext(context.Background(), "pki", &api.MountInput{
err = client.Sys().Mount("pki", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -3429,7 +3429,7 @@ func TestBackend_AllowedDomainsTemplate(t *testing.T) {
}
// Generate internal CA.
_, err = client.Logical().WriteWithContext(context.Background(), "pki/root/generate/internal", map[string]interface{}{
_, err = client.Logical().Write("pki/root/generate/internal", map[string]interface{}{
"ttl": "40h",
"common_name": "myvault.com",
})
@ -3438,7 +3438,7 @@ func TestBackend_AllowedDomainsTemplate(t *testing.T) {
}
// Write role PKI.
_, err = client.Logical().WriteWithContext(context.Background(), "pki/roles/test", map[string]interface{}{
_, err = client.Logical().Write("pki/roles/test", map[string]interface{}{
"allowed_domains": []string{
"foobar.com", "zipzap.com", "{{identity.entity.aliases." + userpassAccessor + ".name}}",
"foo.{{identity.entity.aliases." + userpassAccessor + ".name}}.example.com",
@ -3458,31 +3458,31 @@ func TestBackend_AllowedDomainsTemplate(t *testing.T) {
if err != nil || secret == nil {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "pki/issue/test", map[string]interface{}{"common_name": "userpassname"})
_, err = client.Logical().Write("pki/issue/test", map[string]interface{}{"common_name": "userpassname"})
if err != nil {
t.Fatal(err)
}
// Issue certificate for foobar.com to verify allowed_domain_templae doesnt break plain domains.
_, err = client.Logical().WriteWithContext(context.Background(), "pki/issue/test", map[string]interface{}{"common_name": "foobar.com"})
_, err = client.Logical().Write("pki/issue/test", map[string]interface{}{"common_name": "foobar.com"})
if err != nil {
t.Fatal(err)
}
// Issue certificate for unknown userpassname.
_, err = client.Logical().WriteWithContext(context.Background(), "pki/issue/test", map[string]interface{}{"common_name": "unknownuserpassname"})
_, err = client.Logical().Write("pki/issue/test", map[string]interface{}{"common_name": "unknownuserpassname"})
if err == nil {
t.Fatal("expected error")
}
// Issue certificate for foo.userpassname.domain.
_, err = client.Logical().WriteWithContext(context.Background(), "pki/issue/test", map[string]interface{}{"common_name": "foo.userpassname.example.com"})
_, err = client.Logical().Write("pki/issue/test", map[string]interface{}{"common_name": "foo.userpassname.example.com"})
if err != nil {
t.Fatal("expected error")
}
// Set allowed_domains_template to false.
_, err = client.Logical().WriteWithContext(context.Background(), "pki/roles/test", map[string]interface{}{
_, err = client.Logical().Write("pki/roles/test", map[string]interface{}{
"allowed_domains_template": false,
})
if err != nil {
@ -3490,7 +3490,7 @@ func TestBackend_AllowedDomainsTemplate(t *testing.T) {
}
// Issue certificate with userpassToken.
_, err = client.Logical().WriteWithContext(context.Background(), "pki/issue/test", map[string]interface{}{"common_name": "userpassname"})
_, err = client.Logical().Write("pki/issue/test", map[string]interface{}{"common_name": "userpassname"})
if err == nil {
t.Fatal("expected error")
}
@ -3752,7 +3752,7 @@ func TestBackend_RevokePlusTidy_Intermediate(t *testing.T) {
var err error
// Mount /pki as a root CA
err = client.Sys().MountWithContext(context.Background(), "pki", &api.MountInput{
err = client.Sys().Mount("pki", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -3765,7 +3765,7 @@ func TestBackend_RevokePlusTidy_Intermediate(t *testing.T) {
// Set the cluster's certificate as the root CA in /pki
pemBundleRootCA := string(cluster.CACertPEM) + string(cluster.CAKeyPEM)
_, err = client.Logical().WriteWithContext(context.Background(), "pki/config/ca", map[string]interface{}{
_, err = client.Logical().Write("pki/config/ca", map[string]interface{}{
"pem_bundle": pemBundleRootCA,
})
if err != nil {
@ -3773,7 +3773,7 @@ func TestBackend_RevokePlusTidy_Intermediate(t *testing.T) {
}
// Mount /pki2 to operate as an intermediate CA
err = client.Sys().MountWithContext(context.Background(), "pki2", &api.MountInput{
err = client.Sys().Mount("pki2", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -3785,14 +3785,14 @@ func TestBackend_RevokePlusTidy_Intermediate(t *testing.T) {
}
// Create a CSR for the intermediate CA
secret, err := client.Logical().WriteWithContext(context.Background(), "pki2/intermediate/generate/internal", nil)
secret, err := client.Logical().Write("pki2/intermediate/generate/internal", nil)
if err != nil {
t.Fatal(err)
}
intermediateCSR := secret.Data["csr"].(string)
// Sign the intermediate CSR using /pki
secret, err = client.Logical().WriteWithContext(context.Background(), "pki/root/sign-intermediate", map[string]interface{}{
secret, err = client.Logical().Write("pki/root/sign-intermediate", map[string]interface{}{
"permitted_dns_domains": ".myvault.com",
"csr": intermediateCSR,
"ttl": "10s",
@ -3804,7 +3804,7 @@ func TestBackend_RevokePlusTidy_Intermediate(t *testing.T) {
intermediateCASerialColon := strings.ReplaceAll(strings.ToLower(intermediateCertSerial), ":", "-")
// Get the intermediate cert after signing
secret, err = client.Logical().ReadWithContext(context.Background(), "pki/cert/"+intermediateCASerialColon)
secret, err = client.Logical().Read("pki/cert/" + intermediateCASerialColon)
if err != nil {
t.Fatal(err)
}
@ -3813,7 +3813,7 @@ func TestBackend_RevokePlusTidy_Intermediate(t *testing.T) {
}
// Issue a revoke on on /pki
_, err = client.Logical().WriteWithContext(context.Background(), "pki/revoke", map[string]interface{}{
_, err = client.Logical().Write("pki/revoke", map[string]interface{}{
"serial_number": intermediateCertSerial,
})
if err != nil {
@ -3825,7 +3825,7 @@ func TestBackend_RevokePlusTidy_Intermediate(t *testing.T) {
time.Sleep(3 * time.Second)
// Issue a tidy on /pki
_, err = client.Logical().WriteWithContext(context.Background(), "pki/tidy", map[string]interface{}{
_, err = client.Logical().Write("pki/tidy", map[string]interface{}{
"tidy_cert_store": true,
"tidy_revoked_certs": true,
"safety_buffer": "1s",
@ -3873,7 +3873,7 @@ func TestBackend_RevokePlusTidy_Intermediate(t *testing.T) {
time.Sleep(10 * time.Second)
// Issue a tidy on /pki
_, err = client.Logical().WriteWithContext(context.Background(), "pki/tidy", map[string]interface{}{
_, err = client.Logical().Write("pki/tidy", map[string]interface{}{
"tidy_cert_store": true,
"tidy_revoked_certs": true,
"safety_buffer": "1s",
@ -3887,7 +3887,7 @@ func TestBackend_RevokePlusTidy_Intermediate(t *testing.T) {
// Issue a tidy-status on /pki
{
tidyStatus, err := client.Logical().ReadWithContext(context.Background(), "pki/tidy-status")
tidyStatus, err := client.Logical().Read("pki/tidy-status")
if err != nil {
t.Fatal(err)
}
@ -4028,7 +4028,7 @@ func runFullCAChainTest(t *testing.T, keyType string) {
var err error
// Generate a root CA at /pki-root
err = client.Sys().MountWithContext(context.Background(), "pki-root", &api.MountInput{
err = client.Sys().Mount("pki-root", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -4039,7 +4039,7 @@ func runFullCAChainTest(t *testing.T, keyType string) {
t.Fatal(err)
}
resp, err := client.Logical().WriteWithContext(context.Background(), "pki-root/root/generate/exported", map[string]interface{}{
resp, err := client.Logical().Write("pki-root/root/generate/exported", map[string]interface{}{
"common_name": "root myvault.com",
"key_type": keyType,
})
@ -4053,7 +4053,7 @@ func runFullCAChainTest(t *testing.T, keyType string) {
rootCert := rootData["certificate"].(string)
// Validate that root's /cert/ca-chain now contains the certificate.
resp, err = client.Logical().ReadWithContext(context.Background(), "pki-root/cert/ca_chain")
resp, err = client.Logical().Read("pki-root/cert/ca_chain")
if err != nil {
t.Fatal(err)
}
@ -4067,7 +4067,7 @@ func runFullCAChainTest(t *testing.T, keyType string) {
}
// Now generate an intermediate at /pki-intermediate, signed by the root.
err = client.Sys().MountWithContext(context.Background(), "pki-intermediate", &api.MountInput{
err = client.Sys().Mount("pki-intermediate", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -4078,7 +4078,7 @@ func runFullCAChainTest(t *testing.T, keyType string) {
t.Fatal(err)
}
resp, err = client.Logical().WriteWithContext(context.Background(), "pki-intermediate/intermediate/generate/exported", map[string]interface{}{
resp, err = client.Logical().Write("pki-intermediate/intermediate/generate/exported", map[string]interface{}{
"common_name": "intermediate myvault.com",
"key_type": keyType,
})
@ -4091,7 +4091,7 @@ func runFullCAChainTest(t *testing.T, keyType string) {
intermediateData := resp.Data
intermediateKey := intermediateData["private_key"].(string)
resp, err = client.Logical().WriteWithContext(context.Background(), "pki-root/root/sign-intermediate", map[string]interface{}{
resp, err = client.Logical().Write("pki-root/root/sign-intermediate", map[string]interface{}{
"csr": intermediateData["csr"],
"format": "pem_bundle",
})
@ -4108,7 +4108,7 @@ func runFullCAChainTest(t *testing.T, keyType string) {
intermediaryCaCert := parseCert(t, intermediateCert)
requireSignedBy(t, intermediaryCaCert, rootCaCert.PublicKey)
resp, err = client.Logical().WriteWithContext(context.Background(), "pki-intermediate/intermediate/set-signed", map[string]interface{}{
resp, err = client.Logical().Write("pki-intermediate/intermediate/set-signed", map[string]interface{}{
"certificate": intermediateCert + "\n" + rootCert + "\n",
})
if err != nil {
@ -4117,7 +4117,7 @@ func runFullCAChainTest(t *testing.T, keyType string) {
// Validate that intermediate's ca_chain field now includes the full
// chain.
resp, err = client.Logical().ReadWithContext(context.Background(), "pki-intermediate/cert/ca_chain")
resp, err = client.Logical().Read("pki-intermediate/cert/ca_chain")
if err != nil {
t.Fatal(err)
}
@ -4135,7 +4135,7 @@ func runFullCAChainTest(t *testing.T, keyType string) {
// Finally, import this signing cert chain into a new mount to ensure
// "external" CAs behave as expected.
err = client.Sys().MountWithContext(context.Background(), "pki-external", &api.MountInput{
err = client.Sys().Mount("pki-external", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -4146,7 +4146,7 @@ func runFullCAChainTest(t *testing.T, keyType string) {
t.Fatal(err)
}
resp, err = client.Logical().WriteWithContext(context.Background(), "pki-external/config/ca", map[string]interface{}{
resp, err = client.Logical().Write("pki-external/config/ca", map[string]interface{}{
"pem_bundle": intermediateKey + "\n" + intermediateCert + "\n" + rootCert + "\n",
})
if err != nil {
@ -4154,7 +4154,7 @@ func runFullCAChainTest(t *testing.T, keyType string) {
}
// Validate the external chain information was loaded correctly.
resp, err = client.Logical().ReadWithContext(context.Background(), "pki-external/cert/ca_chain")
resp, err = client.Logical().Read("pki-external/cert/ca_chain")
if err != nil {
t.Fatal(err)
}
@ -4234,7 +4234,7 @@ func RoleIssuanceRegressionHelper(t *testing.T, client *api.Client, index int, t
for _, AllowLocalhost := range test.AllowLocalhost.ToValues() {
for _, AllowWildcardCertificates := range test.AllowWildcardCertificates.ToValues() {
role := fmt.Sprintf("issuance-regression-%d-bare-%v-glob-%v-subdomains-%v-localhost-%v-wildcard-%v", index, AllowBareDomains, AllowGlobDomains, AllowSubdomains, AllowLocalhost, AllowWildcardCertificates)
resp, err := client.Logical().WriteWithContext(context.Background(), "pki/roles/"+role, map[string]interface{}{
resp, err := client.Logical().Write("pki/roles/"+role, map[string]interface{}{
"allowed_domains": test.AllowedDomains,
"allow_bare_domains": AllowBareDomains,
"allow_glob_domains": AllowGlobDomains,
@ -4251,7 +4251,7 @@ func RoleIssuanceRegressionHelper(t *testing.T, client *api.Client, index int, t
t.Fatal(err)
}
resp, err = client.Logical().WriteWithContext(context.Background(), "pki/issue/"+role, map[string]interface{}{
resp, err = client.Logical().Write("pki/issue/"+role, map[string]interface{}{
"common_name": test.CommonName,
})
@ -4442,7 +4442,7 @@ func TestBackend_Roles_IssuanceRegression(t *testing.T) {
var err error
// Generate a root CA at /pki to use for our tests
err = client.Sys().MountWithContext(context.Background(), "pki", &api.MountInput{
err = client.Sys().Mount("pki", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "12h",
@ -4454,7 +4454,7 @@ func TestBackend_Roles_IssuanceRegression(t *testing.T) {
}
// We need a RSA key so all signature sizes are valid with it.
resp, err := client.Logical().WriteWithContext(context.Background(), "pki/root/generate/exported", map[string]interface{}{
resp, err := client.Logical().Write("pki/root/generate/exported", map[string]interface{}{
"common_name": "myvault.com",
"ttl": "128h",
"key_type": "rsa",

View File

@ -155,7 +155,7 @@ func TestBackend_CA_Steps(t *testing.T) {
// Setup backends
var rsaRoot, rsaInt, ecRoot, ecInt, edRoot, edInt *backend
{
if err := client.Sys().MountWithContext(context.Background(), "rsaroot", &api.MountInput{
if err := client.Sys().Mount("rsaroot", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -166,7 +166,7 @@ func TestBackend_CA_Steps(t *testing.T) {
}
rsaRoot = b
if err := client.Sys().MountWithContext(context.Background(), "rsaint", &api.MountInput{
if err := client.Sys().Mount("rsaint", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -177,7 +177,7 @@ func TestBackend_CA_Steps(t *testing.T) {
}
rsaInt = b
if err := client.Sys().MountWithContext(context.Background(), "ecroot", &api.MountInput{
if err := client.Sys().Mount("ecroot", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -188,7 +188,7 @@ func TestBackend_CA_Steps(t *testing.T) {
}
ecRoot = b
if err := client.Sys().MountWithContext(context.Background(), "ecint", &api.MountInput{
if err := client.Sys().Mount("ecint", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -199,7 +199,7 @@ func TestBackend_CA_Steps(t *testing.T) {
}
ecInt = b
if err := client.Sys().MountWithContext(context.Background(), "ed25519root", &api.MountInput{
if err := client.Sys().Mount("ed25519root", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -210,7 +210,7 @@ func TestBackend_CA_Steps(t *testing.T) {
}
edRoot = b
if err := client.Sys().MountWithContext(context.Background(), "ed25519int", &api.MountInput{
if err := client.Sys().Mount("ed25519int", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -259,7 +259,7 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
{
// Attempt import but only provide one the cert
{
_, err := client.Logical().WriteWithContext(context.Background(), rootName+"config/ca", map[string]interface{}{
_, err := client.Logical().Write(rootName+"config/ca", map[string]interface{}{
"pem_bundle": caCert,
})
if err == nil {
@ -269,7 +269,7 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
// Same but with only the key
{
_, err := client.Logical().WriteWithContext(context.Background(), rootName+"config/ca", map[string]interface{}{
_, err := client.Logical().Write(rootName+"config/ca", map[string]interface{}{
"pem_bundle": caKey,
})
if err == nil {
@ -279,7 +279,7 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
// Import CA bundle
{
_, err := client.Logical().WriteWithContext(context.Background(), rootName+"config/ca", map[string]interface{}{
_, err := client.Logical().Write(rootName+"config/ca", map[string]interface{}{
"pem_bundle": strings.Join([]string{caKey, caCert}, "\n"),
})
if err != nil {
@ -292,7 +292,7 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
// cert/ca path
{
resp, err := client.Logical().ReadWithContext(context.Background(), rootName+"cert/ca")
resp, err := client.Logical().Read(rootName + "cert/ca")
if err != nil {
t.Fatal(err)
}
@ -359,7 +359,7 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
{
// Set CRL config
{
_, err := client.Logical().WriteWithContext(context.Background(), rootName+"config/crl", map[string]interface{}{
_, err := client.Logical().Write(rootName+"config/crl", map[string]interface{}{
"expiry": "16h",
})
if err != nil {
@ -369,7 +369,7 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
// Verify it
{
resp, err := client.Logical().ReadWithContext(context.Background(), rootName+"config/crl")
resp, err := client.Logical().Read(rootName + "config/crl")
if err != nil {
t.Fatal(err)
}
@ -390,7 +390,7 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
{
// First, delete the existing CA info
{
_, err := client.Logical().DeleteWithContext(context.Background(), rootName+"root")
_, err := client.Logical().Delete(rootName + "root")
if err != nil {
t.Fatal(err)
}
@ -399,7 +399,7 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
var rootPEM, rootKey, rootPEMBundle string
// Test exported root generation
{
resp, err := client.Logical().WriteWithContext(context.Background(), rootName+"root/generate/exported", map[string]interface{}{
resp, err := client.Logical().Write(rootName+"root/generate/exported", map[string]interface{}{
"common_name": "Root Cert",
"ttl": "180h",
})
@ -421,7 +421,7 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
var intPEM, intCSR, intKey string
// Test exported intermediate CSR generation
{
resp, err := client.Logical().WriteWithContext(context.Background(), intName+"intermediate/generate/exported", map[string]interface{}{
resp, err := client.Logical().Write(intName+"intermediate/generate/exported", map[string]interface{}{
"common_name": "intermediate.cert.com",
"ttl": "180h",
})
@ -441,7 +441,7 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
// Test signing
{
resp, err := client.Logical().WriteWithContext(context.Background(), rootName+"root/sign-intermediate", map[string]interface{}{
resp, err := client.Logical().Write(rootName+"root/sign-intermediate", map[string]interface{}{
"common_name": "intermediate.cert.com",
"ttl": "10s",
"csr": intCSR,
@ -458,7 +458,7 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
// Test setting signed
{
resp, err := client.Logical().WriteWithContext(context.Background(), intName+"intermediate/set-signed", map[string]interface{}{
resp, err := client.Logical().Write(intName+"intermediate/set-signed", map[string]interface{}{
"certificate": intPEM,
})
if err != nil {
@ -471,7 +471,7 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
// Verify we can find it via the root
{
resp, err := client.Logical().ReadWithContext(context.Background(), rootName+"cert/"+intSerialNumber)
resp, err := client.Logical().Read(rootName + "cert/" + intSerialNumber)
if err != nil {
t.Fatal(err)
}
@ -485,7 +485,7 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
// Revoke the intermediate
{
resp, err := client.Logical().WriteWithContext(context.Background(), rootName+"revoke", map[string]interface{}{
resp, err := client.Logical().Write(rootName+"revoke", map[string]interface{}{
"serial_number": intSerialNumber,
})
if err != nil {
@ -501,7 +501,7 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
t.Helper()
// Verify it is now revoked
{
resp, err := client.Logical().ReadWithContext(context.Background(), rootName+"cert/"+intSerialNumber)
resp, err := client.Logical().Read(rootName + "cert/" + intSerialNumber)
if err != nil {
t.Fatal(err)
}
@ -559,7 +559,7 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
}
verifyTidyStatus := func(expectedCertStoreDeleteCount int, expectedRevokedCertDeletedCount int) {
tidyStatus, err := client.Logical().ReadWithContext(context.Background(), rootName+"tidy-status")
tidyStatus, err := client.Logical().Read(rootName + "tidy-status")
if err != nil {
t.Fatal(err)
}
@ -594,7 +594,7 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
{
// Run with a high safety buffer, nothing should happen
{
resp, err := client.Logical().WriteWithContext(context.Background(), rootName+"tidy", map[string]interface{}{
resp, err := client.Logical().Write(rootName+"tidy", map[string]interface{}{
"safety_buffer": "3h",
"tidy_cert_store": true,
"tidy_revoked_certs": true,
@ -617,7 +617,7 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
// Run with both values set false, nothing should happen
{
resp, err := client.Logical().WriteWithContext(context.Background(), rootName+"tidy", map[string]interface{}{
resp, err := client.Logical().Write(rootName+"tidy", map[string]interface{}{
"safety_buffer": "1s",
"tidy_cert_store": false,
"tidy_revoked_certs": false,
@ -640,7 +640,7 @@ func runSteps(t *testing.T, rootB, intB *backend, client *api.Client, rootName,
// Run with a short safety buffer and both set to true, both should be cleared
{
resp, err := client.Logical().WriteWithContext(context.Background(), rootName+"tidy", map[string]interface{}{
resp, err := client.Logical().Write(rootName+"tidy", map[string]interface{}{
"safety_buffer": "1s",
"tidy_cert_store": true,
"tidy_revoked_certs": true,

View File

@ -28,7 +28,7 @@ func TestBackend_CRL_EnableDisable(t *testing.T) {
client := cluster.Cores[0].Client
var err error
err = client.Sys().MountWithContext(context.Background(), "pki", &api.MountInput{
err = client.Sys().Mount("pki", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -36,7 +36,7 @@ func TestBackend_CRL_EnableDisable(t *testing.T) {
},
})
resp, err := client.Logical().WriteWithContext(context.Background(), "pki/root/generate/internal", map[string]interface{}{
resp, err := client.Logical().Write("pki/root/generate/internal", map[string]interface{}{
"ttl": "40h",
"common_name": "myvault.com",
})
@ -45,7 +45,7 @@ func TestBackend_CRL_EnableDisable(t *testing.T) {
}
caSerial := resp.Data["serial_number"]
_, err = client.Logical().WriteWithContext(context.Background(), "pki/roles/test", map[string]interface{}{
_, err = client.Logical().Write("pki/roles/test", map[string]interface{}{
"allow_bare_domains": true,
"allow_subdomains": true,
"allowed_domains": "foobar.com",
@ -57,7 +57,7 @@ func TestBackend_CRL_EnableDisable(t *testing.T) {
serials := make(map[int]string)
for i := 0; i < 6; i++ {
resp, err := client.Logical().WriteWithContext(context.Background(), "pki/issue/test", map[string]interface{}{
resp, err := client.Logical().Write("pki/issue/test", map[string]interface{}{
"common_name": "test.foobar.com",
})
if err != nil {
@ -75,14 +75,14 @@ func TestBackend_CRL_EnableDisable(t *testing.T) {
}
revoke := func(num int) {
resp, err = client.Logical().WriteWithContext(context.Background(), "pki/revoke", map[string]interface{}{
resp, err = client.Logical().Write("pki/revoke", map[string]interface{}{
"serial_number": serials[num],
})
if err != nil {
t.Fatal(err)
}
resp, err = client.Logical().WriteWithContext(context.Background(), "pki/revoke", map[string]interface{}{
resp, err = client.Logical().Write("pki/revoke", map[string]interface{}{
"serial_number": caSerial,
})
if err == nil {
@ -91,7 +91,7 @@ func TestBackend_CRL_EnableDisable(t *testing.T) {
}
toggle := func(disabled bool) {
_, err = client.Logical().WriteWithContext(context.Background(), "pki/config/crl", map[string]interface{}{
_, err = client.Logical().Write("pki/config/crl", map[string]interface{}{
"disable": disabled,
})
if err != nil {

View File

@ -1464,14 +1464,14 @@ func TestBackend_DefExtTemplatingEnabled(t *testing.T) {
client := cluster.Cores[0].Client
// Get auth accessor for identity template.
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}
userpassAccessor := auths["userpass/"].Accessor
// Write SSH role.
_, err = client.Logical().WriteWithContext(context.Background(), "ssh/roles/test", map[string]interface{}{
_, err = client.Logical().Write("ssh/roles/test", map[string]interface{}{
"key_type": "ca",
"allowed_extensions": "login@zipzap.com",
"allow_user_certificates": true,
@ -1490,7 +1490,7 @@ func TestBackend_DefExtTemplatingEnabled(t *testing.T) {
// Issue SSH certificate with default extensions templating enabled, and no user-provided extensions
client.SetToken(userpassToken)
resp, err := client.Logical().WriteWithContext(context.Background(), "ssh/sign/test", map[string]interface{}{
resp, err := client.Logical().Write("ssh/sign/test", map[string]interface{}{
"public_key": publicKey4096,
})
if err != nil {
@ -1518,7 +1518,7 @@ func TestBackend_DefExtTemplatingEnabled(t *testing.T) {
userProvidedExtensionPermissions := map[string]string{
"login@zipzap.com": "some_other_user_name",
}
resp, err = client.Logical().WriteWithContext(context.Background(), "ssh/sign/test", map[string]interface{}{
resp, err = client.Logical().Write("ssh/sign/test", map[string]interface{}{
"public_key": publicKey4096,
"extensions": userProvidedExtensionPermissions,
})
@ -1542,7 +1542,7 @@ func TestBackend_DefExtTemplatingEnabled(t *testing.T) {
invalidUserProvidedExtensionPermissions := map[string]string{
"login@foobar.com": "{{identity.entity.metadata}}",
}
resp, err = client.Logical().WriteWithContext(context.Background(), "ssh/sign/test", map[string]interface{}{
resp, err = client.Logical().Write("ssh/sign/test", map[string]interface{}{
"public_key": publicKey4096,
"extensions": invalidUserProvidedExtensionPermissions,
})
@ -1557,7 +1557,7 @@ func TestBackend_EmptyAllowedExtensionFailsClosed(t *testing.T) {
client := cluster.Cores[0].Client
// Get auth accessor for identity template.
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}
@ -1565,7 +1565,7 @@ func TestBackend_EmptyAllowedExtensionFailsClosed(t *testing.T) {
// Write SSH role to test with no allowed extension. We also provide a templated default extension,
// to verify that it's not actually being evaluated
_, err = client.Logical().WriteWithContext(context.Background(), "ssh/roles/test_allow_all_extensions", map[string]interface{}{
_, err = client.Logical().Write("ssh/roles/test_allow_all_extensions", map[string]interface{}{
"key_type": "ca",
"allow_user_certificates": true,
"allowed_users": "tuber",
@ -1585,7 +1585,7 @@ func TestBackend_EmptyAllowedExtensionFailsClosed(t *testing.T) {
userProvidedAnyExtensionPermissions := map[string]string{
"login@foobar.com": "not_userpassname",
}
_, err = client.Logical().WriteWithContext(context.Background(), "ssh/sign/test_allow_all_extensions", map[string]interface{}{
_, err = client.Logical().Write("ssh/sign/test_allow_all_extensions", map[string]interface{}{
"public_key": publicKey4096,
"extensions": userProvidedAnyExtensionPermissions,
})
@ -1604,7 +1604,7 @@ func TestBackend_DefExtTemplatingDisabled(t *testing.T) {
client := cluster.Cores[0].Client
// Get auth accessor for identity template.
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}
@ -1612,7 +1612,7 @@ func TestBackend_DefExtTemplatingDisabled(t *testing.T) {
// Write SSH role to test with any extension. We also provide a templated default extension,
// to verify that it's not actually being evaluated
_, err = client.Logical().WriteWithContext(context.Background(), "ssh/roles/test_allow_all_extensions", map[string]interface{}{
_, err = client.Logical().Write("ssh/roles/test_allow_all_extensions", map[string]interface{}{
"key_type": "ca",
"allow_user_certificates": true,
"allowed_users": "tuber",
@ -1635,7 +1635,7 @@ func TestBackend_DefExtTemplatingDisabled(t *testing.T) {
"login@foobar.com": "{{identity.entity.aliases." + userpassAccessor + ".name}}",
"login@zipzap.com": "some_other_user_name",
}
resp, err := client.Logical().WriteWithContext(context.Background(), "ssh/sign/test_allow_all_extensions", map[string]interface{}{
resp, err := client.Logical().Write("ssh/sign/test_allow_all_extensions", map[string]interface{}{
"public_key": publicKey4096,
"extensions": defaultExtensionPermissions,
})
@ -1661,7 +1661,7 @@ func TestBackend_DefExtTemplatingDisabled(t *testing.T) {
"login@foobar.com": "not_userpassname",
"login@zipzap.com": "some_other_user_name",
}
resp, err = client.Logical().WriteWithContext(context.Background(), "ssh/sign/test_allow_all_extensions", map[string]interface{}{
resp, err = client.Logical().Write("ssh/sign/test_allow_all_extensions", map[string]interface{}{
"public_key": publicKey4096,
"extensions": userProvidedAnyExtensionPermissions,
})
@ -1698,7 +1698,7 @@ func getSshCaTestCluster(t *testing.T, userIdentity string) (*vault.TestCluster,
client := cluster.Cores[0].Client
// Write test policy for userpass auth method.
err := client.Sys().PutPolicyWithContext(context.Background(), "test", `
err := client.Sys().PutPolicy("test", `
path "ssh/*" {
capabilities = ["update"]
}`)
@ -1712,7 +1712,7 @@ func getSshCaTestCluster(t *testing.T, userIdentity string) (*vault.TestCluster,
}
// Configure test role for userpass.
if _, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/"+userIdentity, map[string]interface{}{
if _, err := client.Logical().Write("auth/userpass/users/"+userIdentity, map[string]interface{}{
"password": "test",
"policies": "test",
}); err != nil {
@ -1720,7 +1720,7 @@ func getSshCaTestCluster(t *testing.T, userIdentity string) (*vault.TestCluster,
}
// Login userpass for test role and keep client token.
secret, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/login/"+userIdentity, map[string]interface{}{
secret, err := client.Logical().Write("auth/userpass/login/"+userIdentity, map[string]interface{}{
"password": "test",
})
if err != nil || secret == nil {
@ -1729,7 +1729,7 @@ func getSshCaTestCluster(t *testing.T, userIdentity string) (*vault.TestCluster,
userpassToken := secret.Auth.ClientToken
// Mount SSH.
err = client.Sys().MountWithContext(context.Background(), "ssh", &api.MountInput{
err = client.Sys().Mount("ssh", &api.MountInput{
Type: "ssh",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -1741,7 +1741,7 @@ func getSshCaTestCluster(t *testing.T, userIdentity string) (*vault.TestCluster,
}
// Configure SSH CA.
_, err = client.Logical().WriteWithContext(context.Background(), "ssh/config/ca", map[string]interface{}{
_, err = client.Logical().Write("ssh/config/ca", map[string]interface{}{
"public_key": testCAPublicKey,
"private_key": testCAPrivateKey,
})
@ -1759,21 +1759,21 @@ func testAllowedUsersTemplate(t *testing.T, testAllowedUsersTemplate string,
client := cluster.Cores[0].Client
// set metadata "ssh_username" to userpass username
tokenLookupResponse, err := client.Logical().WriteWithContext(context.Background(), "/auth/token/lookup", map[string]interface{}{
tokenLookupResponse, err := client.Logical().Write("/auth/token/lookup", map[string]interface{}{
"token": userpassToken,
})
if err != nil {
t.Fatal(err)
}
entityID := tokenLookupResponse.Data["entity_id"].(string)
_, err = client.Logical().WriteWithContext(context.Background(), "/identity/entity/id/"+entityID, map[string]interface{}{
_, err = client.Logical().Write("/identity/entity/id/"+entityID, map[string]interface{}{
"metadata": testEntityMetadata,
})
if err != nil {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "ssh/roles/my-role", map[string]interface{}{
_, err = client.Logical().Write("ssh/roles/my-role", map[string]interface{}{
"key_type": testCaKeyType,
"allow_user_certificates": true,
"allowed_users": testAllowedUsersTemplate,
@ -1785,7 +1785,7 @@ func testAllowedUsersTemplate(t *testing.T, testAllowedUsersTemplate string,
// sign SSH key as userpass user
client.SetToken(userpassToken)
signResponse, err := client.Logical().WriteWithContext(context.Background(), "ssh/sign/my-role", map[string]interface{}{
signResponse, err := client.Logical().Write("ssh/sign/my-role", map[string]interface{}{
"public_key": testCAPublicKey,
"valid_principals": expectedValidPrincipal,
})

View File

@ -348,7 +348,7 @@ func TestTransit_UpdateKeyConfigWithAutorotation(t *testing.T) {
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client
err := client.Sys().MountWithContext(context.Background(), "transit", &api.MountInput{
err := client.Sys().Mount("transit", &api.MountInput{
Type: "transit",
})
if err != nil {
@ -363,13 +363,13 @@ func TestTransit_UpdateKeyConfigWithAutorotation(t *testing.T) {
}
keyName := hex.EncodeToString(keyNameBytes)
_, err = client.Logical().WriteWithContext(context.Background(), fmt.Sprintf("transit/keys/%s", keyName), map[string]interface{}{
_, err = client.Logical().Write(fmt.Sprintf("transit/keys/%s", keyName), map[string]interface{}{
"auto_rotate_period": test.initialAutoRotatePeriod,
})
if err != nil {
t.Fatal(err)
}
resp, err := client.Logical().WriteWithContext(context.Background(), fmt.Sprintf("transit/keys/%s/config", keyName), map[string]interface{}{
resp, err := client.Logical().Write(fmt.Sprintf("transit/keys/%s/config", keyName), map[string]interface{}{
"auto_rotate_period": test.newAutoRotatePeriod,
})
switch {
@ -380,7 +380,7 @@ func TestTransit_UpdateKeyConfigWithAutorotation(t *testing.T) {
}
if !test.shouldError {
resp, err = client.Logical().ReadWithContext(context.Background(), fmt.Sprintf("transit/keys/%s", keyName))
resp, err = client.Logical().Read(fmt.Sprintf("transit/keys/%s", keyName))
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package transit_test
import (
"context"
"encoding/hex"
"encoding/json"
"fmt"
@ -40,7 +39,7 @@ func TestTransit_Issue_2958(t *testing.T) {
client := cores[0].Client
err := client.Sys().EnableAuditWithOptionsWithContext(context.Background(), "file", &api.EnableAuditOptions{
err := client.Sys().EnableAuditWithOptions("file", &api.EnableAuditOptions{
Type: "file",
Options: map[string]string{
"file_path": "/dev/null",
@ -50,45 +49,45 @@ func TestTransit_Issue_2958(t *testing.T) {
t.Fatal(err)
}
err = client.Sys().MountWithContext(context.Background(), "transit", &api.MountInput{
err = client.Sys().Mount("transit", &api.MountInput{
Type: "transit",
})
if err != nil {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "transit/keys/foo", map[string]interface{}{
_, err = client.Logical().Write("transit/keys/foo", map[string]interface{}{
"type": "ecdsa-p256",
})
if err != nil {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "transit/keys/foobar", map[string]interface{}{
_, err = client.Logical().Write("transit/keys/foobar", map[string]interface{}{
"type": "ecdsa-p384",
})
if err != nil {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "transit/keys/bar", map[string]interface{}{
_, err = client.Logical().Write("transit/keys/bar", map[string]interface{}{
"type": "ed25519",
})
if err != nil {
t.Fatal(err)
}
_, err = client.Logical().ReadWithContext(context.Background(), "transit/keys/foo")
_, err = client.Logical().Read("transit/keys/foo")
if err != nil {
t.Fatal(err)
}
_, err = client.Logical().ReadWithContext(context.Background(), "transit/keys/foobar")
_, err = client.Logical().Read("transit/keys/foobar")
if err != nil {
t.Fatal(err)
}
_, err = client.Logical().ReadWithContext(context.Background(), "transit/keys/bar")
_, err = client.Logical().Read("transit/keys/bar")
if err != nil {
t.Fatal(err)
}
@ -145,7 +144,7 @@ func TestTransit_CreateKeyWithAutorotation(t *testing.T) {
cores := cluster.Cores
vault.TestWaitActive(t, cores[0].Core)
client := cores[0].Client
err := client.Sys().MountWithContext(context.Background(), "transit", &api.MountInput{
err := client.Sys().Mount("transit", &api.MountInput{
Type: "transit",
})
if err != nil {
@ -160,7 +159,7 @@ func TestTransit_CreateKeyWithAutorotation(t *testing.T) {
}
keyName := hex.EncodeToString(keyNameBytes)
_, err = client.Logical().WriteWithContext(context.Background(), fmt.Sprintf("transit/keys/%s", keyName), map[string]interface{}{
_, err = client.Logical().Write(fmt.Sprintf("transit/keys/%s", keyName), map[string]interface{}{
"auto_rotate_period": test.autoRotatePeriod,
})
switch {
@ -171,7 +170,7 @@ func TestTransit_CreateKeyWithAutorotation(t *testing.T) {
}
if !test.shouldError {
resp, err := client.Logical().ReadWithContext(context.Background(), fmt.Sprintf("transit/keys/%s", keyName))
resp, err := client.Logical().Read(fmt.Sprintf("transit/keys/%s", keyName))
if err != nil {
t.Fatal(err)
}

View File

@ -60,7 +60,7 @@ func TestAliCloudEndToEnd(t *testing.T) {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "auth/alicloud/role/test", map[string]interface{}{
if _, err := client.Logical().Write("auth/alicloud/role/test", map[string]interface{}{
"arn": os.Getenv(envVarAlicloudRoleArn),
}); err != nil {
t.Fatal(err)

View File

@ -93,7 +93,7 @@ func testAppRoleEndToEnd(t *testing.T, removeSecretIDFile bool, bindSecretID boo
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/approle/role/test1", addConstraints(!bindSecretID, map[string]interface{}{
_, err = client.Logical().Write("auth/approle/role/test1", addConstraints(!bindSecretID, map[string]interface{}{
"bind_secret_id": bindSecretID,
"token_ttl": "6s",
"token_max_ttl": "10s",
@ -109,7 +109,7 @@ func testAppRoleEndToEnd(t *testing.T, removeSecretIDFile bool, bindSecretID boo
secretID1 := ""
secretID2 := ""
if bindSecretID {
resp, err := client.Logical().WriteWithContext(context.Background(), "auth/approle/role/test1/secret-id", nil)
resp, err := client.Logical().Write("auth/approle/role/test1/secret-id", nil)
if err != nil {
t.Fatal(err)
}
@ -117,13 +117,13 @@ func testAppRoleEndToEnd(t *testing.T, removeSecretIDFile bool, bindSecretID boo
} else {
logger.Trace("skipped write to auth/approle/role/test1/secret-id")
}
resp, err := client.Logical().ReadWithContext(context.Background(), "auth/approle/role/test1/role-id")
resp, err := client.Logical().Read("auth/approle/role/test1/role-id")
if err != nil {
t.Fatal(err)
}
roleID1 := resp.Data["role_id"].(string)
_, err = client.Logical().WriteWithContext(context.Background(), "auth/approle/role/test2", addConstraints(!bindSecretID, map[string]interface{}{
_, err = client.Logical().Write("auth/approle/role/test2", addConstraints(!bindSecretID, map[string]interface{}{
"bind_secret_id": bindSecretID,
"token_ttl": "6s",
"token_max_ttl": "10s",
@ -132,7 +132,7 @@ func testAppRoleEndToEnd(t *testing.T, removeSecretIDFile bool, bindSecretID boo
t.Fatal(err)
}
if bindSecretID {
resp, err = client.Logical().WriteWithContext(context.Background(), "auth/approle/role/test2/secret-id", nil)
resp, err = client.Logical().Write("auth/approle/role/test2/secret-id", nil)
if err != nil {
t.Fatal(err)
}
@ -140,7 +140,7 @@ func testAppRoleEndToEnd(t *testing.T, removeSecretIDFile bool, bindSecretID boo
} else {
logger.Trace("skipped write to auth/approle/role/test2/secret-id")
}
resp, err = client.Logical().ReadWithContext(context.Background(), "auth/approle/role/test2/role-id")
resp, err = client.Logical().Read("auth/approle/role/test2/role-id")
if err != nil {
t.Fatal(err)
}
@ -321,7 +321,7 @@ func testAppRoleEndToEnd(t *testing.T, removeSecretIDFile bool, bindSecretID boo
}
}
client.SetToken(string(val))
secret, err := client.Auth().Token().LookupSelfWithContext(context.Background())
secret, err := client.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
@ -345,7 +345,7 @@ func testAppRoleEndToEnd(t *testing.T, removeSecretIDFile bool, bindSecretID boo
if time.Now().After(timeout) {
break
}
secret, err := client.Auth().Token().LookupSelfWithContext(context.Background())
secret, err := client.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
@ -385,7 +385,7 @@ func testAppRoleEndToEnd(t *testing.T, removeSecretIDFile bool, bindSecretID boo
if time.Now().After(timeout) {
break
}
secret, err := client.Auth().Token().LookupSelfWithContext(context.Background())
secret, err := client.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
@ -455,7 +455,7 @@ func testAppRoleWithWrapping(t *testing.T, bindSecretID bool, secretIDLess bool,
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/approle/role/test1", addConstraints(!bindSecretID, map[string]interface{}{
_, err = client.Logical().Write("auth/approle/role/test1", addConstraints(!bindSecretID, map[string]interface{}{
"bind_secret_id": bindSecretID,
"token_ttl": "6s",
"token_max_ttl": "10s",
@ -474,7 +474,7 @@ func testAppRoleWithWrapping(t *testing.T, bindSecretID bool, secretIDLess bool,
secret := ""
secretID1 := ""
if bindSecretID {
resp, err := client.Logical().WriteWithContext(context.Background(), "auth/approle/role/test1/secret-id", nil)
resp, err := client.Logical().Write("auth/approle/role/test1/secret-id", nil)
if err != nil {
t.Fatal(err)
}
@ -482,7 +482,7 @@ func testAppRoleWithWrapping(t *testing.T, bindSecretID bool, secretIDLess bool,
} else {
logger.Trace("skipped write to auth/approle/role/test1/secret-id")
}
resp, err := client.Logical().ReadWithContext(context.Background(), "auth/approle/role/test1/role-id")
resp, err := client.Logical().Read("auth/approle/role/test1/role-id")
if err != nil {
t.Fatal(err)
}
@ -664,7 +664,7 @@ func testAppRoleWithWrapping(t *testing.T, bindSecretID bool, secretIDLess bool,
}
client.SetToken(string(val))
secret, err := client.Auth().Token().LookupSelfWithContext(context.Background())
secret, err := client.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
@ -690,7 +690,7 @@ func testAppRoleWithWrapping(t *testing.T, bindSecretID bool, secretIDLess bool,
if time.Now().After(timeout) {
break
}
secret, err := client.Auth().Token().LookupSelfWithContext(context.Background())
secret, err := client.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
@ -708,7 +708,7 @@ func testAppRoleWithWrapping(t *testing.T, bindSecretID bool, secretIDLess bool,
logger.Trace("origToken set into client", "origToken", origToken)
if bindSecretID {
resp, err = client.Logical().WriteWithContext(context.Background(), "auth/approle/role/test1/secret-id", nil)
resp, err = client.Logical().Write("auth/approle/role/test1/secret-id", nil)
if err != nil {
t.Fatal(err)
}
@ -732,7 +732,7 @@ func testAppRoleWithWrapping(t *testing.T, bindSecretID bool, secretIDLess bool,
if time.Now().After(timeout) {
break
}
secret, err := client.Auth().Token().LookupSelfWithContext(context.Background())
secret, err := client.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}

View File

@ -33,7 +33,7 @@ func newUserpassTestMethod(t *testing.T, client *api.Client) AuthMethod {
}
func (u *userpassTestMethod) Authenticate(_ context.Context, client *api.Client) (string, http.Header, map[string]interface{}, error) {
_, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/foo", map[string]interface{}{
_, err := client.Logical().Write("auth/userpass/users/foo", map[string]interface{}{
"password": "bar",
})
if err != nil {

View File

@ -48,7 +48,7 @@ func TestTokenPreload_UsingAutoAuth(t *testing.T) {
}
// Setup Approle
_, err := client.Logical().WriteWithContext(context.Background(), "auth/approle/role/test1", map[string]interface{}{
_, err := client.Logical().Write("auth/approle/role/test1", map[string]interface{}{
"bind_secret_id": "true",
"token_ttl": "3s",
"token_max_ttl": "10s",
@ -58,13 +58,13 @@ func TestTokenPreload_UsingAutoAuth(t *testing.T) {
t.Fatal(err)
}
resp, err := client.Logical().WriteWithContext(context.Background(), "auth/approle/role/test1/secret-id", nil)
resp, err := client.Logical().Write("auth/approle/role/test1/secret-id", nil)
if err != nil {
t.Fatal(err)
}
secretID1 := resp.Data["secret_id"].(string)
resp, err = client.Logical().ReadWithContext(context.Background(), "auth/approle/role/test1/role-id")
resp, err = client.Logical().Read("auth/approle/role/test1/role-id")
if err != nil {
t.Fatal(err)
}
@ -108,7 +108,7 @@ func TestTokenPreload_UsingAutoAuth(t *testing.T) {
}
// Setup Preload Token
tokenRespRaw, err := client.Logical().WriteWithContext(context.Background(), "auth/token/create", map[string]interface{}{
tokenRespRaw, err := client.Logical().Write("auth/token/create", map[string]interface{}{
"ttl": "10s",
"explicit-max-ttl": "15s",
"policies": []string{""},
@ -222,7 +222,7 @@ func TestTokenPreload_UsingAutoAuth(t *testing.T) {
wrappedToken := map[string]interface{}{
"token": authToken.Token,
}
unwrapResp, err := client.Logical().WriteWithContext(context.Background(), "sys/wrapping/unwrap", wrappedToken)
unwrapResp, err := client.Logical().Write("sys/wrapping/unwrap", wrappedToken)
if err != nil {
t.Fatalf("error unwrapping token: %s", err)
}

View File

@ -70,7 +70,7 @@ func TestAWSEndToEnd(t *testing.T) {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "auth/aws/role/test", map[string]interface{}{
if _, err := client.Logical().Write("auth/aws/role/test", map[string]interface{}{
"auth_type": "iam",
"policies": "default",
// Retain thru the account number of the given arn and wildcard the rest.

View File

@ -92,7 +92,7 @@ func setupClusterAndAgentCommon(ctx context.Context, t *testing.T, coreConfig *v
}
// Add an admin policy
if err := activeClient.Sys().PutPolicyWithContext(context.Background(), "admin", policyAdmin); err != nil {
if err := activeClient.Sys().PutPolicy("admin", policyAdmin); err != nil {
t.Fatal(err)
}
@ -105,7 +105,7 @@ func setupClusterAndAgentCommon(ctx context.Context, t *testing.T, coreConfig *v
t.Fatal(err)
}
_, err = activeClient.Logical().WriteWithContext(context.Background(), "auth/userpass/users/foo", map[string]interface{}{
_, err = activeClient.Logical().Write("auth/userpass/users/foo", map[string]interface{}{
"password": "bar",
"policies": []string{"admin"},
})
@ -174,7 +174,7 @@ func setupClusterAndAgentCommon(ctx context.Context, t *testing.T, coreConfig *v
// Login via userpass method to derive a managed token. Set that token as the
// testClient's token
resp, err := testClient.Logical().WriteWithContext(context.Background(), "auth/userpass/login/foo", map[string]interface{}{
resp, err := testClient.Logical().Write("auth/userpass/login/foo", map[string]interface{}{
"password": "bar",
})
if err != nil {
@ -264,7 +264,7 @@ func TestCache_AutoAuthTokenStripping(t *testing.T) {
// Empty the token in the client. Auto-auth token should be put to use.
testClient.SetToken("")
secret, err := testClient.Auth().Token().LookupSelfWithContext(context.Background())
secret, err := testClient.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
@ -272,7 +272,7 @@ func TestCache_AutoAuthTokenStripping(t *testing.T) {
t.Fatalf("failed to strip off auto-auth token on lookup-self")
}
secret, err = testClient.Auth().Token().LookupWithContext(context.Background(), "")
secret, err = testClient.Auth().Token().Lookup("")
if err != nil {
t.Fatal(err)
}
@ -329,7 +329,7 @@ func TestCache_AutoAuthClientTokenProxyStripping(t *testing.T) {
// Empty the token in the client. Auto-auth token should be put to use.
testClient.SetToken(dummyToken)
_, err = testClient.Auth().Token().LookupSelfWithContext(context.Background())
_, err = testClient.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
@ -351,7 +351,7 @@ func TestCache_ConcurrentRequests(t *testing.T) {
cleanup, _, testClient, _ := setupClusterAndAgent(namespace.RootContext(nil), t, coreConfig)
defer cleanup()
err := testClient.Sys().MountWithContext(context.Background(), "kv", &api.MountInput{
err := testClient.Sys().Mount("kv", &api.MountInput{
Type: "kv",
})
if err != nil {
@ -364,13 +364,13 @@ func TestCache_ConcurrentRequests(t *testing.T) {
go func(i int) {
defer wg.Done()
key := fmt.Sprintf("kv/foo/%d_%d", i, rand.Int())
_, err := testClient.Logical().WriteWithContext(context.Background(), key, map[string]interface{}{
_, err := testClient.Logical().Write(key, map[string]interface{}{
"key": key,
})
if err != nil {
t.Fatal(err)
}
secret, err := testClient.Logical().ReadWithContext(context.Background(), key)
secret, err := testClient.Logical().Read(key)
if err != nil {
t.Fatal(err)
}
@ -402,7 +402,7 @@ func TestCache_TokenRevocations_RevokeOrphan(t *testing.T) {
sampleSpace[token1] = "token"
// Mount the kv backend
err := testClient.Sys().MountWithContext(context.Background(), "kv", &api.MountInput{
err := testClient.Sys().Mount("kv", &api.MountInput{
Type: "kv",
})
if err != nil {
@ -410,7 +410,7 @@ func TestCache_TokenRevocations_RevokeOrphan(t *testing.T) {
}
// Create a secret in the backend
_, err = testClient.Logical().WriteWithContext(context.Background(), "kv/foo", map[string]interface{}{
_, err = testClient.Logical().Write("kv/foo", map[string]interface{}{
"value": "bar",
"ttl": "1h",
})
@ -419,14 +419,14 @@ func TestCache_TokenRevocations_RevokeOrphan(t *testing.T) {
}
// Read the secret and create a lease
leaseResp, err := testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
leaseResp, err := testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
lease1 := leaseResp.LeaseID
sampleSpace[lease1] = "lease"
resp, err := testClient.Logical().WriteWithContext(context.Background(), "auth/token/create", nil)
resp, err := testClient.Logical().Write("auth/token/create", nil)
if err != nil {
t.Fatal(err)
}
@ -435,14 +435,14 @@ func TestCache_TokenRevocations_RevokeOrphan(t *testing.T) {
testClient.SetToken(token2)
leaseResp, err = testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
leaseResp, err = testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
lease2 := leaseResp.LeaseID
sampleSpace[lease2] = "lease"
resp, err = testClient.Logical().WriteWithContext(context.Background(), "auth/token/create", nil)
resp, err = testClient.Logical().Write("auth/token/create", nil)
if err != nil {
t.Fatal(err)
}
@ -451,7 +451,7 @@ func TestCache_TokenRevocations_RevokeOrphan(t *testing.T) {
testClient.SetToken(token3)
leaseResp, err = testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
leaseResp, err = testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
@ -469,7 +469,7 @@ func TestCache_TokenRevocations_RevokeOrphan(t *testing.T) {
// including the child tokens and leases of the child tokens should be
// untouched.
testClient.SetToken(token2)
err = testClient.Auth().Token().RevokeOrphanWithContext(context.Background(), token2)
err = testClient.Auth().Token().RevokeOrphan(token2)
if err != nil {
t.Fatal(err)
}
@ -503,7 +503,7 @@ func TestCache_TokenRevocations_LeafLevelToken(t *testing.T) {
sampleSpace[token1] = "token"
// Mount the kv backend
err := testClient.Sys().MountWithContext(context.Background(), "kv", &api.MountInput{
err := testClient.Sys().Mount("kv", &api.MountInput{
Type: "kv",
})
if err != nil {
@ -511,7 +511,7 @@ func TestCache_TokenRevocations_LeafLevelToken(t *testing.T) {
}
// Create a secret in the backend
_, err = testClient.Logical().WriteWithContext(context.Background(), "kv/foo", map[string]interface{}{
_, err = testClient.Logical().Write("kv/foo", map[string]interface{}{
"value": "bar",
"ttl": "1h",
})
@ -520,14 +520,14 @@ func TestCache_TokenRevocations_LeafLevelToken(t *testing.T) {
}
// Read the secret and create a lease
leaseResp, err := testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
leaseResp, err := testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
lease1 := leaseResp.LeaseID
sampleSpace[lease1] = "lease"
resp, err := testClient.Logical().WriteWithContext(context.Background(), "auth/token/create", nil)
resp, err := testClient.Logical().Write("auth/token/create", nil)
if err != nil {
t.Fatal(err)
}
@ -536,14 +536,14 @@ func TestCache_TokenRevocations_LeafLevelToken(t *testing.T) {
testClient.SetToken(token2)
leaseResp, err = testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
leaseResp, err = testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
lease2 := leaseResp.LeaseID
sampleSpace[lease2] = "lease"
resp, err = testClient.Logical().WriteWithContext(context.Background(), "auth/token/create", nil)
resp, err = testClient.Logical().Write("auth/token/create", nil)
if err != nil {
t.Fatal(err)
}
@ -552,7 +552,7 @@ func TestCache_TokenRevocations_LeafLevelToken(t *testing.T) {
testClient.SetToken(token3)
leaseResp, err = testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
leaseResp, err = testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
@ -569,7 +569,7 @@ func TestCache_TokenRevocations_LeafLevelToken(t *testing.T) {
// token, evict entries for all the child tokens and their respective
// leases.
testClient.SetToken(token3)
err = testClient.Auth().Token().RevokeSelfWithContext(context.Background(), "")
err = testClient.Auth().Token().RevokeSelf("")
if err != nil {
t.Fatal(err)
}
@ -603,7 +603,7 @@ func TestCache_TokenRevocations_IntermediateLevelToken(t *testing.T) {
sampleSpace[token1] = "token"
// Mount the kv backend
err := testClient.Sys().MountWithContext(context.Background(), "kv", &api.MountInput{
err := testClient.Sys().Mount("kv", &api.MountInput{
Type: "kv",
})
if err != nil {
@ -611,7 +611,7 @@ func TestCache_TokenRevocations_IntermediateLevelToken(t *testing.T) {
}
// Create a secret in the backend
_, err = testClient.Logical().WriteWithContext(context.Background(), "kv/foo", map[string]interface{}{
_, err = testClient.Logical().Write("kv/foo", map[string]interface{}{
"value": "bar",
"ttl": "1h",
})
@ -620,14 +620,14 @@ func TestCache_TokenRevocations_IntermediateLevelToken(t *testing.T) {
}
// Read the secret and create a lease
leaseResp, err := testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
leaseResp, err := testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
lease1 := leaseResp.LeaseID
sampleSpace[lease1] = "lease"
resp, err := testClient.Logical().WriteWithContext(context.Background(), "auth/token/create", nil)
resp, err := testClient.Logical().Write("auth/token/create", nil)
if err != nil {
t.Fatal(err)
}
@ -636,14 +636,14 @@ func TestCache_TokenRevocations_IntermediateLevelToken(t *testing.T) {
testClient.SetToken(token2)
leaseResp, err = testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
leaseResp, err = testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
lease2 := leaseResp.LeaseID
sampleSpace[lease2] = "lease"
resp, err = testClient.Logical().WriteWithContext(context.Background(), "auth/token/create", nil)
resp, err = testClient.Logical().Write("auth/token/create", nil)
if err != nil {
t.Fatal(err)
}
@ -652,7 +652,7 @@ func TestCache_TokenRevocations_IntermediateLevelToken(t *testing.T) {
testClient.SetToken(token3)
leaseResp, err = testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
leaseResp, err = testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
@ -669,7 +669,7 @@ func TestCache_TokenRevocations_IntermediateLevelToken(t *testing.T) {
// belonging to this token, evict entries for all the child tokens and
// their respective leases.
testClient.SetToken(token2)
err = testClient.Auth().Token().RevokeSelfWithContext(context.Background(), "")
err = testClient.Auth().Token().RevokeSelf("")
if err != nil {
t.Fatal(err)
}
@ -701,7 +701,7 @@ func TestCache_TokenRevocations_TopLevelToken(t *testing.T) {
sampleSpace[token1] = "token"
// Mount the kv backend
err := testClient.Sys().MountWithContext(context.Background(), "kv", &api.MountInput{
err := testClient.Sys().Mount("kv", &api.MountInput{
Type: "kv",
})
if err != nil {
@ -709,7 +709,7 @@ func TestCache_TokenRevocations_TopLevelToken(t *testing.T) {
}
// Create a secret in the backend
_, err = testClient.Logical().WriteWithContext(context.Background(), "kv/foo", map[string]interface{}{
_, err = testClient.Logical().Write("kv/foo", map[string]interface{}{
"value": "bar",
"ttl": "1h",
})
@ -718,14 +718,14 @@ func TestCache_TokenRevocations_TopLevelToken(t *testing.T) {
}
// Read the secret and create a lease
leaseResp, err := testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
leaseResp, err := testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
lease1 := leaseResp.LeaseID
sampleSpace[lease1] = "lease"
resp, err := testClient.Logical().WriteWithContext(context.Background(), "auth/token/create", nil)
resp, err := testClient.Logical().Write("auth/token/create", nil)
if err != nil {
t.Fatal(err)
}
@ -734,14 +734,14 @@ func TestCache_TokenRevocations_TopLevelToken(t *testing.T) {
testClient.SetToken(token2)
leaseResp, err = testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
leaseResp, err = testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
lease2 := leaseResp.LeaseID
sampleSpace[lease2] = "lease"
resp, err = testClient.Logical().WriteWithContext(context.Background(), "auth/token/create", nil)
resp, err = testClient.Logical().Write("auth/token/create", nil)
if err != nil {
t.Fatal(err)
}
@ -750,7 +750,7 @@ func TestCache_TokenRevocations_TopLevelToken(t *testing.T) {
testClient.SetToken(token3)
leaseResp, err = testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
leaseResp, err = testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
@ -767,7 +767,7 @@ func TestCache_TokenRevocations_TopLevelToken(t *testing.T) {
// to this token, evict entries for all the child tokens and their
// respective leases.
testClient.SetToken(token1)
err = testClient.Auth().Token().RevokeSelfWithContext(context.Background(), "")
err = testClient.Auth().Token().RevokeSelf("")
if err != nil {
t.Fatal(err)
}
@ -797,7 +797,7 @@ func TestCache_TokenRevocations_Shutdown(t *testing.T) {
sampleSpace[token1] = "token"
// Mount the kv backend
err := testClient.Sys().MountWithContext(context.Background(), "kv", &api.MountInput{
err := testClient.Sys().Mount("kv", &api.MountInput{
Type: "kv",
})
if err != nil {
@ -805,7 +805,7 @@ func TestCache_TokenRevocations_Shutdown(t *testing.T) {
}
// Create a secret in the backend
_, err = testClient.Logical().WriteWithContext(context.Background(), "kv/foo", map[string]interface{}{
_, err = testClient.Logical().Write("kv/foo", map[string]interface{}{
"value": "bar",
"ttl": "1h",
})
@ -814,14 +814,14 @@ func TestCache_TokenRevocations_Shutdown(t *testing.T) {
}
// Read the secret and create a lease
leaseResp, err := testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
leaseResp, err := testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
lease1 := leaseResp.LeaseID
sampleSpace[lease1] = "lease"
resp, err := testClient.Logical().WriteWithContext(context.Background(), "auth/token/create", nil)
resp, err := testClient.Logical().Write("auth/token/create", nil)
if err != nil {
t.Fatal(err)
}
@ -830,14 +830,14 @@ func TestCache_TokenRevocations_Shutdown(t *testing.T) {
testClient.SetToken(token2)
leaseResp, err = testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
leaseResp, err = testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
lease2 := leaseResp.LeaseID
sampleSpace[lease2] = "lease"
resp, err = testClient.Logical().WriteWithContext(context.Background(), "auth/token/create", nil)
resp, err = testClient.Logical().Write("auth/token/create", nil)
if err != nil {
t.Fatal(err)
}
@ -846,7 +846,7 @@ func TestCache_TokenRevocations_Shutdown(t *testing.T) {
testClient.SetToken(token3)
leaseResp, err = testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
leaseResp, err = testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
@ -886,7 +886,7 @@ func TestCache_TokenRevocations_BaseContextCancellation(t *testing.T) {
sampleSpace[token1] = "token"
// Mount the kv backend
err := testClient.Sys().MountWithContext(context.Background(), "kv", &api.MountInput{
err := testClient.Sys().Mount("kv", &api.MountInput{
Type: "kv",
})
if err != nil {
@ -894,7 +894,7 @@ func TestCache_TokenRevocations_BaseContextCancellation(t *testing.T) {
}
// Create a secret in the backend
_, err = testClient.Logical().WriteWithContext(context.Background(), "kv/foo", map[string]interface{}{
_, err = testClient.Logical().Write("kv/foo", map[string]interface{}{
"value": "bar",
"ttl": "1h",
})
@ -903,14 +903,14 @@ func TestCache_TokenRevocations_BaseContextCancellation(t *testing.T) {
}
// Read the secret and create a lease
leaseResp, err := testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
leaseResp, err := testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
lease1 := leaseResp.LeaseID
sampleSpace[lease1] = "lease"
resp, err := testClient.Logical().WriteWithContext(context.Background(), "auth/token/create", nil)
resp, err := testClient.Logical().Write("auth/token/create", nil)
if err != nil {
t.Fatal(err)
}
@ -919,14 +919,14 @@ func TestCache_TokenRevocations_BaseContextCancellation(t *testing.T) {
testClient.SetToken(token2)
leaseResp, err = testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
leaseResp, err = testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
lease2 := leaseResp.LeaseID
sampleSpace[lease2] = "lease"
resp, err = testClient.Logical().WriteWithContext(context.Background(), "auth/token/create", nil)
resp, err = testClient.Logical().Write("auth/token/create", nil)
if err != nil {
t.Fatal(err)
}
@ -935,7 +935,7 @@ func TestCache_TokenRevocations_BaseContextCancellation(t *testing.T) {
testClient.SetToken(token3)
leaseResp, err = testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
leaseResp, err = testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
@ -972,13 +972,13 @@ func TestCache_NonCacheable(t *testing.T) {
defer cleanup()
// Query mounts first
origMounts, err := testClient.Sys().ListMountsWithContext(context.Background())
origMounts, err := testClient.Sys().ListMounts()
if err != nil {
t.Fatal(err)
}
// Mount a kv backend
if err := testClient.Sys().MountWithContext(context.Background(), "kv", &api.MountInput{
if err := testClient.Sys().Mount("kv", &api.MountInput{
Type: "kv",
Options: map[string]string{
"version": "2",
@ -988,7 +988,7 @@ func TestCache_NonCacheable(t *testing.T) {
}
// Query mounts again
newMounts, err := testClient.Sys().ListMountsWithContext(context.Background())
newMounts, err := testClient.Sys().ListMounts()
if err != nil {
t.Fatal(err)
}
@ -1020,7 +1020,7 @@ func TestCache_Caching_AuthResponse(t *testing.T) {
cleanup, _, testClient, _ := setupClusterAndAgent(namespace.RootContext(nil), t, nil)
defer cleanup()
resp, err := testClient.Logical().WriteWithContext(context.Background(), "auth/token/create", nil)
resp, err := testClient.Logical().Write("auth/token/create", nil)
if err != nil {
t.Fatal(err)
}
@ -1028,7 +1028,7 @@ func TestCache_Caching_AuthResponse(t *testing.T) {
testClient.SetToken(token)
authTokeCreateReq := func(t *testing.T, policies map[string]interface{}) *api.Secret {
resp, err := testClient.Logical().WriteWithContext(context.Background(), "auth/token/create", policies)
resp, err := testClient.Logical().Write("auth/token/create", policies)
if err != nil {
t.Fatal(err)
}
@ -1079,7 +1079,7 @@ func TestCache_Caching_LeaseResponse(t *testing.T) {
cleanup, client, testClient, _ := setupClusterAndAgent(namespace.RootContext(nil), t, coreConfig)
defer cleanup()
err := client.Sys().MountWithContext(context.Background(), "kv", &api.MountInput{
err := client.Sys().Mount("kv", &api.MountInput{
Type: "kv",
})
if err != nil {
@ -1089,14 +1089,14 @@ func TestCache_Caching_LeaseResponse(t *testing.T) {
// Test proxy by issuing two different requests
{
// Write data to the lease-kv backend
_, err := testClient.Logical().WriteWithContext(context.Background(), "kv/foo", map[string]interface{}{
_, err := testClient.Logical().Write("kv/foo", map[string]interface{}{
"value": "bar",
"ttl": "1h",
})
if err != nil {
t.Fatal(err)
}
_, err = testClient.Logical().WriteWithContext(context.Background(), "kv/foobar", map[string]interface{}{
_, err = testClient.Logical().Write("kv/foobar", map[string]interface{}{
"value": "bar",
"ttl": "1h",
})
@ -1104,12 +1104,12 @@ func TestCache_Caching_LeaseResponse(t *testing.T) {
t.Fatal(err)
}
firstResp, err := testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
firstResp, err := testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
secondResp, err := testClient.Logical().ReadWithContext(context.Background(), "kv/foobar")
secondResp, err := testClient.Logical().Read("kv/foobar")
if err != nil {
t.Fatal(err)
}
@ -1122,7 +1122,7 @@ func TestCache_Caching_LeaseResponse(t *testing.T) {
// Test caching behavior by issue the same request twice
{
_, err := testClient.Logical().WriteWithContext(context.Background(), "kv/baz", map[string]interface{}{
_, err := testClient.Logical().Write("kv/baz", map[string]interface{}{
"value": "foo",
"ttl": "1h",
})
@ -1130,12 +1130,12 @@ func TestCache_Caching_LeaseResponse(t *testing.T) {
t.Fatal(err)
}
proxiedResp, err := testClient.Logical().ReadWithContext(context.Background(), "kv/baz")
proxiedResp, err := testClient.Logical().Read("kv/baz")
if err != nil {
t.Fatal(err)
}
cachedResp, err := testClient.Logical().ReadWithContext(context.Background(), "kv/baz")
cachedResp, err := testClient.Logical().Read("kv/baz")
if err != nil {
t.Fatal(err)
}
@ -1181,7 +1181,7 @@ func testCachingCacheClearCommon(t *testing.T, clearType string) {
cleanup, client, testClient, leaseCache := setupClusterAndAgent(namespace.RootContext(nil), t, coreConfig)
defer cleanup()
err := client.Sys().MountWithContext(context.Background(), "kv", &api.MountInput{
err := client.Sys().Mount("kv", &api.MountInput{
Type: "kv",
})
if err != nil {
@ -1189,7 +1189,7 @@ func testCachingCacheClearCommon(t *testing.T, clearType string) {
}
// Write data to the lease-kv backend
_, err = testClient.Logical().WriteWithContext(context.Background(), "kv/foo", map[string]interface{}{
_, err = testClient.Logical().Write("kv/foo", map[string]interface{}{
"value": "bar",
"ttl": "1h",
})
@ -1198,7 +1198,7 @@ func testCachingCacheClearCommon(t *testing.T, clearType string) {
}
// Proxy this request, agent should cache the response
resp, err := testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
resp, err := testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
@ -1228,7 +1228,7 @@ func testCachingCacheClearCommon(t *testing.T, clearType string) {
case "token":
data["value"] = testClient.Token()
case "token_accessor":
lookupResp, err := client.Auth().Token().LookupWithContext(context.Background(), testClient.Token())
lookupResp, err := client.Auth().Token().Lookup(testClient.Token())
if err != nil {
t.Fatal(err)
}
@ -1285,7 +1285,7 @@ func TestCache_AuthTokenCreateOrphan(t *testing.T) {
Policies: []string{"default"},
NoParent: true,
}
resp, err := testClient.Auth().Token().CreateWithContext(context.Background(), reqOpts)
resp, err := testClient.Auth().Token().Create(reqOpts)
if err != nil {
t.Fatal(err)
}
@ -1312,7 +1312,7 @@ func TestCache_AuthTokenCreateOrphan(t *testing.T) {
// Use the test client but set the token to one that's not managed by agent
testClient.SetToken(clusterClient.Token())
resp, err := testClient.Auth().Token().CreateWithContext(context.Background(), reqOpts)
resp, err := testClient.Auth().Token().Create(reqOpts)
if err != nil {
t.Fatal(err)
}
@ -1336,7 +1336,7 @@ func TestCache_AuthTokenCreateOrphan(t *testing.T) {
reqOpts := &api.TokenCreateRequest{
Policies: []string{"default"},
}
resp, err := testClient.Auth().Token().CreateOrphanWithContext(context.Background(), reqOpts)
resp, err := testClient.Auth().Token().CreateOrphan(reqOpts)
if err != nil {
t.Fatal(err)
}
@ -1362,7 +1362,7 @@ func TestCache_AuthTokenCreateOrphan(t *testing.T) {
// Use the test client but set the token to one that's not managed by agent
testClient.SetToken(clusterClient.Token())
resp, err := testClient.Auth().Token().CreateOrphanWithContext(context.Background(), reqOpts)
resp, err := testClient.Auth().Token().CreateOrphan(reqOpts)
if err != nil {
t.Fatal(err)
}

View File

@ -71,7 +71,7 @@ func TestCache_UsingAutoAuthToken(t *testing.T) {
defer os.Setenv(api.EnvVaultCACert, os.Getenv(api.EnvVaultCACert))
os.Setenv(api.EnvVaultCACert, fmt.Sprintf("%s/ca_cert.pem", cluster.TempDir))
err = client.Sys().MountWithContext(context.Background(), "kv", &api.MountInput{
err = client.Sys().Mount("kv", &api.MountInput{
Type: "kv",
})
if err != nil {
@ -79,7 +79,7 @@ func TestCache_UsingAutoAuthToken(t *testing.T) {
}
// Create a secret in the backend
_, err = client.Logical().WriteWithContext(context.Background(), "kv/foo", map[string]interface{}{
_, err = client.Logical().Write("kv/foo", map[string]interface{}{
"value": "bar",
"ttl": "1h",
})
@ -88,7 +88,7 @@ func TestCache_UsingAutoAuthToken(t *testing.T) {
}
// Add an kv-admin policy
if err := client.Sys().PutPolicyWithContext(context.Background(), "test-autoauth", policyAutoAuthAppRole); err != nil {
if err := client.Sys().PutPolicy("test-autoauth", policyAutoAuthAppRole); err != nil {
t.Fatal(err)
}
@ -100,7 +100,7 @@ func TestCache_UsingAutoAuthToken(t *testing.T) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/approle/role/test1", map[string]interface{}{
_, err = client.Logical().Write("auth/approle/role/test1", map[string]interface{}{
"bind_secret_id": "true",
"token_ttl": "3s",
"token_max_ttl": "10s",
@ -110,13 +110,13 @@ func TestCache_UsingAutoAuthToken(t *testing.T) {
t.Fatal(err)
}
resp, err := client.Logical().WriteWithContext(context.Background(), "auth/approle/role/test1/secret-id", nil)
resp, err := client.Logical().Write("auth/approle/role/test1/secret-id", nil)
if err != nil {
t.Fatal(err)
}
secretID1 := resp.Data["secret_id"].(string)
resp, err = client.Logical().ReadWithContext(context.Background(), "auth/approle/role/test1/role-id")
resp, err = client.Logical().Read("auth/approle/role/test1/role-id")
if err != nil {
t.Fatal(err)
}
@ -343,7 +343,7 @@ func TestCache_UsingAutoAuthToken(t *testing.T) {
// Empty the token in the client to ensure that auto-auth token is used
testClient.SetToken("")
resp, err = testClient.Logical().ReadWithContext(context.Background(), "auth/token/lookup-self")
resp, err = testClient.Logical().Read("auth/token/lookup-self")
if err != nil {
t.Fatal(err)
}
@ -354,14 +354,14 @@ func TestCache_UsingAutoAuthToken(t *testing.T) {
// This block tests lease creation caching using the auto-auth token.
{
resp, err = testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
resp, err = testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
origReqID := resp.RequestID
resp, err = testClient.Logical().ReadWithContext(context.Background(), "kv/foo")
resp, err = testClient.Logical().Read("kv/foo")
if err != nil {
t.Fatal(err)
}
@ -379,7 +379,7 @@ func TestCache_UsingAutoAuthToken(t *testing.T) {
// This block tests auth token creation caching (child, non-orphan tokens)
// using the auto-auth token.
{
resp, err = testClient.Logical().WriteWithContext(context.Background(), "auth/token/create", nil)
resp, err = testClient.Logical().Write("auth/token/create", nil)
if err != nil {
t.Fatal(err)
}
@ -388,7 +388,7 @@ func TestCache_UsingAutoAuthToken(t *testing.T) {
// Sleep for a bit to allow renewer logic to kick in
time.Sleep(20 * time.Millisecond)
resp, err = testClient.Logical().WriteWithContext(context.Background(), "auth/token/create", nil)
resp, err = testClient.Logical().Write("auth/token/create", nil)
if err != nil {
t.Fatal(err)
}
@ -405,7 +405,7 @@ func TestCache_UsingAutoAuthToken(t *testing.T) {
// Empty the token in the client to ensure that auto-auth token is used
testClient.SetToken(client.Token())
resp, err = testClient.Logical().ReadWithContext(context.Background(), "auth/token/lookup-self")
resp, err = testClient.Logical().Read("auth/token/lookup-self")
if err != nil {
t.Fatal(err)
}

View File

@ -90,7 +90,7 @@ func testCertEndToEnd(t *testing.T, withCertRoleName, ahWrapping bool) {
certificatePEM := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: cluster.CACert.Raw})
certRoleName := "test"
_, err = client.Logical().WriteWithContext(context.Background(), fmt.Sprintf("auth/cert/certs/%s", certRoleName), map[string]interface{}{
_, err = client.Logical().Write(fmt.Sprintf("auth/cert/certs/%s", certRoleName), map[string]interface{}{
"certificate": string(certificatePEM),
"policies": "default",
})
@ -327,7 +327,7 @@ func TestCertEndToEnd_CertsInConfig(t *testing.T) {
// /////////////
// Mount /pki as a root CA
err := client.Sys().MountWithContext(context.Background(), "pki", &api.MountInput{
err := client.Sys().Mount("pki", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -340,7 +340,7 @@ func TestCertEndToEnd_CertsInConfig(t *testing.T) {
// Set the cluster's certificate as the root CA in /pki
pemBundleRootCA := string(cluster.CACertPEM) + string(cluster.CAKeyPEM)
_, err = client.Logical().WriteWithContext(context.Background(), "pki/config/ca", map[string]interface{}{
_, err = client.Logical().Write("pki/config/ca", map[string]interface{}{
"pem_bundle": pemBundleRootCA,
})
if err != nil {
@ -348,7 +348,7 @@ func TestCertEndToEnd_CertsInConfig(t *testing.T) {
}
// Mount /pki2 to operate as an intermediate CA
err = client.Sys().MountWithContext(context.Background(), "pki2", &api.MountInput{
err = client.Sys().Mount("pki2", &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
@ -360,14 +360,14 @@ func TestCertEndToEnd_CertsInConfig(t *testing.T) {
}
// Create a CSR for the intermediate CA
secret, err := client.Logical().WriteWithContext(context.Background(), "pki2/intermediate/generate/internal", nil)
secret, err := client.Logical().Write("pki2/intermediate/generate/internal", nil)
if err != nil {
t.Fatal(err)
}
intermediateCSR := secret.Data["csr"].(string)
// Sign the intermediate CSR using /pki
secret, err = client.Logical().WriteWithContext(context.Background(), "pki/root/sign-intermediate", map[string]interface{}{
secret, err = client.Logical().Write("pki/root/sign-intermediate", map[string]interface{}{
"permitted_dns_domains": ".myvault.com",
"csr": intermediateCSR,
})
@ -377,7 +377,7 @@ func TestCertEndToEnd_CertsInConfig(t *testing.T) {
intermediateCertPEM := secret.Data["certificate"].(string)
// Configure the intermediate cert as the CA in /pki2
_, err = client.Logical().WriteWithContext(context.Background(), "pki2/intermediate/set-signed", map[string]interface{}{
_, err = client.Logical().Write("pki2/intermediate/set-signed", map[string]interface{}{
"certificate": intermediateCertPEM,
})
if err != nil {
@ -385,7 +385,7 @@ func TestCertEndToEnd_CertsInConfig(t *testing.T) {
}
// Create a role on the intermediate CA mount
_, err = client.Logical().WriteWithContext(context.Background(), "pki2/roles/myvault-dot-com", map[string]interface{}{
_, err = client.Logical().Write("pki2/roles/myvault-dot-com", map[string]interface{}{
"allowed_domains": "myvault.com",
"allow_subdomains": "true",
"max_ttl": "5m",
@ -395,7 +395,7 @@ func TestCertEndToEnd_CertsInConfig(t *testing.T) {
}
// Issue a leaf cert using the intermediate CA
secret, err = client.Logical().WriteWithContext(context.Background(), "pki2/issue/myvault-dot-com", map[string]interface{}{
secret, err = client.Logical().Write("pki2/issue/myvault-dot-com", map[string]interface{}{
"common_name": "cert.myvault.com",
"format": "pem",
"ip_sans": "127.0.0.1",
@ -457,7 +457,7 @@ func TestCertEndToEnd_CertsInConfig(t *testing.T) {
}
// Set the intermediate CA cert as a trusted certificate in the backend
_, err = client.Logical().WriteWithContext(context.Background(), "auth/cert/certs/myvault-dot-com", map[string]interface{}{
_, err = client.Logical().Write("auth/cert/certs/myvault-dot-com", map[string]interface{}{
"display_name": "myvault.com",
"policies": "default",
"certificate": intermediateCertPEM,

View File

@ -68,7 +68,7 @@ func TestCFEndToEnd(t *testing.T) {
defer mockCFAPI.Close()
// Configure a CA certificate like a Vault operator would in setting up CF.
if _, err := client.Logical().WriteWithContext(context.Background(), "auth/cf/config", map[string]interface{}{
if _, err := client.Logical().Write("auth/cf/config", map[string]interface{}{
"identity_ca_certificates": testCFCerts.CACertificate,
"cf_api_addr": mockCFAPI.URL,
"cf_username": cfAPI.AuthUsername,
@ -78,7 +78,7 @@ func TestCFEndToEnd(t *testing.T) {
}
// Configure a role to be used for logging in, another thing a Vault operator would do.
if _, err := client.Logical().WriteWithContext(context.Background(), "auth/cf/roles/test-role", map[string]interface{}{
if _, err := client.Logical().Write("auth/cf/roles/test-role", map[string]interface{}{
"bound_instance_ids": cfAPI.FoundServiceGUID,
"bound_organization_ids": cfAPI.FoundOrgGUID,
"bound_space_ids": cfAPI.FoundSpaceGUID,

View File

@ -53,7 +53,7 @@ func testJWTEndToEnd(t *testing.T, ahWrapping bool) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/jwt/config", map[string]interface{}{
_, err = client.Logical().Write("auth/jwt/config", map[string]interface{}{
"bound_issuer": "https://team-vault.auth0.com/",
"jwt_validation_pubkeys": TestECDSAPubKey,
"jwt_supported_algs": "ES256",
@ -62,7 +62,7 @@ func testJWTEndToEnd(t *testing.T, ahWrapping bool) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/jwt/role/test", map[string]interface{}{
_, err = client.Logical().Write("auth/jwt/role/test", map[string]interface{}{
"role_type": "jwt",
"bound_subject": "r3qXcK2bix9eFECzsU3Sbmh0K16fatW6@clients",
"bound_audiences": "https://vault.plugin.auth.jwt.test",

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
@ -76,7 +75,7 @@ func TestAgent_Cache_UnixListener(t *testing.T) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/jwt/config", map[string]interface{}{
_, err = client.Logical().Write("auth/jwt/config", map[string]interface{}{
"bound_issuer": "https://team-vault.auth0.com/",
"jwt_validation_pubkeys": agent.TestECDSAPubKey,
})
@ -84,7 +83,7 @@ func TestAgent_Cache_UnixListener(t *testing.T) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/jwt/role/test", map[string]interface{}{
_, err = client.Logical().Write("auth/jwt/role/test", map[string]interface{}{
"role_type": "jwt",
"bound_subject": "r3qXcK2bix9eFECzsU3Sbmh0K16fatW6@clients",
"bound_audiences": "https://vault.plugin.auth.jwt.test",
@ -219,7 +218,7 @@ cache {
time.Sleep(1 * time.Second)
// Invoke lookup self through the agent
secret, err := testClient.Auth().Token().LookupSelfWithContext(context.Background())
secret, err := testClient.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
@ -264,7 +263,7 @@ func testAgentExitAfterAuth(t *testing.T, viaFlag bool) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/jwt/config", map[string]interface{}{
_, err = client.Logical().Write("auth/jwt/config", map[string]interface{}{
"bound_issuer": "https://team-vault.auth0.com/",
"jwt_validation_pubkeys": agent.TestECDSAPubKey,
"jwt_supported_algs": "ES256",
@ -273,7 +272,7 @@ func testAgentExitAfterAuth(t *testing.T, viaFlag bool) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/jwt/role/test", map[string]interface{}{
_, err = client.Logical().Write("auth/jwt/role/test", map[string]interface{}{
"role_type": "jwt",
"bound_subject": "r3qXcK2bix9eFECzsU3Sbmh0K16fatW6@clients",
"bound_audiences": "https://vault.plugin.auth.jwt.test",
@ -1307,7 +1306,7 @@ func TestAgent_Template_Retry(t *testing.T) {
methodConf, cleanup := prepAgentApproleKV(t, serverClient)
defer cleanup()
err := serverClient.Sys().TuneMountWithContext(context.Background(), "secret", api.MountConfigInput{
err := serverClient.Sys().TuneMount("secret", api.MountConfigInput{
Options: map[string]string{
"version": "2",
},
@ -1316,7 +1315,7 @@ func TestAgent_Template_Retry(t *testing.T) {
t.Fatal(err)
}
_, err = serverClient.Logical().WriteWithContext(context.Background(), "secret/data/otherapp", map[string]interface{}{
_, err = serverClient.Logical().Write("secret/data/otherapp", map[string]interface{}{
"data": map[string]interface{}{
"username": "barstuff",
"password": "zap",
@ -1500,7 +1499,7 @@ path "/secret/*" {
}
`
// Add an kv-admin policy
if err := client.Sys().PutPolicyWithContext(context.Background(), "test-autoauth", policyAutoAuthAppRole); err != nil {
if err := client.Sys().PutPolicy("test-autoauth", policyAutoAuthAppRole); err != nil {
t.Fatal(err)
}
@ -1512,7 +1511,7 @@ path "/secret/*" {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/approle/role/test1", map[string]interface{}{
_, err = client.Logical().Write("auth/approle/role/test1", map[string]interface{}{
"bind_secret_id": "true",
"token_ttl": "1h",
"token_max_ttl": "2h",
@ -1522,14 +1521,14 @@ path "/secret/*" {
t.Fatal(err)
}
resp, err := client.Logical().WriteWithContext(context.Background(), "auth/approle/role/test1/secret-id", nil)
resp, err := client.Logical().Write("auth/approle/role/test1/secret-id", nil)
if err != nil {
t.Fatal(err)
}
secretID := resp.Data["secret_id"].(string)
secretIDFile := makeTempFile(t, "secret_id.txt", secretID+"\n")
resp, err = client.Logical().ReadWithContext(context.Background(), "auth/approle/role/test1/role-id")
resp, err = client.Logical().Read("auth/approle/role/test1/role-id")
if err != nil {
t.Fatal(err)
}
@ -1591,7 +1590,7 @@ func TestAgent_Cache_Retry(t *testing.T) {
defer os.Setenv(api.EnvVaultAddress, os.Getenv(api.EnvVaultAddress))
os.Unsetenv(api.EnvVaultAddress)
_, err := serverClient.Logical().WriteWithContext(context.Background(), "secret/foo", map[string]interface{}{
_, err := serverClient.Logical().Write("secret/foo", map[string]interface{}{
"bar": "baz",
})
if err != nil {
@ -1689,7 +1688,7 @@ vault {
if err != nil {
t.Fatal(err)
}
secret, err := client.Logical().ReadWithContext(context.Background(), "secret/foo")
secret, err := client.Logical().Read("secret/foo")
switch {
case (err != nil || secret == nil) && tc.expectError:
case (err == nil || secret != nil) && !tc.expectError:
@ -1743,7 +1742,7 @@ func TestAgent_TemplateConfig_ExitOnRetryFailure(t *testing.T) {
autoAuthConfig, cleanup := prepAgentApproleKV(t, serverClient)
defer cleanup()
err := serverClient.Sys().TuneMountWithContext(context.Background(), "secret", api.MountConfigInput{
err := serverClient.Sys().TuneMount("secret", api.MountConfigInput{
Options: map[string]string{
"version": "2",
},
@ -1752,7 +1751,7 @@ func TestAgent_TemplateConfig_ExitOnRetryFailure(t *testing.T) {
t.Fatal(err)
}
_, err = serverClient.Logical().WriteWithContext(context.Background(), "secret/data/otherapp", map[string]interface{}{
_, err = serverClient.Logical().Write("secret/data/otherapp", map[string]interface{}{
"data": map[string]interface{}{
"username": "barstuff",
"password": "zap",

View File

@ -45,7 +45,7 @@ func TestAppRole_Integ_ConcurrentLogins(t *testing.T) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/approle/role/role1", map[string]interface{}{
_, err = client.Logical().Write("auth/approle/role/role1", map[string]interface{}{
"bind_secret_id": "true",
"period": "300",
})
@ -53,13 +53,13 @@ func TestAppRole_Integ_ConcurrentLogins(t *testing.T) {
t.Fatal(err)
}
secret, err := client.Logical().WriteWithContext(context.Background(), "auth/approle/role/role1/secret-id", nil)
secret, err := client.Logical().Write("auth/approle/role/role1/secret-id", nil)
if err != nil {
t.Fatal(err)
}
secretID := secret.Data["secret_id"].(string)
secret, err = client.Logical().ReadWithContext(context.Background(), "auth/approle/role/role1/role-id")
secret, err = client.Logical().Read("auth/approle/role/role1/role-id")
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -64,7 +63,7 @@ func TestAuditDisableCommand_Run(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if err := client.Sys().EnableAuditWithOptionsWithContext(context.Background(), "file", &api.EnableAuditOptions{
if err := client.Sys().EnableAuditWithOptions("file", &api.EnableAuditOptions{
Type: "file",
Options: map[string]string{
"file_path": "discard",
@ -94,7 +93,7 @@ func TestAuditDisableCommand_Run(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if err := client.Sys().EnableAuditWithOptionsWithContext(context.Background(), "integration_audit_disable", &api.EnableAuditOptions{
if err := client.Sys().EnableAuditWithOptions("integration_audit_disable", &api.EnableAuditOptions{
Type: "file",
Options: map[string]string{
"file_path": "discard",
@ -119,7 +118,7 @@ func TestAuditDisableCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
mounts, err := client.Sys().ListMountsWithContext(context.Background())
mounts, err := client.Sys().ListMounts()
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"io/ioutil"
"os"
"strings"
@ -109,7 +108,7 @@ func TestAuditEnableCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
audits, err := client.Sys().ListAuditWithContext(context.Background())
audits, err := client.Sys().ListAudit()
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -58,7 +57,7 @@ func TestAuditListCommand_Run(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if err := client.Sys().EnableAuditWithOptionsWithContext(context.Background(), "file", &api.EnableAuditOptions{
if err := client.Sys().EnableAuditWithOptions("file", &api.EnableAuditOptions{
Type: "file",
Options: map[string]string{
"file_path": "discard",

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -96,7 +95,7 @@ func TestAuthDisableCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"io/ioutil"
"strings"
"testing"
@ -106,7 +105,7 @@ func TestAuthEnableCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -105,7 +104,7 @@ func TestAuthMoveCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
mounts, err := client.Sys().ListAuthWithContext(context.Background())
mounts, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -110,7 +109,7 @@ func TestAuthTuneCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}
@ -176,7 +175,7 @@ func TestAuthTuneCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}
@ -219,7 +218,7 @@ func TestAuthTuneCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"reflect"
"testing"
@ -17,25 +16,25 @@ func TestPredictVaultPaths(t *testing.T) {
defer closer()
data := map[string]interface{}{"a": "b"}
if _, err := client.Logical().WriteWithContext(context.Background(), "secret/bar", data); err != nil {
if _, err := client.Logical().Write("secret/bar", data); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "secret/foo", data); err != nil {
if _, err := client.Logical().Write("secret/foo", data); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "secret/zip/zap", data); err != nil {
if _, err := client.Logical().Write("secret/zip/zap", data); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "secret/zip/zonk", data); err != nil {
if _, err := client.Logical().Write("secret/zip/zonk", data); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "secret/zip/twoot", data); err != nil {
if _, err := client.Logical().Write("secret/zip/twoot", data); err != nil {
t.Fatal(err)
}
if err := client.Sys().MountWithContext(context.Background(), "level1a/level2a/level3a", &api.MountInput{Type: "kv"}); err != nil {
if err := client.Sys().Mount("level1a/level2a/level3a", &api.MountInput{Type: "kv"}); err != nil {
t.Fatal(err)
}
if err := client.Sys().MountWithContext(context.Background(), "level1a/level2a/level3b", &api.MountInput{Type: "kv"}); err != nil {
if err := client.Sys().Mount("level1a/level2a/level3b", &api.MountInput{Type: "kv"}); err != nil {
t.Fatal(err)
}
@ -231,7 +230,7 @@ func TestPredict_Audits(t *testing.T) {
badClient, badCloser := testVaultServerBad(t)
defer badCloser()
if err := client.Sys().EnableAuditWithOptionsWithContext(context.Background(), "file", &api.EnableAuditOptions{
if err := client.Sys().EnableAuditWithOptions("file", &api.EnableAuditOptions{
Type: "file",
Options: map[string]string{
"file_path": "discard",
@ -496,13 +495,13 @@ func TestPredict_Paths(t *testing.T) {
defer closer()
data := map[string]interface{}{"a": "b"}
if _, err := client.Logical().WriteWithContext(context.Background(), "secret/bar", data); err != nil {
if _, err := client.Logical().Write("secret/bar", data); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "secret/foo", data); err != nil {
if _, err := client.Logical().Write("secret/foo", data); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "secret/zip/zap", data); err != nil {
if _, err := client.Logical().Write("secret/zip/zap", data); err != nil {
t.Fatal(err)
}
@ -572,10 +571,10 @@ func TestPredict_ListPaths(t *testing.T) {
defer badCloser()
data := map[string]interface{}{"a": "b"}
if _, err := client.Logical().WriteWithContext(context.Background(), "secret/bar", data); err != nil {
if _, err := client.Logical().Write("secret/bar", data); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "secret/foo", data); err != nil {
if _, err := client.Logical().Write("secret/foo", data); err != nil {
t.Fatal(err)
}

View File

@ -236,7 +236,7 @@ func testVaultServerBad(tb testing.TB) (*api.Client, func()) {
func testTokenAndAccessor(tb testing.TB, client *api.Client) (string, string) {
tb.Helper()
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
TTL: "30m",
})

View File

@ -2,7 +2,6 @@ package command
import (
"archive/tar"
"context"
"encoding/json"
"fmt"
"io/ioutil"
@ -643,7 +642,7 @@ func TestDebugCommand_PartialPermissions(t *testing.T) {
defer closer()
// Create a new token with default policy
resp, err := client.Logical().WriteWithContext(context.Background(), "auth/token/create", map[string]interface{}{
resp, err := client.Logical().Write("auth/token/create", map[string]interface{}{
"policies": "default",
})
if err != nil {

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -82,7 +81,7 @@ func TestDeleteCommand_Run(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if _, err := client.Logical().WriteWithContext(context.Background(), "secret/delete/foo", map[string]interface{}{
if _, err := client.Logical().Write("secret/delete/foo", map[string]interface{}{
"foo": "bar",
}); err != nil {
t.Fatal(err)
@ -104,7 +103,7 @@ func TestDeleteCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
secret, _ := client.Logical().ReadWithContext(context.Background(), "secret/delete/foo")
secret, _ := client.Logical().Read("secret/delete/foo")
if secret != nil {
t.Errorf("expected deletion: %#v", secret)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"encoding/json"
"io"
"strings"
@ -63,7 +62,7 @@ func TestKvMetadataPatchCommand_EmptyArgs(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
if err := client.Sys().Mount("kv/", &api.MountInput{
Type: "kv-v2",
}); err != nil {
t.Fatalf("kv-v2 mount error: %#v", err)
@ -180,7 +179,7 @@ func TestKvMetadataPatchCommand_Flags(t *testing.T) {
secretPath := basePath + "my-secret"
metadataPath := basePath + "metadata/" + "my-secret"
if err := client.Sys().MountWithContext(context.Background(), basePath, &api.MountInput{
if err := client.Sys().Mount(basePath, &api.MountInput{
Type: "kv-v2",
}); err != nil {
t.Fatalf("kv-v2 mount error: %#v", err)
@ -193,7 +192,7 @@ func TestKvMetadataPatchCommand_Flags(t *testing.T) {
t.Fatalf("initial metadata put failed, code: %d, output: %s", code, combined)
}
initialMetadata, err := client.Logical().ReadWithContext(context.Background(), metadataPath)
initialMetadata, err := client.Logical().Read(metadataPath)
if err != nil {
t.Fatalf("metadata read failed, err: %#v", err)
}
@ -209,7 +208,7 @@ func TestKvMetadataPatchCommand_Flags(t *testing.T) {
t.Fatalf("expected code to be %d but was %d for patch cmd with args %#v", tc.code, code, patchArgs)
}
patchedMetadata, err := client.Logical().ReadWithContext(context.Background(), metadataPath)
patchedMetadata, err := client.Logical().Read(metadataPath)
if err != nil {
t.Fatalf("metadata read failed, err: %#v", err)
}
@ -236,7 +235,7 @@ func TestKvMetadataPatchCommand_CasWarning(t *testing.T) {
defer closer()
basePath := "kv/"
if err := client.Sys().MountWithContext(context.Background(), basePath, &api.MountInput{
if err := client.Sys().Mount(basePath, &api.MountInput{
Type: "kv-v2",
}); err != nil {
t.Fatalf("kv-v2 mount error: %#v", err)
@ -255,7 +254,7 @@ func TestKvMetadataPatchCommand_CasWarning(t *testing.T) {
"cas_required": true,
}
_, err := client.Logical().WriteWithContext(context.Background(), basePath+"config", casConfig)
_, err := client.Logical().Write(basePath+"config", casConfig)
if err != nil {
t.Fatalf("config write failed, err: #%v", err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"encoding/json"
"strings"
"testing"
@ -27,7 +26,7 @@ func TestKvMetadataPutCommand_DeleteVersionAfter(t *testing.T) {
defer closer()
basePath := t.Name() + "/"
if err := client.Sys().MountWithContext(context.Background(), basePath, &api.MountInput{
if err := client.Sys().Mount(basePath, &api.MountInput{
Type: "kv-v2",
}); err != nil {
t.Fatal(err)
@ -49,7 +48,7 @@ func TestKvMetadataPutCommand_DeleteVersionAfter(t *testing.T) {
t.Fatalf("expected %q but received %q", success, combined)
}
secret, err := client.Logical().ReadWithContext(context.Background(), metaFullPath)
secret, err := client.Logical().Read(metaFullPath)
if err != nil {
t.Fatal(err)
}
@ -72,7 +71,7 @@ func TestKvMetadataPutCommand_DeleteVersionAfter(t *testing.T) {
t.Errorf("expected %q but received %q", success, combined)
}
secret, err = client.Logical().ReadWithContext(context.Background(), metaFullPath)
secret, err = client.Logical().Read(metaFullPath)
if err != nil {
t.Fatal(err)
}
@ -88,7 +87,7 @@ func TestKvMetadataPutCommand_CustomMetadata(t *testing.T) {
basePath := t.Name() + "/"
secretPath := basePath + "secret/my-secret"
if err := client.Sys().MountWithContext(context.Background(), basePath, &api.MountInput{
if err := client.Sys().Mount(basePath, &api.MountInput{
Type: "kv-v2",
}); err != nil {
t.Fatalf("kv-v2 mount error: %#v", err)
@ -111,7 +110,7 @@ func TestKvMetadataPutCommand_CustomMetadata(t *testing.T) {
t.Fatalf("Expected command output %q but received %q", expectedOutput, commandOutput)
}
metadata, err := client.Logical().ReadWithContext(context.Background(), metaFullPath)
metadata, err := client.Logical().Read(metaFullPath)
if err != nil {
t.Fatalf("Metadata read error: %#v", err)
}
@ -142,7 +141,7 @@ func TestKvMetadataPutCommand_CustomMetadata(t *testing.T) {
t.Fatalf("Expected command output %q but received %q", expectedOutput, commandOutput)
}
metadata, err = client.Logical().ReadWithContext(context.Background(), metaFullPath)
metadata, err = client.Logical().Read(metaFullPath)
if err != nil {
t.Fatalf("Metadata read error: %#v", err)
@ -164,7 +163,7 @@ func TestKvMetadataPutCommand_UnprovidedFlags(t *testing.T) {
basePath := t.Name() + "/"
secretPath := basePath + "my-secret"
if err := client.Sys().MountWithContext(context.Background(), basePath, &api.MountInput{
if err := client.Sys().Mount(basePath, &api.MountInput{
Type: "kv-v2",
}); err != nil {
t.Fatalf("kv-v2 mount error: %#v", err)
@ -187,7 +186,7 @@ func TestKvMetadataPutCommand_UnprovidedFlags(t *testing.T) {
t.Fatalf("expected 0 exit status but received %d", code)
}
secret, err := client.Logical().ReadWithContext(context.Background(), basePath+"metadata/"+"my-secret")
secret, err := client.Logical().Read(basePath + "metadata/" + "my-secret")
if err != nil {
t.Fatal(err)
}

View File

@ -170,7 +170,7 @@ func TestKVPutCommand(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
if err := client.Sys().Mount("kv/", &api.MountInput{
Type: "kv-v2",
}); err != nil {
t.Fatal(err)
@ -195,7 +195,7 @@ func TestKVPutCommand(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
if err := client.Sys().Mount("kv/", &api.MountInput{
Type: "kv-v2",
}); err != nil {
t.Fatal(err)
@ -302,7 +302,7 @@ func TestKVPutCommand(t *testing.T) {
t.Fatalf("expected 0 to be %d", code)
}
secret, err := client.Logical().ReadWithContext(context.Background(), "secret/write/stdin_full")
secret, err := client.Logical().Read("secret/write/stdin_full")
if err != nil {
t.Fatal(err)
}
@ -337,7 +337,7 @@ func TestKVPutCommand(t *testing.T) {
t.Fatalf("expected 0 to be %d", code)
}
secret, err := client.Logical().ReadWithContext(context.Background(), "secret/write/stdin_value")
secret, err := client.Logical().Read("secret/write/stdin_value")
if err != nil {
t.Fatal(err)
}
@ -365,7 +365,7 @@ func TestKVPutCommand(t *testing.T) {
t.Fatalf("expected 0 to be %d", code)
}
secret, err := client.Logical().ReadWithContext(context.Background(), "secret/write/integration")
secret, err := client.Logical().Read("secret/write/integration")
if err != nil {
t.Fatal(err)
}
@ -489,7 +489,7 @@ func TestKVGetCommand(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
if err := client.Sys().Mount("kv/", &api.MountInput{
Type: "kv-v2",
}); err != nil {
t.Fatal(err)
@ -498,13 +498,13 @@ func TestKVGetCommand(t *testing.T) {
// Give time for the upgrade code to run/finish
time.Sleep(time.Second)
if _, err := client.Logical().WriteWithContext(context.Background(), "secret/read/foo", map[string]interface{}{
if _, err := client.Logical().Write("secret/read/foo", map[string]interface{}{
"foo": "bar",
}); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "kv/data/read/foo", map[string]interface{}{
if _, err := client.Logical().Write("kv/data/read/foo", map[string]interface{}{
"data": map[string]interface{}{
"foo": "bar",
},
@ -614,7 +614,7 @@ func TestKVMetadataGetCommand(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
if err := client.Sys().Mount("kv/", &api.MountInput{
Type: "kv-v2",
}); err != nil {
t.Fatal(err)
@ -623,7 +623,7 @@ func TestKVMetadataGetCommand(t *testing.T) {
// Give time for the upgrade code to run/finish
time.Sleep(time.Second)
if _, err := client.Logical().WriteWithContext(context.Background(), "kv/data/foo", map[string]interface{}{
if _, err := client.Logical().Write("kv/data/foo", map[string]interface{}{
"data": map[string]interface{}{
"foo": "bar",
},
@ -710,7 +710,7 @@ func TestKVPatchCommand_ArgValidation(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
if err := client.Sys().Mount("kv/", &api.MountInput{
Type: "kv-v2",
}); err != nil {
t.Fatalf("kv-v2 mount attempt failed - err: %#v\n", err)
@ -746,13 +746,13 @@ func TestKVPatchCommand_StdinFull(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
if err := client.Sys().Mount("kv/", &api.MountInput{
Type: "kv-v2",
}); err != nil {
t.Fatalf("kv-v2 mount attempt failed - err: %#v\n", err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "kv/data/patch/foo", map[string]interface{}{
if _, err := client.Logical().Write("kv/data/patch/foo", map[string]interface{}{
"data": map[string]interface{}{
"foo": "a",
},
@ -813,13 +813,13 @@ func TestKVPatchCommand_StdinValue(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
if err := client.Sys().Mount("kv/", &api.MountInput{
Type: "kv-v2",
}); err != nil {
t.Fatalf("kv-v2 mount attempt failed - err: %#v\n", err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "kv/data/patch/foo", map[string]interface{}{
if _, err := client.Logical().Write("kv/data/patch/foo", map[string]interface{}{
"data": map[string]interface{}{
"foo": "a",
},
@ -877,7 +877,7 @@ func TestKVPatchCommand_RWMethodNotExists(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
if err := client.Sys().Mount("kv/", &api.MountInput{
Type: "kv-v2",
}); err != nil {
t.Fatalf("kv-v2 mount attempt failed - err: %#v\n", err)
@ -906,13 +906,13 @@ func TestKVPatchCommand_RWMethodSucceeds(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
if err := client.Sys().Mount("kv/", &api.MountInput{
Type: "kv-v2",
}); err != nil {
t.Fatalf("kv-v2 mount attempt failed - err: %#v\n", err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "kv/data/patch/foo", map[string]interface{}{
if _, err := client.Logical().Write("kv/data/patch/foo", map[string]interface{}{
"data": map[string]interface{}{
"foo": "a",
"bar": "b",
@ -997,7 +997,7 @@ func TestKVPatchCommand_CAS(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
if err := client.Sys().Mount("kv/", &api.MountInput{
Type: "kv-v2",
}); err != nil {
t.Fatalf("kv-v2 mount attempt failed - err: %#v\n", err)
@ -1017,7 +1017,7 @@ func TestKVPatchCommand_CAS(t *testing.T) {
kvClient.SetToken(secretAuth.ClientToken)
_, err = kvClient.Logical().WriteWithContext(context.Background(), "kv/data/foo", map[string]interface{}{"data": map[string]interface{}{"bar": "baz"}})
_, err = kvClient.Logical().Write("kv/data/foo", map[string]interface{}{"data": map[string]interface{}{"bar": "baz"}})
if err != nil {
t.Fatal(err)
}
@ -1076,7 +1076,7 @@ func TestKVPatchCommand_Methods(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
if err := client.Sys().Mount("kv/", &api.MountInput{
Type: "kv-v2",
}); err != nil {
t.Fatalf("kv-v2 mount attempt failed - err: %#v\n", err)
@ -1096,7 +1096,7 @@ func TestKVPatchCommand_Methods(t *testing.T) {
kvClient.SetToken(secretAuth.ClientToken)
_, err = kvClient.Logical().WriteWithContext(context.Background(), "kv/data/foo", map[string]interface{}{"data": map[string]interface{}{"bar": "baz"}})
_, err = kvClient.Logical().Write("kv/data/foo", map[string]interface{}{"data": map[string]interface{}{"bar": "baz"}})
if err != nil {
t.Fatal(err)
}
@ -1150,7 +1150,7 @@ func TestKVPatchCommand_403Fallback(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
if err := client.Sys().Mount("kv/", &api.MountInput{
Type: "kv-v2",
}); err != nil {
t.Fatalf("kv-v2 mount attempt failed - err: %#v\n", err)
@ -1171,7 +1171,7 @@ func TestKVPatchCommand_403Fallback(t *testing.T) {
kvClient.SetToken(secretAuth.ClientToken)
// Write a value then attempt to patch it
_, err = kvClient.Logical().WriteWithContext(context.Background(), "kv/data/foo", map[string]interface{}{"data": map[string]interface{}{"bar": "baz"}})
_, err = kvClient.Logical().Write("kv/data/foo", map[string]interface{}{"data": map[string]interface{}{"bar": "baz"}})
if err != nil {
t.Fatal(err)
}
@ -1231,7 +1231,7 @@ func TestKVPatchCommand_RWMethodPolicyVariations(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
if err := client.Sys().Mount("kv/", &api.MountInput{
Type: "kv-v2",
}); err != nil {
t.Fatalf("kv-v2 mount attempt failed - err: %#v\n", err)
@ -1315,11 +1315,11 @@ func TestPadEqualSigns(t *testing.T) {
func createTokenForPolicy(t *testing.T, client *api.Client, policy string) (*api.SecretAuth, error) {
t.Helper()
if err := client.Sys().PutPolicyWithContext(context.Background(), "policy", policy); err != nil {
if err := client.Sys().PutPolicy("policy", policy); err != nil {
return nil, err
}
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"policy"},
TTL: "30m",
})

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -23,13 +22,13 @@ func testLeaseLookupCommand(tb testing.TB) (*cli.MockUi, *LeaseLookupCommand) {
// testLeaseLookupCommandMountAndLease mounts a leased secret backend and returns
// the leaseID of an item.
func testLeaseLookupCommandMountAndLease(tb testing.TB, client *api.Client) string {
if err := client.Sys().MountWithContext(context.Background(), "testing", &api.MountInput{
if err := client.Sys().Mount("testing", &api.MountInput{
Type: "generic-leased",
}); err != nil {
tb.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "testing/foo", map[string]interface{}{
if _, err := client.Logical().Write("testing/foo", map[string]interface{}{
"key": "value",
"lease": "5m",
}); err != nil {
@ -37,7 +36,7 @@ func testLeaseLookupCommandMountAndLease(tb testing.TB, client *api.Client) stri
}
// Read the secret back to get the leaseID
secret, err := client.Logical().ReadWithContext(context.Background(), "testing/foo")
secret, err := client.Logical().Read("testing/foo")
if err != nil {
tb.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -23,13 +22,13 @@ func testLeaseRenewCommand(tb testing.TB) (*cli.MockUi, *LeaseRenewCommand) {
// testLeaseRenewCommandMountAndLease mounts a leased secret backend and returns
// the leaseID of an item.
func testLeaseRenewCommandMountAndLease(tb testing.TB, client *api.Client) string {
if err := client.Sys().MountWithContext(context.Background(), "testing", &api.MountInput{
if err := client.Sys().Mount("testing", &api.MountInput{
Type: "generic-leased",
}); err != nil {
tb.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "testing/foo", map[string]interface{}{
if _, err := client.Logical().Write("testing/foo", map[string]interface{}{
"key": "value",
"lease": "5m",
}); err != nil {
@ -37,7 +36,7 @@ func testLeaseRenewCommandMountAndLease(tb testing.TB, client *api.Client) strin
}
// Read the secret back to get the leaseID
secret, err := client.Logical().ReadWithContext(context.Background(), "testing/foo")
secret, err := client.Logical().Read("testing/foo")
if err != nil {
tb.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -79,7 +78,7 @@ func TestLeaseRevokeCommand_Run(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if err := client.Sys().MountWithContext(context.Background(), "secret-leased", &api.MountInput{
if err := client.Sys().Mount("secret-leased", &api.MountInput{
Type: "generic-leased",
}); err != nil {
t.Fatal(err)
@ -90,10 +89,10 @@ func TestLeaseRevokeCommand_Run(t *testing.T) {
"key": "value",
"lease": "1m",
}
if _, err := client.Logical().WriteWithContext(context.Background(), path, data); err != nil {
if _, err := client.Logical().Write(path, data); err != nil {
t.Fatal(err)
}
secret, err := client.Logical().ReadWithContext(context.Background(), path)
secret, err := client.Logical().Read(path)
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -78,7 +77,7 @@ func TestListCommand_Run(t *testing.T) {
"secret/list/baz",
}
for _, k := range keys {
if _, err := client.Logical().WriteWithContext(context.Background(), k, map[string]interface{}{
if _, err := client.Logical().Write(k, map[string]interface{}{
"foo": "bar",
}); err != nil {
t.Fatal(err)

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -49,7 +48,7 @@ func TestLoginCommand_Run(t *testing.T) {
if err := client.Sys().EnableAuth("my-auth", "userpass", ""); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "auth/my-auth/users/test", map[string]interface{}{
if _, err := client.Logical().Write("auth/my-auth/users/test", map[string]interface{}{
"password": "test",
"policies": "default",
}); err != nil {
@ -99,7 +98,7 @@ func TestLoginCommand_Run(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
TTL: "30m",
})
@ -145,7 +144,7 @@ func TestLoginCommand_Run(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
TTL: "30m",
})
@ -188,7 +187,7 @@ func TestLoginCommand_Run(t *testing.T) {
if err := client.Sys().EnableAuth("userpass", "userpass", ""); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/test", map[string]interface{}{
if _, err := client.Logical().Write("auth/userpass/users/test", map[string]interface{}{
"password": "test",
"policies": "default",
}); err != nil {
@ -266,7 +265,7 @@ func TestLoginCommand_Run(t *testing.T) {
if err := client.Sys().EnableAuth("userpass", "userpass", ""); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/test", map[string]interface{}{
if _, err := client.Logical().Write("auth/userpass/users/test", map[string]interface{}{
"password": "test",
"policies": "default",
}); err != nil {
@ -303,7 +302,7 @@ func TestLoginCommand_Run(t *testing.T) {
client.SetToken(token)
// Ensure the resulting token is unwrapped
secret, err := client.Auth().Token().LookupSelfWithContext(context.Background())
secret, err := client.Auth().Token().LookupSelf()
if err != nil {
t.Error(err)
}
@ -325,7 +324,7 @@ func TestLoginCommand_Run(t *testing.T) {
if err := client.Sys().EnableAuth("userpass", "userpass", ""); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/test", map[string]interface{}{
if _, err := client.Logical().Write("auth/userpass/users/test", map[string]interface{}{
"password": "test",
"policies": "default",
}); err != nil {
@ -368,7 +367,7 @@ func TestLoginCommand_Run(t *testing.T) {
// Ensure the resulting token is, in fact, still wrapped.
client.SetToken(token)
secret, err := client.Logical().UnwrapWithContext(context.Background(), "")
secret, err := client.Logical().Unwrap("")
if err != nil {
t.Error(err)
}
@ -386,7 +385,7 @@ func TestLoginCommand_Run(t *testing.T) {
if err := client.Sys().EnableAuth("userpass", "userpass", ""); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/test", map[string]interface{}{
if _, err := client.Logical().Write("auth/userpass/users/test", map[string]interface{}{
"password": "test",
"policies": "default",
}); err != nil {

View File

@ -3,7 +3,6 @@
package command
import (
"context"
"encoding/base64"
"io"
"os"
@ -256,7 +255,7 @@ func TestOperatorGenerateRootCommand_Run(t *testing.T) {
defer closer()
// Initialize a generation
if _, err := client.Sys().GenerateRootInitWithContext(context.Background(), "", ""); err != nil {
if _, err := client.Sys().GenerateRootInit("", ""); err != nil {
t.Fatal(err)
}
@ -276,7 +275,7 @@ func TestOperatorGenerateRootCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
status, err := client.Sys().GenerateRootStatusWithContext(context.Background())
status, err := client.Sys().GenerateRootStatus()
if err != nil {
t.Fatal(err)
}
@ -308,7 +307,7 @@ func TestOperatorGenerateRootCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
status, err := client.Sys().GenerateRootStatusWithContext(context.Background())
status, err := client.Sys().GenerateRootStatus()
if err != nil {
t.Fatal(err)
}
@ -344,7 +343,7 @@ func TestOperatorGenerateRootCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
status, err := client.Sys().GenerateRootStatusWithContext(context.Background())
status, err := client.Sys().GenerateRootStatus()
if err != nil {
t.Fatal(err)
}
@ -387,7 +386,7 @@ func TestOperatorGenerateRootCommand_Run(t *testing.T) {
defer closer()
// Initialize a generation
status, err := client.Sys().GenerateRootInitWithContext(context.Background(), "", "")
status, err := client.Sys().GenerateRootInit("", "")
if err != nil {
t.Fatal(err)
}
@ -448,7 +447,7 @@ func TestOperatorGenerateRootCommand_Run(t *testing.T) {
defer closer()
// Initialize a generation
status, err := client.Sys().GenerateRootInitWithContext(context.Background(), "", "")
status, err := client.Sys().GenerateRootInit("", "")
if err != nil {
t.Fatal(err)
}

View File

@ -3,7 +3,6 @@
package command
import (
"context"
"fmt"
"os"
"regexp"
@ -144,7 +143,7 @@ func TestOperatorInitCommand_Run(t *testing.T) {
}
// Now init to verify the init response code
if _, err := client.Sys().InitWithContext(context.Background(), &api.InitRequest{
if _, err := client.Sys().Init(&api.InitRequest{
SecretShares: 1,
SecretThreshold: 1,
}); err != nil {
@ -176,7 +175,7 @@ func TestOperatorInitCommand_Run(t *testing.T) {
t.Errorf("expected %d to be %d: %s", code, exp, ui.ErrorWriter.String())
}
init, err := client.Sys().InitStatusWithContext(context.Background())
init, err := client.Sys().InitStatus()
if err != nil {
t.Fatal(err)
}
@ -199,7 +198,7 @@ func TestOperatorInitCommand_Run(t *testing.T) {
// Try unsealing with those keys - only use 3, which is the default
// threshold.
for i, key := range keys[:3] {
resp, err := client.Sys().UnsealWithContext(context.Background(), key)
resp, err := client.Sys().Unseal(key)
if err != nil {
t.Fatal(err)
}
@ -210,7 +209,7 @@ func TestOperatorInitCommand_Run(t *testing.T) {
}
}
status, err := client.Sys().SealStatusWithContext(context.Background())
status, err := client.Sys().SealStatus()
if err != nil {
t.Fatal(err)
}
@ -238,7 +237,7 @@ func TestOperatorInitCommand_Run(t *testing.T) {
t.Errorf("expected %d to be %d: %s", code, exp, ui.ErrorWriter.String())
}
init, err := client.Sys().InitStatusWithContext(context.Background())
init, err := client.Sys().InitStatus()
if err != nil {
t.Fatal(err)
}
@ -261,7 +260,7 @@ func TestOperatorInitCommand_Run(t *testing.T) {
// Try unsealing with those keys - only use 3, which is the default
// threshold.
for i, key := range keys[:keyThreshold] {
resp, err := client.Sys().UnsealWithContext(context.Background(), key)
resp, err := client.Sys().Unseal(key)
if err != nil {
t.Fatal(err)
}
@ -272,7 +271,7 @@ func TestOperatorInitCommand_Run(t *testing.T) {
}
}
status, err := client.Sys().SealStatusWithContext(context.Background())
status, err := client.Sys().SealStatus()
if err != nil {
t.Fatal(err)
}
@ -321,7 +320,7 @@ func TestOperatorInitCommand_Run(t *testing.T) {
// Try unsealing with one key
decryptedKey := testPGPDecrypt(t, pgpkeys.TestPrivKey1, keys[0])
if _, err := client.Sys().UnsealWithContext(context.Background(), decryptedKey); err != nil {
if _, err := client.Sys().Unseal(decryptedKey); err != nil {
t.Fatal(err)
}

View File

@ -3,7 +3,6 @@
package command
import (
"context"
"io"
"reflect"
"regexp"
@ -118,7 +117,7 @@ func TestOperatorRekeyCommand_Run(t *testing.T) {
}
// Now init to verify the init response
if _, err := client.Sys().RekeyInitWithContext(context.Background(), &api.RekeyInitRequest{
if _, err := client.Sys().RekeyInit(&api.RekeyInitRequest{
SecretShares: 1,
SecretThreshold: 1,
}); err != nil {
@ -149,7 +148,7 @@ func TestOperatorRekeyCommand_Run(t *testing.T) {
defer closer()
// Initialize a rekey
if _, err := client.Sys().RekeyInitWithContext(context.Background(), &api.RekeyInitRequest{
if _, err := client.Sys().RekeyInit(&api.RekeyInitRequest{
SecretShares: 1,
SecretThreshold: 1,
}); err != nil {
@ -172,7 +171,7 @@ func TestOperatorRekeyCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
status, err := client.Sys().GenerateRootStatusWithContext(context.Background())
status, err := client.Sys().GenerateRootStatus()
if err != nil {
t.Fatal(err)
}
@ -206,7 +205,7 @@ func TestOperatorRekeyCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
status, err := client.Sys().RekeyStatusWithContext(context.Background())
status, err := client.Sys().RekeyStatus()
if err != nil {
t.Fatal(err)
}
@ -243,7 +242,7 @@ func TestOperatorRekeyCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
status, err := client.Sys().RekeyStatusWithContext(context.Background())
status, err := client.Sys().RekeyStatus()
if err != nil {
t.Fatal(err)
}
@ -262,7 +261,7 @@ func TestOperatorRekeyCommand_Run(t *testing.T) {
defer closer()
// Initialize a rekey
status, err := client.Sys().RekeyInitWithContext(context.Background(), &api.RekeyInitRequest{
status, err := client.Sys().RekeyInit(&api.RekeyInitRequest{
SecretShares: 1,
SecretThreshold: 1,
})
@ -308,7 +307,7 @@ func TestOperatorRekeyCommand_Run(t *testing.T) {
if err := client.Sys().Seal(); err != nil {
t.Fatal(err)
}
sealStatus, err := client.Sys().UnsealWithContext(context.Background(), unsealKey)
sealStatus, err := client.Sys().Unseal(unsealKey)
if err != nil {
t.Fatal(err)
}
@ -324,7 +323,7 @@ func TestOperatorRekeyCommand_Run(t *testing.T) {
defer closer()
// Initialize a rekey
status, err := client.Sys().RekeyInitWithContext(context.Background(), &api.RekeyInitRequest{
status, err := client.Sys().RekeyInit(&api.RekeyInitRequest{
SecretShares: 1,
SecretThreshold: 1,
})
@ -384,7 +383,7 @@ func TestOperatorRekeyCommand_Run(t *testing.T) {
if err := client.Sys().Seal(); err != nil {
t.Fatal(err)
}
sealStatus, err := client.Sys().UnsealWithContext(context.Background(), unsealKey)
sealStatus, err := client.Sys().Unseal(unsealKey)
if err != nil {
t.Fatal(err)
}
@ -417,7 +416,7 @@ func TestOperatorRekeyCommand_Run(t *testing.T) {
}
// Get the status for the nonce
status, err := client.Sys().RekeyStatusWithContext(context.Background())
status, err := client.Sys().RekeyStatus()
if err != nil {
t.Fatal(err)
}
@ -480,7 +479,7 @@ func TestOperatorRekeyCommand_Run(t *testing.T) {
t.Errorf("expected %d to be %d: %s", code, exp, ui.ErrorWriter.String())
}
secret, err := client.Sys().RekeyRetrieveBackupWithContext(context.Background())
secret, err := client.Sys().RekeyRetrieveBackup()
if err == nil {
t.Errorf("expected error: %#v", secret)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -84,7 +83,7 @@ func TestOperatorSealCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
sealStatus, err := client.Sys().SealStatusWithContext(context.Background())
sealStatus, err := client.Sys().SealStatus()
if err != nil {
t.Fatal(err)
}

View File

@ -2,7 +2,6 @@ package command
import (
"bytes"
"context"
"encoding/json"
"io/ioutil"
"os"
@ -60,7 +59,7 @@ func TestOperatorUnsealCommand_Run(t *testing.T) {
}
// Enter an unseal key
if _, err := client.Sys().UnsealWithContext(context.Background(), keys[0]); err != nil {
if _, err := client.Sys().Unseal(keys[0]); err != nil {
t.Fatal(err)
}
@ -107,7 +106,7 @@ func TestOperatorUnsealCommand_Run(t *testing.T) {
}
}
status, err := client.Sys().SealStatusWithContext(context.Background())
status, err := client.Sys().SealStatus()
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"testing"
log "github.com/hashicorp/go-hclog"
@ -46,7 +45,7 @@ func TestPathMap_Upgrade_API(t *testing.T) {
}
// Create an app-id
_, err = client.Logical().WriteWithContext(context.Background(), "auth/app-id/map/app-id/test-app-id", map[string]interface{}{
_, err = client.Logical().Write("auth/app-id/map/app-id/test-app-id", map[string]interface{}{
"policy": "test-policy",
})
if err != nil {
@ -54,7 +53,7 @@ func TestPathMap_Upgrade_API(t *testing.T) {
}
// Create a user-id
_, err = client.Logical().WriteWithContext(context.Background(), "auth/app-id/map/user-id/test-user-id", map[string]interface{}{
_, err = client.Logical().Write("auth/app-id/map/user-id/test-user-id", map[string]interface{}{
"value": "test-app-id",
})
if err != nil {
@ -62,7 +61,7 @@ func TestPathMap_Upgrade_API(t *testing.T) {
}
// Perform a login. It should succeed.
_, err = client.Logical().WriteWithContext(context.Background(), "auth/app-id/login", map[string]interface{}{
_, err = client.Logical().Write("auth/app-id/login", map[string]interface{}{
"app_id": "test-app-id",
"user_id": "test-user-id",
})
@ -71,20 +70,20 @@ func TestPathMap_Upgrade_API(t *testing.T) {
}
// List the hashed app-ids in the storage
secret, err := client.Logical().ListWithContext(context.Background(), "auth/app-id/map/app-id")
secret, err := client.Logical().List("auth/app-id/map/app-id")
if err != nil {
t.Fatal(err)
}
hashedAppID := secret.Data["keys"].([]interface{})[0].(string)
// Try reading it. This used to cause an issue which is fixed in [GH-3806].
_, err = client.Logical().ReadWithContext(context.Background(), "auth/app-id/map/app-id/"+hashedAppID)
_, err = client.Logical().Read("auth/app-id/map/app-id/" + hashedAppID)
if err != nil {
t.Fatal(err)
}
// Ensure that there was no issue by performing another login
_, err = client.Logical().WriteWithContext(context.Background(), "auth/app-id/login", map[string]interface{}{
_, err = client.Logical().Write("auth/app-id/login", map[string]interface{}{
"app_id": "test-app-id",
"user_id": "test-user-id",
})

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -89,7 +88,7 @@ func TestPluginDeregisterCommand_Run(t *testing.T) {
ui, cmd := testPluginDeregisterCommand(t)
cmd.client = client
if err := client.Sys().RegisterPluginWithContext(context.Background(), &api.RegisterPluginInput{
if err := client.Sys().RegisterPlugin(&api.RegisterPluginInput{
Name: pluginName,
Type: consts.PluginTypeCredential,
Command: pluginName,
@ -112,7 +111,7 @@ func TestPluginDeregisterCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
resp, err := client.Sys().ListPluginsWithContext(context.Background(), &api.ListPluginsInput{
resp, err := client.Sys().ListPlugins(&api.ListPluginsInput{
Type: consts.PluginTypeCredential,
})
if err != nil {

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -104,7 +103,7 @@ func TestPluginRegisterCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
resp, err := client.Sys().ListPluginsWithContext(context.Background(), &api.ListPluginsInput{
resp, err := client.Sys().ListPlugins(&api.ListPluginsInput{
Type: consts.PluginTypeCredential,
})
if err != nil {

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -95,7 +94,7 @@ func TestPluginReloadCommand_Run(t *testing.T) {
ui, cmd := testPluginReloadCommand(t)
cmd.client = client
if err := client.Sys().RegisterPluginWithContext(context.Background(), &api.RegisterPluginInput{
if err := client.Sys().RegisterPlugin(&api.RegisterPluginInput{
Name: pluginName,
Type: consts.PluginTypeCredential,
Command: pluginName,

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"crypto/sha256"
"fmt"
"io"
@ -68,7 +67,7 @@ func testPluginCreateAndRegister(tb testing.TB, client *api.Client, dir, name st
pth, sha256Sum := testPluginCreate(tb, dir, name)
if err := client.Sys().RegisterPluginWithContext(context.Background(), &api.RegisterPluginInput{
if err := client.Sys().RegisterPlugin(&api.RegisterPluginInput{
Name: name,
Type: pluginType,
Command: name,

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"reflect"
"strings"
"testing"
@ -78,7 +77,7 @@ func TestPolicyDeleteCommand_Run(t *testing.T) {
defer closer()
policy := `path "secret/" {}`
if err := client.Sys().PutPolicyWithContext(context.Background(), "my-policy", policy); err != nil {
if err := client.Sys().PutPolicy("my-policy", policy); err != nil {
t.Fatal(err)
}
@ -98,7 +97,7 @@ func TestPolicyDeleteCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
policies, err := client.Sys().ListPoliciesWithContext(context.Background())
policies, err := client.Sys().ListPolicies()
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -77,7 +76,7 @@ func TestPolicyReadCommand_Run(t *testing.T) {
defer closer()
policy := `path "secret/" {}`
if err := client.Sys().PutPolicyWithContext(context.Background(), "my-policy", policy); err != nil {
if err := client.Sys().PutPolicy("my-policy", policy); err != nil {
t.Fatal(err)
}

View File

@ -2,7 +2,6 @@ package command
import (
"bytes"
"context"
"io"
"io/ioutil"
"os"
@ -124,7 +123,7 @@ func TestPolicyWriteCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
policies, err := client.Sys().ListPoliciesWithContext(context.Background())
policies, err := client.Sys().ListPolicies()
if err != nil {
t.Fatal(err)
}
@ -165,7 +164,7 @@ func TestPolicyWriteCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
policies, err := client.Sys().ListPoliciesWithContext(context.Background())
policies, err := client.Sys().ListPolicies()
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -84,7 +83,7 @@ func TestReadCommand_Run(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if _, err := client.Logical().WriteWithContext(context.Background(), "secret/read/foo", map[string]interface{}{
if _, err := client.Logical().Write("secret/read/foo", map[string]interface{}{
"foo": "bar",
}); err != nil {
t.Fatal(err)

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -84,7 +83,7 @@ func TestOperatorRotateCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
status, err := client.Sys().KeyStatusWithContext(context.Background())
status, err := client.Sys().KeyStatus()
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -89,7 +88,7 @@ func TestSecretsDisableCommand_Run(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if err := client.Sys().MountWithContext(context.Background(), "my-secret/", &api.MountInput{
if err := client.Sys().Mount("my-secret/", &api.MountInput{
Type: "generic",
}); err != nil {
t.Fatal(err)
@ -111,7 +110,7 @@ func TestSecretsDisableCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
mounts, err := client.Sys().ListMountsWithContext(context.Background())
mounts, err := client.Sys().ListMounts()
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"io/ioutil"
"strings"
"testing"
@ -128,7 +127,7 @@ func TestSecretsEnableCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
mounts, err := client.Sys().ListMountsWithContext(context.Background())
mounts, err := client.Sys().ListMounts()
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -98,7 +97,7 @@ func TestSecretsMoveCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
mounts, err := client.Sys().ListMountsWithContext(context.Background())
mounts, err := client.Sys().ListMounts()
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -81,7 +80,7 @@ func TestSecretsTuneCommand_Run(t *testing.T) {
cmd.client = client
// Mount
if err := client.Sys().MountWithContext(context.Background(), "kv", &api.MountInput{
if err := client.Sys().Mount("kv", &api.MountInput{
Type: "kv",
Options: map[string]string{
"version": "2",
@ -91,7 +90,7 @@ func TestSecretsTuneCommand_Run(t *testing.T) {
}
// confirm default max_versions
mounts, err := client.Sys().ListMountsWithContext(context.Background())
mounts, err := client.Sys().ListMounts()
if err != nil {
t.Fatal(err)
}
@ -126,7 +125,7 @@ func TestSecretsTuneCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
mounts, err = client.Sys().ListMountsWithContext(context.Background())
mounts, err = client.Sys().ListMounts()
if err != nil {
t.Fatal(err)
}
@ -156,7 +155,7 @@ func TestSecretsTuneCommand_Run(t *testing.T) {
cmd.client = client
// Mount
if err := client.Sys().MountWithContext(context.Background(), "mount_tune_integration", &api.MountInput{
if err := client.Sys().Mount("mount_tune_integration", &api.MountInput{
Type: "pki",
}); err != nil {
t.Fatal(err)
@ -185,7 +184,7 @@ func TestSecretsTuneCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
mounts, err := client.Sys().ListMountsWithContext(context.Background())
mounts, err := client.Sys().ListMounts()
if err != nil {
t.Fatal(err)
}
@ -233,7 +232,7 @@ func TestSecretsTuneCommand_Run(t *testing.T) {
cmd.client = client
// Mount
if err := client.Sys().MountWithContext(context.Background(), "mount_tune_integration", &api.MountInput{
if err := client.Sys().Mount("mount_tune_integration", &api.MountInput{
Type: "pki",
Description: "initial description",
}); err != nil {
@ -254,7 +253,7 @@ func TestSecretsTuneCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
mounts, err := client.Sys().ListMountsWithContext(context.Background())
mounts, err := client.Sys().ListMounts()
if err != nil {
t.Fatal(err)
}
@ -276,7 +275,7 @@ func TestSecretsTuneCommand_Run(t *testing.T) {
cmd.client = client
// Mount
if err := client.Sys().MountWithContext(context.Background(), "mount_tune_integration", &api.MountInput{
if err := client.Sys().Mount("mount_tune_integration", &api.MountInput{
Type: "pki",
Description: "initial description",
}); err != nil {
@ -297,7 +296,7 @@ func TestSecretsTuneCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
mounts, err := client.Sys().ListMountsWithContext(context.Background())
mounts, err := client.Sys().ListMounts()
if err != nil {
t.Fatal(err)
}

View File

@ -61,7 +61,7 @@ func TestTransitSeal_TokenRenewal(t *testing.T) {
req := &api.TokenCreateRequest{
Period: "5s",
}
rsp, err := remoteClient.Auth().Token().CreateWithContext(context.Background(), req)
rsp, err := remoteClient.Auth().Token().Create(req)
if err != nil {
t.Fatalf("err: %s", err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -68,11 +67,11 @@ func TestTokenCapabilitiesCommand_Run(t *testing.T) {
defer closer()
policy := `path "secret/foo" { capabilities = ["read"] }`
if err := client.Sys().PutPolicyWithContext(context.Background(), "policy", policy); err != nil {
if err := client.Sys().PutPolicy("policy", policy); err != nil {
t.Error(err)
}
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"policy"},
TTL: "30m",
})
@ -108,11 +107,11 @@ func TestTokenCapabilitiesCommand_Run(t *testing.T) {
defer closer()
policy := `path "secret/foo" { capabilities = ["read"] }`
if err := client.Sys().PutPolicyWithContext(context.Background(), "policy", policy); err != nil {
if err := client.Sys().PutPolicy("policy", policy); err != nil {
t.Error(err)
}
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"policy"},
TTL: "30m",
})

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"reflect"
"strings"
"testing"
@ -116,7 +115,7 @@ func TestTokenCreateCommand_Run(t *testing.T) {
}
token := strings.TrimSpace(ui.OutputWriter.String())
secret, err := client.Auth().Token().LookupWithContext(context.Background(), token)
secret, err := client.Auth().Token().Lookup(token)
if secret == nil || err != nil {
t.Fatal(err)
}
@ -141,7 +140,7 @@ func TestTokenCreateCommand_Run(t *testing.T) {
}
token := strings.TrimSpace(ui.OutputWriter.String())
secret, err := client.Auth().Token().LookupWithContext(context.Background(), token)
secret, err := client.Auth().Token().Lookup(token)
if secret == nil || err != nil {
t.Fatal(err)
}
@ -177,7 +176,7 @@ func TestTokenCreateCommand_Run(t *testing.T) {
}
token := strings.TrimSpace(ui.OutputWriter.String())
secret, err := client.Auth().Token().LookupWithContext(context.Background(), token)
secret, err := client.Auth().Token().Lookup(token)
if secret == nil || err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"encoding/json"
"strconv"
"strings"
@ -107,7 +106,7 @@ func TestTokenRenewCommand_Run(t *testing.T) {
t.Errorf("expected %d to be %d", code, exp)
}
secret, err := client.Auth().Token().LookupWithContext(context.Background(), token)
secret, err := client.Auth().Token().Lookup(token)
if err != nil {
t.Fatal(err)
}
@ -142,7 +141,7 @@ func TestTokenRenewCommand_Run(t *testing.T) {
t.Errorf("expected %d to be %d", code, exp)
}
secret, err := client.Auth().Token().LookupWithContext(context.Background(), token)
secret, err := client.Auth().Token().Lookup(token)
if err != nil {
t.Fatal(err)
}
@ -181,7 +180,7 @@ func TestTokenRenewCommand_Run(t *testing.T) {
}
client.SetToken(oldToken)
secret, err := client.Auth().Token().LookupWithContext(context.Background(), token)
secret, err := client.Auth().Token().Lookup(token)
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -130,7 +129,7 @@ func TestTokenRevokeCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
secret, err := client.Auth().Token().LookupWithContext(context.Background(), token)
secret, err := client.Auth().Token().Lookup(token)
if secret != nil || err == nil {
t.Errorf("expected token to be revoked: %#v", secret)
}
@ -158,7 +157,7 @@ func TestTokenRevokeCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
secret, err := client.Auth().Token().LookupSelfWithContext(context.Background())
secret, err := client.Auth().Token().LookupSelf()
if secret != nil || err == nil {
t.Errorf("expected token to be revoked: %#v", secret)
}
@ -189,7 +188,7 @@ func TestTokenRevokeCommand_Run(t *testing.T) {
t.Errorf("expected %q to contain %q", combined, expected)
}
secret, err := client.Auth().Token().LookupWithContext(context.Background(), token)
secret, err := client.Auth().Token().Lookup(token)
if secret != nil || err == nil {
t.Errorf("expected token to be revoked: %#v", secret)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"strings"
"testing"
@ -23,7 +22,7 @@ func testUnwrapCommand(tb testing.TB) (*cli.MockUi, *UnwrapCommand) {
func testUnwrapWrappedToken(tb testing.TB, client *api.Client, data map[string]interface{}) string {
tb.Helper()
wrapped, err := client.Logical().WriteWithContext(context.Background(), "sys/wrapping/wrap", data)
wrapped, err := client.Logical().Write("sys/wrapping/wrap", data)
if err != nil {
tb.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package command
import (
"context"
"io"
"strings"
"testing"
@ -122,7 +121,7 @@ func TestWriteCommand_Run(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
if err := client.Sys().MountWithContext(context.Background(), "transit/", &api.MountInput{
if err := client.Sys().Mount("transit/", &api.MountInput{
Type: "transit",
}); err != nil {
t.Fatal(err)
@ -139,7 +138,7 @@ func TestWriteCommand_Run(t *testing.T) {
t.Fatalf("expected %d to be %d: %q", code, exp, ui.ErrorWriter.String())
}
secret, err := client.Logical().ReadWithContext(context.Background(), "transit/keys/my-key")
secret, err := client.Logical().Read("transit/keys/my-key")
if err != nil {
t.Fatal(err)
}
@ -171,7 +170,7 @@ func TestWriteCommand_Run(t *testing.T) {
t.Fatalf("expected 0 to be %d", code)
}
secret, err := client.Logical().ReadWithContext(context.Background(), "secret/write/stdin_full")
secret, err := client.Logical().Read("secret/write/stdin_full")
if err != nil {
t.Fatal(err)
}
@ -206,7 +205,7 @@ func TestWriteCommand_Run(t *testing.T) {
t.Fatalf("expected 0 to be %d", code)
}
secret, err := client.Logical().ReadWithContext(context.Background(), "secret/write/stdin_value")
secret, err := client.Logical().Read("secret/write/stdin_value")
if err != nil {
t.Fatal(err)
}
@ -234,7 +233,7 @@ func TestWriteCommand_Run(t *testing.T) {
t.Fatalf("expected 0 to be %d", code)
}
secret, err := client.Logical().ReadWithContext(context.Background(), "secret/write/integration")
secret, err := client.Logical().Read("secret/write/integration")
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package http
import (
"context"
"strings"
"testing"
@ -23,7 +22,7 @@ func TestAuthTokenCreate(t *testing.T) {
}
client.SetToken(token)
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Lease: "1h",
})
if err != nil {
@ -38,7 +37,7 @@ func TestAuthTokenCreate(t *testing.T) {
Renewable: new(bool),
}
secret, err = client.Auth().Token().CreateWithContext(context.Background(), renewCreateRequest)
secret, err = client.Auth().Token().Create(renewCreateRequest)
if err != nil {
t.Fatal(err)
}
@ -50,7 +49,7 @@ func TestAuthTokenCreate(t *testing.T) {
}
*renewCreateRequest.Renewable = true
secret, err = client.Auth().Token().CreateWithContext(context.Background(), renewCreateRequest)
secret, err = client.Auth().Token().Create(renewCreateRequest)
if err != nil {
t.Fatal(err)
}
@ -66,7 +65,7 @@ func TestAuthTokenCreate(t *testing.T) {
ExplicitMaxTTL: "1800s",
}
secret, err = client.Auth().Token().CreateWithContext(context.Background(), explicitMaxCreateRequest)
secret, err = client.Auth().Token().Create(explicitMaxCreateRequest)
if err != nil {
t.Fatal(err)
}
@ -75,7 +74,7 @@ func TestAuthTokenCreate(t *testing.T) {
}
explicitMaxCreateRequest.ExplicitMaxTTL = "2h"
secret, err = client.Auth().Token().CreateWithContext(context.Background(), explicitMaxCreateRequest)
secret, err = client.Auth().Token().Create(explicitMaxCreateRequest)
if err != nil {
t.Fatal(err)
}
@ -99,7 +98,7 @@ func TestAuthTokenLookup(t *testing.T) {
client.SetToken(token)
// Create a new token ...
secret2, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret2, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Lease: "1h",
})
if err != nil {
@ -107,7 +106,7 @@ func TestAuthTokenLookup(t *testing.T) {
}
// lookup details of this token
secret, err := client.Auth().Token().LookupWithContext(context.Background(), secret2.Auth.ClientToken)
secret, err := client.Auth().Token().Lookup(secret2.Auth.ClientToken)
if err != nil {
t.Fatalf("unable to lookup details of token, err = %v", err)
}
@ -132,7 +131,7 @@ func TestAuthTokenLookupSelf(t *testing.T) {
client.SetToken(token)
// you should be able to lookup your own token
secret, err := client.Auth().Token().LookupSelfWithContext(context.Background())
secret, err := client.Auth().Token().LookupSelf()
if err != nil {
t.Fatalf("should be allowed to lookup self, err = %v", err)
}
@ -160,7 +159,7 @@ func TestAuthTokenRenew(t *testing.T) {
client.SetToken(token)
// The default root token is not renewable, so this should not work
_, err = client.Auth().Token().RenewWithContext(context.Background(), token, 0)
_, err = client.Auth().Token().Renew(token, 0)
if err == nil {
t.Fatal("should not be allowed to renew root token")
}
@ -169,7 +168,7 @@ func TestAuthTokenRenew(t *testing.T) {
}
// Create a new token that should be renewable
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Lease: "1h",
})
if err != nil {
@ -178,7 +177,7 @@ func TestAuthTokenRenew(t *testing.T) {
client.SetToken(secret.Auth.ClientToken)
// Now attempt a renew with the new token
secret, err = client.Auth().Token().RenewWithContext(context.Background(), secret.Auth.ClientToken, 3600)
secret, err = client.Auth().Token().Renew(secret.Auth.ClientToken, 3600)
if err != nil {
t.Fatal(err)
}
@ -192,7 +191,7 @@ func TestAuthTokenRenew(t *testing.T) {
}
// Do the same thing with the self variant
secret, err = client.Auth().Token().RenewSelfWithContext(context.Background(), 3600)
secret, err = client.Auth().Token().RenewSelf(3600)
if err != nil {
t.Fatal(err)
}

View File

@ -2,7 +2,6 @@ package http
import (
"bytes"
"context"
"encoding/base64"
"encoding/json"
"fmt"
@ -62,7 +61,7 @@ func TestHTTP_Fallback_Bad_Address(t *testing.T) {
}
client.SetToken(cluster.RootToken)
secret, err := client.Auth().Token().LookupSelfWithContext(context.Background())
secret, err := client.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
@ -110,7 +109,7 @@ func TestHTTP_Fallback_Disabled(t *testing.T) {
}
client.SetToken(cluster.RootToken)
secret, err := client.Auth().Token().LookupSelfWithContext(context.Background())
secret, err := client.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
@ -530,7 +529,7 @@ func TestHTTP_Forwarding_ClientTLS(t *testing.T) {
t.Fatal(err)
}
secret, err := client.Logical().WriteWithContext(context.Background(), "auth/cert/login", nil)
secret, err := client.Logical().Write("auth/cert/login", nil)
if err != nil {
t.Fatal(err)
}
@ -547,7 +546,7 @@ func TestHTTP_Forwarding_ClientTLS(t *testing.T) {
t.Fatalf("bad client token: %#v", *secret.Auth)
}
client.SetToken(secret.Auth.ClientToken)
secret, err = client.Auth().Token().LookupSelfWithContext(context.Background())
secret, err = client.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
@ -595,7 +594,7 @@ func TestHTTP_Forwarding_LocalOnly(t *testing.T) {
vault.TestWaitActive(t, cores[0].Core)
testLocalOnly := func(client *api.Client) {
_, err := client.Logical().ReadWithContext(context.Background(), "sys/config/state/sanitized")
_, err := client.Logical().Read("sys/config/state/sanitized")
if err == nil {
t.Fatal("expected error")
}

View File

@ -843,7 +843,7 @@ func TestHandler_Parse_Form(t *testing.T) {
client := cores[0].Client
client.SetToken(cluster.RootToken)
apiResp, err := client.Logical().ReadWithContext(context.Background(), "secret/foo")
apiResp, err := client.Logical().Read("secret/foo")
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package http
import (
"context"
"encoding/json"
"io/ioutil"
"os"
@ -56,7 +55,7 @@ func getPluginClusterAndCore(t testing.TB, logger log.Logger) (*vault.TestCluste
vault.TestAddTestPlugin(t, core.Core, "mock-plugin", consts.PluginTypeSecrets, "TestPlugin_PluginMain", []string{}, "")
// Mount the mock plugin
err = core.Client.Sys().MountWithContext(context.Background(), "mock", &api.MountInput{
err = core.Client.Sys().Mount("mock", &api.MountInput{
Type: "mock-plugin",
})
if err != nil {
@ -104,14 +103,14 @@ func TestPlugin_MockList(t *testing.T) {
cluster, core := getPluginClusterAndCore(t, logger)
defer cluster.Cleanup()
_, err := core.Client.Logical().WriteWithContext(context.Background(), "mock/kv/foo", map[string]interface{}{
_, err := core.Client.Logical().Write("mock/kv/foo", map[string]interface{}{
"value": "baz",
})
if err != nil {
t.Fatal(err)
}
keys, err := core.Client.Logical().ListWithContext(context.Background(), "mock/kv/")
keys, err := core.Client.Logical().List("mock/kv/")
if err != nil {
t.Fatal(err)
}
@ -119,14 +118,14 @@ func TestPlugin_MockList(t *testing.T) {
t.Fatal(keys)
}
_, err = core.Client.Logical().WriteWithContext(context.Background(), "mock/kv/zoo", map[string]interface{}{
_, err = core.Client.Logical().Write("mock/kv/zoo", map[string]interface{}{
"value": "baz",
})
if err != nil {
t.Fatal(err)
}
keys, err = core.Client.Logical().ListWithContext(context.Background(), "mock/kv/")
keys, err = core.Client.Logical().List("mock/kv/")
if err != nil {
t.Fatal(err)
}
@ -167,7 +166,7 @@ func TestPlugin_GetParams(t *testing.T) {
cluster, core := getPluginClusterAndCore(t, logger)
defer cluster.Cleanup()
_, err := core.Client.Logical().WriteWithContext(context.Background(), "mock/kv/foo", map[string]interface{}{
_, err := core.Client.Logical().Write("mock/kv/foo", map[string]interface{}{
"value": "baz",
})
if err != nil {

View File

@ -1,7 +1,6 @@
package http
import (
"context"
"encoding/json"
"testing"
@ -20,7 +19,7 @@ func TestSysHostInfo(t *testing.T) {
vault.TestWaitActive(t, cores[0].Core)
// Query against the active node, should get host information back
secret, err := cores[0].Client.Logical().ReadWithContext(context.Background(), "sys/host-info")
secret, err := cores[0].Client.Logical().Read("sys/host-info")
if err != nil {
t.Fatal(err)
}
@ -55,7 +54,7 @@ func TestSysHostInfo(t *testing.T) {
}
// Query against a standby, should error
secret, err = cores[1].Client.Logical().ReadWithContext(context.Background(), "sys/host-info")
secret, err = cores[1].Client.Logical().Read("sys/host-info")
if err == nil || secret != nil {
t.Fatalf("expected error on standby node, HostInfo: %v", secret)
}

View File

@ -1,7 +1,6 @@
package http
import (
"context"
"fmt"
"math/rand"
"testing"
@ -30,10 +29,10 @@ func TestSysMountConfig(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer client.Sys().UnmountWithContext(context.Background(), path)
defer client.Sys().Unmount(path)
// Get config info for this mount
mountConfig, err := client.Sys().MountConfigWithContext(context.Background(), path)
mountConfig, err := client.Sys().MountConfig(path)
if err != nil {
t.Fatal(err)
}
@ -61,6 +60,6 @@ func testMount(client *api.Client) (string, error) {
rand.Seed(time.Now().UTC().UnixNano())
randInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
path := fmt.Sprintf("testmount-%d", randInt)
err := client.Sys().MountWithContext(context.Background(), path, &api.MountInput{Type: "kv"})
err := client.Sys().Mount(path, &api.MountInput{Type: "kv"})
return path, err
}

View File

@ -1,7 +1,6 @@
package http
import (
"context"
"encoding/json"
"reflect"
"testing"
@ -30,7 +29,7 @@ func TestHTTP_Wrapping(t *testing.T) {
client.SetToken(cluster.RootToken)
// Write a value that we will use with wrapping for lookup
_, err := client.Logical().WriteWithContext(context.Background(), "secret/foo", map[string]interface{}{
_, err := client.Logical().Write("secret/foo", map[string]interface{}{
"zip": "zap",
})
if err != nil {
@ -48,19 +47,19 @@ func TestHTTP_Wrapping(t *testing.T) {
// First test: basic things that should fail, lookup edition
// Root token isn't a wrapping token
_, err = client.Logical().WriteWithContext(context.Background(), "sys/wrapping/lookup", nil)
_, err = client.Logical().Write("sys/wrapping/lookup", nil)
if err == nil {
t.Fatal("expected error")
}
// Not supplied
_, err = client.Logical().WriteWithContext(context.Background(), "sys/wrapping/lookup", map[string]interface{}{
_, err = client.Logical().Write("sys/wrapping/lookup", map[string]interface{}{
"foo": "bar",
})
if err == nil {
t.Fatal("expected error")
}
// Nonexistent token isn't a wrapping token
_, err = client.Logical().WriteWithContext(context.Background(), "sys/wrapping/lookup", map[string]interface{}{
_, err = client.Logical().Write("sys/wrapping/lookup", map[string]interface{}{
"token": "bar",
})
if err == nil {
@ -69,24 +68,24 @@ func TestHTTP_Wrapping(t *testing.T) {
// Second: basic things that should fail, unwrap edition
// Root token isn't a wrapping token
_, err = client.Logical().UnwrapWithContext(context.Background(), cluster.RootToken)
_, err = client.Logical().Unwrap(cluster.RootToken)
if err == nil {
t.Fatal("expected error")
}
// Root token isn't a wrapping token
_, err = client.Logical().WriteWithContext(context.Background(), "sys/wrapping/unwrap", nil)
_, err = client.Logical().Write("sys/wrapping/unwrap", nil)
if err == nil {
t.Fatal("expected error")
}
// Not supplied
_, err = client.Logical().WriteWithContext(context.Background(), "sys/wrapping/unwrap", map[string]interface{}{
_, err = client.Logical().Write("sys/wrapping/unwrap", map[string]interface{}{
"foo": "bar",
})
if err == nil {
t.Fatal("expected error")
}
// Nonexistent token isn't a wrapping token
_, err = client.Logical().WriteWithContext(context.Background(), "sys/wrapping/unwrap", map[string]interface{}{
_, err = client.Logical().Write("sys/wrapping/unwrap", map[string]interface{}{
"token": "bar",
})
if err == nil {
@ -98,7 +97,7 @@ func TestHTTP_Wrapping(t *testing.T) {
//
// Create a wrapping token
secret, err := client.Logical().ReadWithContext(context.Background(), "secret/foo")
secret, err := client.Logical().Read("secret/foo")
if err != nil {
t.Fatal(err)
}
@ -109,7 +108,7 @@ func TestHTTP_Wrapping(t *testing.T) {
// Test this twice to ensure no ill effect to the wrapping token as a result of the lookup
for i := 0; i < 2; i++ {
secret, err = client.Logical().WriteWithContext(context.Background(), "sys/wrapping/lookup", map[string]interface{}{
secret, err = client.Logical().Write("sys/wrapping/lookup", map[string]interface{}{
"token": wrapInfo.Token,
})
if err != nil {
@ -132,7 +131,7 @@ func TestHTTP_Wrapping(t *testing.T) {
//
// Create a wrapping token
secret, err = client.Logical().ReadWithContext(context.Background(), "secret/foo")
secret, err = client.Logical().Read("secret/foo")
if err != nil {
t.Fatal(err)
}
@ -143,7 +142,7 @@ func TestHTTP_Wrapping(t *testing.T) {
// Test unwrap via the client token
client.SetToken(wrapInfo.Token)
secret, err = client.Logical().WriteWithContext(context.Background(), "sys/wrapping/unwrap", nil)
secret, err = client.Logical().Write("sys/wrapping/unwrap", nil)
if err != nil {
t.Fatal(err)
}
@ -152,14 +151,14 @@ func TestHTTP_Wrapping(t *testing.T) {
}
ret1 := secret
// Should be expired and fail
_, err = client.Logical().WriteWithContext(context.Background(), "sys/wrapping/unwrap", nil)
_, err = client.Logical().Write("sys/wrapping/unwrap", nil)
if err == nil {
t.Fatal("expected err")
}
// Create a wrapping token
client.SetToken(cluster.RootToken)
secret, err = client.Logical().ReadWithContext(context.Background(), "secret/foo")
secret, err = client.Logical().Read("secret/foo")
if err != nil {
t.Fatal(err)
}
@ -169,7 +168,7 @@ func TestHTTP_Wrapping(t *testing.T) {
wrapInfo = secret.WrapInfo
// Test as a separate token
secret, err = client.Logical().WriteWithContext(context.Background(), "sys/wrapping/unwrap", map[string]interface{}{
secret, err = client.Logical().Write("sys/wrapping/unwrap", map[string]interface{}{
"token": wrapInfo.Token,
})
if err != nil {
@ -177,7 +176,7 @@ func TestHTTP_Wrapping(t *testing.T) {
}
ret2 := secret
// Should be expired and fail
_, err = client.Logical().WriteWithContext(context.Background(), "sys/wrapping/unwrap", map[string]interface{}{
_, err = client.Logical().Write("sys/wrapping/unwrap", map[string]interface{}{
"token": wrapInfo.Token,
})
if err == nil {
@ -185,7 +184,7 @@ func TestHTTP_Wrapping(t *testing.T) {
}
// Create a wrapping token
secret, err = client.Logical().ReadWithContext(context.Background(), "secret/foo")
secret, err = client.Logical().Read("secret/foo")
if err != nil {
t.Fatal(err)
}
@ -196,20 +195,20 @@ func TestHTTP_Wrapping(t *testing.T) {
// Read response directly
client.SetToken(wrapInfo.Token)
secret, err = client.Logical().ReadWithContext(context.Background(), "cubbyhole/response")
secret, err = client.Logical().Read("cubbyhole/response")
if err != nil {
t.Fatal(err)
}
ret3 := secret
// Should be expired and fail
_, err = client.Logical().WriteWithContext(context.Background(), "cubbyhole/response", nil)
_, err = client.Logical().Write("cubbyhole/response", nil)
if err == nil {
t.Fatal("expected err")
}
// Create a wrapping token
client.SetToken(cluster.RootToken)
secret, err = client.Logical().ReadWithContext(context.Background(), "secret/foo")
secret, err = client.Logical().Read("secret/foo")
if err != nil {
t.Fatal(err)
}
@ -219,13 +218,13 @@ func TestHTTP_Wrapping(t *testing.T) {
wrapInfo = secret.WrapInfo
// Read via Unwrap method
secret, err = client.Logical().UnwrapWithContext(context.Background(), wrapInfo.Token)
secret, err = client.Logical().Unwrap(wrapInfo.Token)
if err != nil {
t.Fatal(err)
}
ret4 := secret
// Should be expired and fail
_, err = client.Logical().UnwrapWithContext(context.Background(), wrapInfo.Token)
_, err = client.Logical().Unwrap(wrapInfo.Token)
if err == nil {
t.Fatal("expected err")
}
@ -270,7 +269,7 @@ func TestHTTP_Wrapping(t *testing.T) {
client.SetWrappingLookupFunc(func(operation, path string) string {
return ""
})
secret, err = client.Logical().WriteWithContext(context.Background(), "sys/wrapping/wrap", data)
secret, err = client.Logical().Write("sys/wrapping/wrap", data)
if err == nil {
t.Fatal("expected error")
}
@ -283,11 +282,11 @@ func TestHTTP_Wrapping(t *testing.T) {
return api.DefaultWrappingLookupFunc(operation, path)
})
secret, err = client.Logical().WriteWithContext(context.Background(), "sys/wrapping/wrap", data)
secret, err = client.Logical().Write("sys/wrapping/wrap", data)
if err != nil {
t.Fatal(err)
}
secret, err = client.Logical().UnwrapWithContext(context.Background(), secret.WrapInfo.Token)
secret, err = client.Logical().Unwrap(secret.WrapInfo.Token)
if err != nil {
t.Fatal(err)
}
@ -300,7 +299,7 @@ func TestHTTP_Wrapping(t *testing.T) {
//
// Create a wrapping token
secret, err = client.Logical().ReadWithContext(context.Background(), "secret/foo")
secret, err = client.Logical().Read("secret/foo")
if err != nil {
t.Fatal(err)
}
@ -315,7 +314,7 @@ func TestHTTP_Wrapping(t *testing.T) {
}
// Test rewrapping
secret, err = client.Logical().WriteWithContext(context.Background(), "sys/wrapping/rewrap", map[string]interface{}{
secret, err = client.Logical().Write("sys/wrapping/rewrap", map[string]interface{}{
"token": wrapInfo.Token,
})
if err != nil {
@ -328,7 +327,7 @@ func TestHTTP_Wrapping(t *testing.T) {
}
// Should be expired and fail
_, err = client.Logical().WriteWithContext(context.Background(), "sys/wrapping/unwrap", map[string]interface{}{
_, err = client.Logical().Write("sys/wrapping/unwrap", map[string]interface{}{
"token": wrapInfo.Token,
})
if err == nil {
@ -337,12 +336,12 @@ func TestHTTP_Wrapping(t *testing.T) {
// Attempt unwrapping the rewrapped token
wrapToken := secret.WrapInfo.Token
secret, err = client.Logical().UnwrapWithContext(context.Background(), wrapToken)
secret, err = client.Logical().Unwrap(wrapToken)
if err != nil {
t.Fatal(err)
}
// Should be expired and fail
_, err = client.Logical().UnwrapWithContext(context.Background(), wrapToken)
_, err = client.Logical().Unwrap(wrapToken)
if err == nil {
t.Fatal("expected err")
}

View File

@ -1,7 +1,6 @@
package http
import (
"context"
"testing"
kv "github.com/hashicorp/vault-plugin-secrets-kv"
@ -27,7 +26,7 @@ func TestUnwrapping_Raw_Body(t *testing.T) {
client := cluster.Cores[0].Client
// Mount a k/v backend, version 2
err := client.Sys().MountWithContext(context.Background(), "kv", &api.MountInput{
err := client.Sys().Mount("kv", &api.MountInput{
Type: "kv",
Options: map[string]string{"version": "2"},
})
@ -38,7 +37,7 @@ func TestUnwrapping_Raw_Body(t *testing.T) {
client.SetWrappingLookupFunc(func(operation, path string) string {
return "5m"
})
secret, err := client.Logical().WriteWithContext(context.Background(), "kv/foo/bar", map[string]interface{}{
secret, err := client.Logical().Write("kv/foo/bar", map[string]interface{}{
"a": "b",
})
if err != nil {
@ -53,7 +52,7 @@ func TestUnwrapping_Raw_Body(t *testing.T) {
wrapToken := secret.WrapInfo.Token
client.SetWrappingLookupFunc(nil)
secret, err = client.Logical().UnwrapWithContext(context.Background(), wrapToken)
secret, err = client.Logical().Unwrap(wrapToken)
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package vault_test
import (
"context"
"encoding/json"
"testing"
"time"
@ -39,7 +38,7 @@ func TestExpiration_RenewToken_TestCluster(t *testing.T) {
}
// Tune the mount
err = client.Sys().TuneMountWithContext(context.Background(), "auth/approle", api.MountConfigInput{
err = client.Sys().TuneMount("auth/approle", api.MountConfigInput{
DefaultLeaseTTL: "5s",
MaxLeaseTTL: "5s",
})
@ -48,7 +47,7 @@ func TestExpiration_RenewToken_TestCluster(t *testing.T) {
}
// Create role
resp, err := client.Logical().WriteWithContext(context.Background(), "auth/approle/role/role-period", map[string]interface{}{
resp, err := client.Logical().Write("auth/approle/role/role-period", map[string]interface{}{
"period": "5s",
})
if err != nil {
@ -56,7 +55,7 @@ func TestExpiration_RenewToken_TestCluster(t *testing.T) {
}
// Get role_id
resp, err = client.Logical().ReadWithContext(context.Background(), "auth/approle/role/role-period/role-id")
resp, err = client.Logical().Read("auth/approle/role/role-period/role-id")
if err != nil {
t.Fatal(err)
}
@ -66,7 +65,7 @@ func TestExpiration_RenewToken_TestCluster(t *testing.T) {
roleID := resp.Data["role_id"]
// Get secret_id
resp, err = client.Logical().WriteWithContext(context.Background(), "auth/approle/role/role-period/secret-id", map[string]interface{}{})
resp, err = client.Logical().Write("auth/approle/role/role-period/secret-id", map[string]interface{}{})
if err != nil {
t.Fatal(err)
}
@ -76,7 +75,7 @@ func TestExpiration_RenewToken_TestCluster(t *testing.T) {
secretID := resp.Data["secret_id"]
// Login
resp, err = client.Logical().WriteWithContext(context.Background(), "auth/approle/login", map[string]interface{}{
resp, err = client.Logical().Write("auth/approle/login", map[string]interface{}{
"role_id": roleID,
"secret_id": secretID,
})
@ -98,7 +97,7 @@ func TestExpiration_RenewToken_TestCluster(t *testing.T) {
time.Sleep(3 * time.Second)
// Renew
resp, err = client.Logical().WriteWithContext(context.Background(), "auth/token/renew", map[string]interface{}{
resp, err = client.Logical().Write("auth/token/renew", map[string]interface{}{
"token": roleToken,
})
if err != nil {
@ -109,7 +108,7 @@ func TestExpiration_RenewToken_TestCluster(t *testing.T) {
}
// Perform token lookup and verify TTL
resp, err = client.Auth().Token().LookupWithContext(context.Background(), roleToken)
resp, err = client.Auth().Token().Lookup(roleToken)
if err != nil {
t.Fatal(err)
}
@ -134,7 +133,7 @@ func TestExpiration_RenewToken_TestCluster(t *testing.T) {
time.Sleep(3 * time.Second)
// Do a second renewal to ensure that period can be renewed past sys/mount max_ttl
resp, err = client.Logical().WriteWithContext(context.Background(), "auth/token/renew", map[string]interface{}{
resp, err = client.Logical().Write("auth/token/renew", map[string]interface{}{
"token": roleToken,
})
if err != nil {
@ -145,7 +144,7 @@ func TestExpiration_RenewToken_TestCluster(t *testing.T) {
}
// Perform token lookup and verify TTL
resp, err = client.Auth().Token().LookupWithContext(context.Background(), roleToken)
resp, err = client.Auth().Token().Lookup(roleToken)
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package api
import (
"context"
"testing"
"time"
@ -19,13 +18,13 @@ func TestRenewer_Renew(t *testing.T) {
t.Run("kv", func(t *testing.T) {
t.Parallel()
if _, err := client.Logical().WriteWithContext(context.Background(), "secret/value", map[string]interface{}{
if _, err := client.Logical().Write("secret/value", map[string]interface{}{
"foo": "bar",
}); err != nil {
t.Fatal(err)
}
secret, err := client.Logical().ReadWithContext(context.Background(), "secret/value")
secret, err := client.Logical().Read("secret/value")
if err != nil {
t.Fatal(err)
}
@ -54,13 +53,13 @@ func TestRenewer_Renew(t *testing.T) {
t.Run("transit", func(t *testing.T) {
t.Parallel()
if err := client.Sys().MountWithContext(context.Background(), "transit", &api.MountInput{
if err := client.Sys().Mount("transit", &api.MountInput{
Type: "transit",
}); err != nil {
t.Fatal(err)
}
secret, err := client.Logical().WriteWithContext(context.Background(), "transit/encrypt/my-app", map[string]interface{}{
secret, err := client.Logical().Write("transit/encrypt/my-app", map[string]interface{}{
"plaintext": "Zm9vCg==",
})
if err != nil {
@ -94,19 +93,19 @@ func TestRenewer_Renew(t *testing.T) {
cleanup, pgURL := postgreshelper.PrepareTestContainer(t, "")
defer cleanup()
if err := client.Sys().MountWithContext(context.Background(), "database", &api.MountInput{
if err := client.Sys().Mount("database", &api.MountInput{
Type: "database",
}); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "database/config/postgresql", map[string]interface{}{
if _, err := client.Logical().Write("database/config/postgresql", map[string]interface{}{
"plugin_name": "postgresql-database-plugin",
"connection_url": pgURL,
"allowed_roles": "readonly",
}); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "database/roles/readonly", map[string]interface{}{
if _, err := client.Logical().Write("database/roles/readonly", map[string]interface{}{
"db_name": "postgresql",
"creation_statements": `` +
`CREATE ROLE "{{name}}" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}';` +
@ -117,7 +116,7 @@ func TestRenewer_Renew(t *testing.T) {
t.Fatal(err)
}
secret, err := client.Logical().ReadWithContext(context.Background(), "database/creds/readonly")
secret, err := client.Logical().Read("database/creds/readonly")
if err != nil {
t.Fatal(err)
}
@ -173,7 +172,7 @@ func TestRenewer_Renew(t *testing.T) {
t.Run("auth", func(t *testing.T) {
t.Parallel()
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
TTL: "5s",
ExplicitMaxTTL: "10s",

View File

@ -1,7 +1,6 @@
package api
import (
"context"
"encoding/json"
"reflect"
"strings"
@ -170,14 +169,14 @@ func TestSecret_TokenID(t *testing.T) {
if err := client.Sys().EnableAuth("userpass", "userpass", ""); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/test", map[string]interface{}{
if _, err := client.Logical().Write("auth/userpass/users/test", map[string]interface{}{
"password": "test",
"policies": "default",
}); err != nil {
t.Fatal(err)
}
secret, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/login/test", map[string]interface{}{
secret, err := client.Logical().Write("auth/userpass/login/test", map[string]interface{}{
"password": "test",
})
if err != nil || secret == nil {
@ -200,7 +199,7 @@ func TestSecret_TokenID(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
})
if err != nil {
@ -223,7 +222,7 @@ func TestSecret_TokenID(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
})
if err != nil {
@ -231,7 +230,7 @@ func TestSecret_TokenID(t *testing.T) {
}
token := secret.Auth.ClientToken
secret, err = client.Auth().Token().LookupWithContext(context.Background(), token)
secret, err = client.Auth().Token().Lookup(token)
if err != nil {
t.Fatal(err)
}
@ -251,7 +250,7 @@ func TestSecret_TokenID(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
})
if err != nil {
@ -260,7 +259,7 @@ func TestSecret_TokenID(t *testing.T) {
token := secret.Auth.ClientToken
client.SetToken(token)
secret, err = client.Auth().Token().LookupSelfWithContext(context.Background())
secret, err = client.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
@ -280,7 +279,7 @@ func TestSecret_TokenID(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
})
if err != nil {
@ -288,7 +287,7 @@ func TestSecret_TokenID(t *testing.T) {
}
token := secret.Auth.ClientToken
secret, err = client.Auth().Token().RenewWithContext(context.Background(), token, 0)
secret, err = client.Auth().Token().Renew(token, 0)
if err != nil {
t.Fatal(err)
}
@ -308,7 +307,7 @@ func TestSecret_TokenID(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
})
if err != nil {
@ -317,7 +316,7 @@ func TestSecret_TokenID(t *testing.T) {
token := secret.Auth.ClientToken
client.SetToken(token)
secret, err = client.Auth().Token().RenewSelfWithContext(context.Background(), 0)
secret, err = client.Auth().Token().RenewSelf(0)
if err != nil {
t.Fatal(err)
}
@ -438,14 +437,14 @@ func TestSecret_TokenAccessor(t *testing.T) {
if err := client.Sys().EnableAuth("userpass", "userpass", ""); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/test", map[string]interface{}{
if _, err := client.Logical().Write("auth/userpass/users/test", map[string]interface{}{
"password": "test",
"policies": "default",
}); err != nil {
t.Fatal(err)
}
secret, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/login/test", map[string]interface{}{
secret, err := client.Logical().Write("auth/userpass/login/test", map[string]interface{}{
"password": "test",
})
if err != nil || secret == nil {
@ -468,7 +467,7 @@ func TestSecret_TokenAccessor(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
})
if err != nil {
@ -491,7 +490,7 @@ func TestSecret_TokenAccessor(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
})
if err != nil {
@ -499,7 +498,7 @@ func TestSecret_TokenAccessor(t *testing.T) {
}
token, accessor := secret.Auth.ClientToken, secret.Auth.Accessor
secret, err = client.Auth().Token().LookupWithContext(context.Background(), token)
secret, err = client.Auth().Token().Lookup(token)
if err != nil {
t.Fatal(err)
}
@ -519,7 +518,7 @@ func TestSecret_TokenAccessor(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
})
if err != nil {
@ -528,7 +527,7 @@ func TestSecret_TokenAccessor(t *testing.T) {
token, accessor := secret.Auth.ClientToken, secret.Auth.Accessor
client.SetToken(token)
secret, err = client.Auth().Token().LookupSelfWithContext(context.Background())
secret, err = client.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
@ -548,7 +547,7 @@ func TestSecret_TokenAccessor(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
})
if err != nil {
@ -556,7 +555,7 @@ func TestSecret_TokenAccessor(t *testing.T) {
}
token, accessor := secret.Auth.ClientToken, secret.Auth.Accessor
secret, err = client.Auth().Token().RenewWithContext(context.Background(), token, 0)
secret, err = client.Auth().Token().Renew(token, 0)
if err != nil {
t.Fatal(err)
}
@ -576,7 +575,7 @@ func TestSecret_TokenAccessor(t *testing.T) {
client, closer := testVaultServer(t)
defer closer()
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
})
if err != nil {
@ -585,7 +584,7 @@ func TestSecret_TokenAccessor(t *testing.T) {
token, accessor := secret.Auth.ClientToken, secret.Auth.Accessor
client.SetToken(token)
secret, err = client.Auth().Token().RenewSelfWithContext(context.Background(), 0)
secret, err = client.Auth().Token().RenewSelf(0)
if err != nil {
t.Fatal(err)
}
@ -674,7 +673,7 @@ func TestSecret_TokenRemainingUses(t *testing.T) {
if err := client.Sys().EnableAuth("userpass", "userpass", ""); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/test", map[string]interface{}{
if _, err := client.Logical().Write("auth/userpass/users/test", map[string]interface{}{
"password": "test",
"policies": "default",
"num_uses": uses,
@ -682,7 +681,7 @@ func TestSecret_TokenRemainingUses(t *testing.T) {
t.Fatal(err)
}
secret, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/login/test", map[string]interface{}{
secret, err := client.Logical().Write("auth/userpass/login/test", map[string]interface{}{
"password": "test",
})
if err != nil || secret == nil {
@ -708,7 +707,7 @@ func TestSecret_TokenRemainingUses(t *testing.T) {
uses := 5
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
NumUses: uses,
})
@ -735,7 +734,7 @@ func TestSecret_TokenRemainingUses(t *testing.T) {
uses := 5
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
NumUses: uses,
})
@ -744,7 +743,7 @@ func TestSecret_TokenRemainingUses(t *testing.T) {
}
token := secret.Auth.ClientToken
secret, err = client.Auth().Token().LookupWithContext(context.Background(), token)
secret, err = client.Auth().Token().Lookup(token)
if err != nil {
t.Fatal(err)
}
@ -766,7 +765,7 @@ func TestSecret_TokenRemainingUses(t *testing.T) {
uses := 5
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
NumUses: uses,
})
@ -776,7 +775,7 @@ func TestSecret_TokenRemainingUses(t *testing.T) {
token := secret.Auth.ClientToken
client.SetToken(token)
secret, err = client.Auth().Token().LookupSelfWithContext(context.Background())
secret, err = client.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
@ -799,7 +798,7 @@ func TestSecret_TokenRemainingUses(t *testing.T) {
uses := 5
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
NumUses: uses,
})
@ -808,7 +807,7 @@ func TestSecret_TokenRemainingUses(t *testing.T) {
}
token := secret.Auth.ClientToken
secret, err = client.Auth().Token().RenewWithContext(context.Background(), token, 0)
secret, err = client.Auth().Token().Renew(token, 0)
if err != nil {
t.Fatal(err)
}
@ -832,7 +831,7 @@ func TestSecret_TokenRemainingUses(t *testing.T) {
uses := 5
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
NumUses: uses,
})
@ -842,7 +841,7 @@ func TestSecret_TokenRemainingUses(t *testing.T) {
token := secret.Auth.ClientToken
client.SetToken(token)
secret, err = client.Auth().Token().RenewSelfWithContext(context.Background(), 0)
secret, err = client.Auth().Token().RenewSelf(0)
if err != nil {
t.Fatal(err)
}
@ -977,14 +976,14 @@ func TestSecret_TokenPolicies(t *testing.T) {
if err := client.Sys().EnableAuth("userpass", "userpass", ""); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/test", map[string]interface{}{
if _, err := client.Logical().Write("auth/userpass/users/test", map[string]interface{}{
"password": "test",
"policies": strings.Join(policies, ","),
}); err != nil {
t.Fatal(err)
}
secret, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/login/test", map[string]interface{}{
secret, err := client.Logical().Write("auth/userpass/login/test", map[string]interface{}{
"password": "test",
})
if err != nil || secret == nil {
@ -1008,7 +1007,7 @@ func TestSecret_TokenPolicies(t *testing.T) {
policies := []string{"bar", "default", "foo"}
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: policies,
})
if err != nil {
@ -1032,7 +1031,7 @@ func TestSecret_TokenPolicies(t *testing.T) {
policies := []string{"bar", "default", "foo"}
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: policies,
})
if err != nil {
@ -1040,7 +1039,7 @@ func TestSecret_TokenPolicies(t *testing.T) {
}
token := secret.Auth.ClientToken
secret, err = client.Auth().Token().LookupWithContext(context.Background(), token)
secret, err = client.Auth().Token().Lookup(token)
if err != nil {
t.Fatal(err)
}
@ -1062,7 +1061,7 @@ func TestSecret_TokenPolicies(t *testing.T) {
policies := []string{"bar", "default", "foo"}
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: policies,
})
if err != nil {
@ -1071,7 +1070,7 @@ func TestSecret_TokenPolicies(t *testing.T) {
token := secret.Auth.ClientToken
client.SetToken(token)
secret, err = client.Auth().Token().LookupSelfWithContext(context.Background())
secret, err = client.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
@ -1093,7 +1092,7 @@ func TestSecret_TokenPolicies(t *testing.T) {
policies := []string{"bar", "default", "foo"}
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: policies,
})
if err != nil {
@ -1101,7 +1100,7 @@ func TestSecret_TokenPolicies(t *testing.T) {
}
token := secret.Auth.ClientToken
secret, err = client.Auth().Token().RenewWithContext(context.Background(), token, 0)
secret, err = client.Auth().Token().Renew(token, 0)
if err != nil {
t.Fatal(err)
}
@ -1123,7 +1122,7 @@ func TestSecret_TokenPolicies(t *testing.T) {
policies := []string{"bar", "default", "foo"}
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: policies,
})
if err != nil {
@ -1132,7 +1131,7 @@ func TestSecret_TokenPolicies(t *testing.T) {
token := secret.Auth.ClientToken
client.SetToken(token)
secret, err = client.Auth().Token().RenewSelfWithContext(context.Background(), 0)
secret, err = client.Auth().Token().RenewSelf(0)
if err != nil {
t.Fatal(err)
}
@ -1275,14 +1274,14 @@ func TestSecret_TokenMetadata(t *testing.T) {
if err := client.Sys().EnableAuth("userpass", "userpass", ""); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/test", map[string]interface{}{
if _, err := client.Logical().Write("auth/userpass/users/test", map[string]interface{}{
"password": "test",
"policies": "default",
}); err != nil {
t.Fatal(err)
}
secret, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/login/test", map[string]interface{}{
secret, err := client.Logical().Write("auth/userpass/login/test", map[string]interface{}{
"password": "test",
})
if err != nil || secret == nil {
@ -1306,7 +1305,7 @@ func TestSecret_TokenMetadata(t *testing.T) {
metadata := map[string]string{"username": "test"}
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Metadata: metadata,
Policies: []string{"default"},
})
@ -1331,7 +1330,7 @@ func TestSecret_TokenMetadata(t *testing.T) {
metadata := map[string]string{"username": "test"}
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Metadata: metadata,
Policies: []string{"default"},
})
@ -1340,7 +1339,7 @@ func TestSecret_TokenMetadata(t *testing.T) {
}
token := secret.Auth.ClientToken
secret, err = client.Auth().Token().LookupWithContext(context.Background(), token)
secret, err = client.Auth().Token().Lookup(token)
if err != nil {
t.Fatal(err)
}
@ -1362,7 +1361,7 @@ func TestSecret_TokenMetadata(t *testing.T) {
metadata := map[string]string{"username": "test"}
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Metadata: metadata,
Policies: []string{"default"},
})
@ -1372,7 +1371,7 @@ func TestSecret_TokenMetadata(t *testing.T) {
token := secret.Auth.ClientToken
client.SetToken(token)
secret, err = client.Auth().Token().LookupSelfWithContext(context.Background())
secret, err = client.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
@ -1394,7 +1393,7 @@ func TestSecret_TokenMetadata(t *testing.T) {
metadata := map[string]string{"username": "test"}
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Metadata: metadata,
Policies: []string{"default"},
})
@ -1403,7 +1402,7 @@ func TestSecret_TokenMetadata(t *testing.T) {
}
token := secret.Auth.ClientToken
secret, err = client.Auth().Token().RenewWithContext(context.Background(), token, 0)
secret, err = client.Auth().Token().Renew(token, 0)
if err != nil {
t.Fatal(err)
}
@ -1425,7 +1424,7 @@ func TestSecret_TokenMetadata(t *testing.T) {
metadata := map[string]string{"username": "test"}
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Metadata: metadata,
Policies: []string{"default"},
})
@ -1435,7 +1434,7 @@ func TestSecret_TokenMetadata(t *testing.T) {
token := secret.Auth.ClientToken
client.SetToken(token)
secret, err = client.Auth().Token().RenewSelfWithContext(context.Background(), 0)
secret, err = client.Auth().Token().RenewSelf(0)
if err != nil {
t.Fatal(err)
}
@ -1567,14 +1566,14 @@ func TestSecret_TokenIsRenewable(t *testing.T) {
if err := client.Sys().EnableAuth("userpass", "userpass", ""); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/test", map[string]interface{}{
if _, err := client.Logical().Write("auth/userpass/users/test", map[string]interface{}{
"password": "test",
"policies": "default",
}); err != nil {
t.Fatal(err)
}
secret, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/login/test", map[string]interface{}{
secret, err := client.Logical().Write("auth/userpass/login/test", map[string]interface{}{
"password": "test",
})
if err != nil || secret == nil {
@ -1598,7 +1597,7 @@ func TestSecret_TokenIsRenewable(t *testing.T) {
renewable := true
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
Renewable: &renewable,
})
@ -1623,7 +1622,7 @@ func TestSecret_TokenIsRenewable(t *testing.T) {
renewable := true
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
Renewable: &renewable,
})
@ -1632,7 +1631,7 @@ func TestSecret_TokenIsRenewable(t *testing.T) {
}
token := secret.Auth.ClientToken
secret, err = client.Auth().Token().LookupWithContext(context.Background(), token)
secret, err = client.Auth().Token().Lookup(token)
if err != nil {
t.Fatal(err)
}
@ -1654,7 +1653,7 @@ func TestSecret_TokenIsRenewable(t *testing.T) {
renewable := true
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
Renewable: &renewable,
})
@ -1664,7 +1663,7 @@ func TestSecret_TokenIsRenewable(t *testing.T) {
token := secret.Auth.ClientToken
client.SetToken(token)
secret, err = client.Auth().Token().LookupSelfWithContext(context.Background())
secret, err = client.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
@ -1686,7 +1685,7 @@ func TestSecret_TokenIsRenewable(t *testing.T) {
renewable := true
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
Renewable: &renewable,
})
@ -1695,7 +1694,7 @@ func TestSecret_TokenIsRenewable(t *testing.T) {
}
token := secret.Auth.ClientToken
secret, err = client.Auth().Token().RenewWithContext(context.Background(), token, 0)
secret, err = client.Auth().Token().Renew(token, 0)
if err != nil {
t.Fatal(err)
}
@ -1717,7 +1716,7 @@ func TestSecret_TokenIsRenewable(t *testing.T) {
renewable := true
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
Renewable: &renewable,
})
@ -1727,7 +1726,7 @@ func TestSecret_TokenIsRenewable(t *testing.T) {
token := secret.Auth.ClientToken
client.SetToken(token)
secret, err = client.Auth().Token().RenewSelfWithContext(context.Background(), 0)
secret, err = client.Auth().Token().RenewSelf(0)
if err != nil {
t.Fatal(err)
}
@ -1841,7 +1840,7 @@ func TestSecret_TokenTTL(t *testing.T) {
if err := client.Sys().EnableAuth("userpass", "userpass", ""); err != nil {
t.Fatal(err)
}
if _, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/test", map[string]interface{}{
if _, err := client.Logical().Write("auth/userpass/users/test", map[string]interface{}{
"password": "test",
"policies": "default",
"ttl": ttl.String(),
@ -1850,7 +1849,7 @@ func TestSecret_TokenTTL(t *testing.T) {
t.Fatal(err)
}
secret, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/login/test", map[string]interface{}{
secret, err := client.Logical().Write("auth/userpass/login/test", map[string]interface{}{
"password": "test",
})
if err != nil || secret == nil {
@ -1874,7 +1873,7 @@ func TestSecret_TokenTTL(t *testing.T) {
ttl := 30 * time.Minute
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
TTL: ttl.String(),
ExplicitMaxTTL: ttl.String(),
@ -1900,7 +1899,7 @@ func TestSecret_TokenTTL(t *testing.T) {
ttl := 30 * time.Minute
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
TTL: ttl.String(),
ExplicitMaxTTL: ttl.String(),
@ -1910,7 +1909,7 @@ func TestSecret_TokenTTL(t *testing.T) {
}
token := secret.Auth.ClientToken
secret, err = client.Auth().Token().LookupWithContext(context.Background(), token)
secret, err = client.Auth().Token().Lookup(token)
if err != nil {
t.Fatal(err)
}
@ -1932,7 +1931,7 @@ func TestSecret_TokenTTL(t *testing.T) {
ttl := 30 * time.Minute
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
TTL: ttl.String(),
ExplicitMaxTTL: ttl.String(),
@ -1943,7 +1942,7 @@ func TestSecret_TokenTTL(t *testing.T) {
token := secret.Auth.ClientToken
client.SetToken(token)
secret, err = client.Auth().Token().LookupSelfWithContext(context.Background())
secret, err = client.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
@ -1965,7 +1964,7 @@ func TestSecret_TokenTTL(t *testing.T) {
ttl := 30 * time.Minute
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
TTL: ttl.String(),
ExplicitMaxTTL: ttl.String(),
@ -1975,7 +1974,7 @@ func TestSecret_TokenTTL(t *testing.T) {
}
token := secret.Auth.ClientToken
secret, err = client.Auth().Token().RenewWithContext(context.Background(), token, 0)
secret, err = client.Auth().Token().Renew(token, 0)
if err != nil {
t.Fatal(err)
}
@ -1997,7 +1996,7 @@ func TestSecret_TokenTTL(t *testing.T) {
ttl := 30 * time.Minute
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
Policies: []string{"default"},
TTL: ttl.String(),
ExplicitMaxTTL: ttl.String(),
@ -2008,7 +2007,7 @@ func TestSecret_TokenTTL(t *testing.T) {
token := secret.Auth.ClientToken
client.SetToken(token)
secret, err = client.Auth().Token().RenewSelfWithContext(context.Background(), 0)
secret, err = client.Auth().Token().RenewSelf(0)
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package approle
import (
"context"
"testing"
log "github.com/hashicorp/go-hclog"
@ -45,7 +44,7 @@ func TestApproleSecretId_Wrapped(t *testing.T) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/approle/role/test-role-1", map[string]interface{}{
_, err = client.Logical().Write("auth/approle/role/test-role-1", map[string]interface{}{
"name": "test-role-1",
})
require.NoError(t, err)
@ -54,7 +53,7 @@ func TestApproleSecretId_Wrapped(t *testing.T) {
return "5m"
})
resp, err := client.Logical().WriteWithContext(context.Background(), "/auth/approle/role/test-role-1/secret-id", map[string]interface{}{})
resp, err := client.Logical().Write("/auth/approle/role/test-role-1/secret-id", map[string]interface{}{})
require.NoError(t, err)
wrappedAccessor := resp.WrapInfo.WrappedAccessor
@ -64,7 +63,7 @@ func TestApproleSecretId_Wrapped(t *testing.T) {
return api.DefaultWrappingLookupFunc(operation, path)
})
unwrappedSecretid, err := client.Logical().UnwrapWithContext(context.Background(), wrappingToken)
unwrappedSecretid, err := client.Logical().Unwrap(wrappingToken)
require.NoError(t, err)
unwrappedAccessor := unwrappedSecretid.Data["secret_id_accessor"].(string)
@ -105,12 +104,12 @@ func TestApproleSecretId_NotWrapped(t *testing.T) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/approle/role/test-role-1", map[string]interface{}{
_, err = client.Logical().Write("auth/approle/role/test-role-1", map[string]interface{}{
"name": "test-role-1",
})
require.NoError(t, err)
resp, err := client.Logical().WriteWithContext(context.Background(), "/auth/approle/role/test-role-1/secret-id", map[string]interface{}{})
resp, err := client.Logical().Write("/auth/approle/role/test-role-1/secret-id", map[string]interface{}{})
require.NoError(t, err)
if resp.WrapInfo != nil && resp.WrapInfo.WrappedAccessor != "" {

View File

@ -1,7 +1,6 @@
package expiration
import (
"context"
"encoding/json"
"reflect"
"testing"
@ -24,7 +23,7 @@ func TestExpiration_irrevocableLeaseCountsAPI(t *testing.T) {
params := make(map[string][]string)
params["type"] = []string{"irrevocable"}
resp, err := client.Logical().ReadWithDataWithContext(context.Background(), "sys/leases/count", params)
resp, err := client.Logical().ReadWithData("sys/leases/count", params)
if err != nil {
t.Fatal(err)
}
@ -64,7 +63,7 @@ func TestExpiration_irrevocableLeaseCountsAPI(t *testing.T) {
t.Fatal(err)
}
resp, err = client.Logical().ReadWithDataWithContext(context.Background(), "sys/leases/count", params)
resp, err = client.Logical().ReadWithData("sys/leases/count", params)
if err != nil {
t.Fatal(err)
}
@ -130,7 +129,7 @@ func TestExpiration_irrevocableLeaseListAPI(t *testing.T) {
params := make(map[string][]string)
params["type"] = []string{"irrevocable"}
resp, err := client.Logical().ReadWithDataWithContext(context.Background(), "sys/leases", params)
resp, err := client.Logical().ReadWithData("sys/leases", params)
if err != nil {
t.Fatal(err)
}
@ -171,7 +170,7 @@ func TestExpiration_irrevocableLeaseListAPI(t *testing.T) {
t.Fatal(err)
}
resp, err = client.Logical().ReadWithDataWithContext(context.Background(), "sys/leases", params)
resp, err = client.Logical().ReadWithData("sys/leases", params)
if err != nil {
t.Fatal(err)
}
@ -240,7 +239,7 @@ func TestExpiration_irrevocableLeaseListAPI_includeAll(t *testing.T) {
params := make(map[string][]string)
params["type"] = []string{"irrevocable"}
resp, err := client.Logical().ReadWithDataWithContext(context.Background(), "sys/leases", params)
resp, err := client.Logical().ReadWithData("sys/leases", params)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
@ -254,7 +253,7 @@ func TestExpiration_irrevocableLeaseListAPI_includeAll(t *testing.T) {
// now try it with the no limit on return size - we expect no errors and many results
params["limit"] = []string{"none"}
resp, err = client.Logical().ReadWithDataWithContext(context.Background(), "sys/leases", params)
resp, err = client.Logical().ReadWithData("sys/leases", params)
if err != nil {
t.Fatalf("unexpected error when using limit=none: %v", err)
}

View File

@ -1,7 +1,6 @@
package identity
import (
"context"
"testing"
"github.com/hashicorp/vault/api"
@ -35,7 +34,7 @@ func TestIdentityStore_ListAlias(t *testing.T) {
t.Fatal(err)
}
mounts, err := client.Sys().ListAuthWithContext(context.Background())
mounts, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}
@ -51,7 +50,7 @@ func TestIdentityStore_ListAlias(t *testing.T) {
t.Fatal("did not find github accessor")
}
resp, err := client.Logical().WriteWithContext(context.Background(), "identity/entity", nil)
resp, err := client.Logical().Write("identity/entity", nil)
if err != nil {
t.Fatalf("err:%v resp:%#v", err, resp)
}
@ -62,7 +61,7 @@ func TestIdentityStore_ListAlias(t *testing.T) {
entityID := resp.Data["id"].(string)
// Create an alias
resp, err = client.Logical().WriteWithContext(context.Background(), "identity/entity-alias", map[string]interface{}{
resp, err = client.Logical().Write("identity/entity-alias", map[string]interface{}{
"name": "testaliasname",
"mount_accessor": githubAccessor,
})
@ -72,7 +71,7 @@ func TestIdentityStore_ListAlias(t *testing.T) {
testAliasCanonicalID := resp.Data["canonical_id"].(string)
testAliasAliasID := resp.Data["id"].(string)
resp, err = client.Logical().WriteWithContext(context.Background(), "identity/entity-alias", map[string]interface{}{
resp, err = client.Logical().Write("identity/entity-alias", map[string]interface{}{
"name": "entityalias",
"mount_accessor": githubAccessor,
"canonical_id": entityID,
@ -82,7 +81,7 @@ func TestIdentityStore_ListAlias(t *testing.T) {
}
entityAliasAliasID := resp.Data["id"].(string)
resp, err = client.Logical().ListWithContext(context.Background(), "identity/entity-alias/id")
resp, err = client.Logical().List("identity/entity-alias/id")
if err != nil {
t.Fatalf("err:%v resp:%#v", err, resp)
}
@ -119,7 +118,7 @@ func TestIdentityStore_ListAlias(t *testing.T) {
}
// Now do the same with entity info
resp, err = client.Logical().ListWithContext(context.Background(), "identity/entity/id")
resp, err = client.Logical().List("identity/entity/id")
if err != nil {
t.Fatalf("err:%v resp:%#v", err, resp)
}
@ -194,20 +193,20 @@ func TestIdentityStore_RenameAlias_CannotMergeEntity(t *testing.T) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/bsmith", map[string]interface{}{
_, err = client.Logical().Write("auth/userpass/users/bsmith", map[string]interface{}{
"password": "training",
})
if err != nil {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/userpass/login/bsmith", map[string]interface{}{
_, err = client.Logical().Write("auth/userpass/login/bsmith", map[string]interface{}{
"password": "training",
})
if err != nil {
t.Fatal(err)
}
mounts, err := client.Sys().ListAuthWithContext(context.Background())
mounts, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}
@ -224,7 +223,7 @@ func TestIdentityStore_RenameAlias_CannotMergeEntity(t *testing.T) {
}
// Now create a new unrelated entity and alias
entityResp, err := client.Logical().WriteWithContext(context.Background(), "identity/entity", map[string]interface{}{
entityResp, err := client.Logical().Write("identity/entity", map[string]interface{}{
"name": "bob-smith",
})
if err != nil {
@ -234,7 +233,7 @@ func TestIdentityStore_RenameAlias_CannotMergeEntity(t *testing.T) {
t.Fatalf("expected a non-nil response")
}
aliasResp, err := client.Logical().WriteWithContext(context.Background(), "identity/entity-alias", map[string]interface{}{
aliasResp, err := client.Logical().Write("identity/entity-alias", map[string]interface{}{
"name": "bob",
"mount_accessor": mountAccessor,
})
@ -244,7 +243,7 @@ func TestIdentityStore_RenameAlias_CannotMergeEntity(t *testing.T) {
aliasID2 := aliasResp.Data["id"].(string)
// Rename this new alias to have the same name as the one implicitly created by our login as bsmith
_, err = client.Logical().WriteWithContext(context.Background(), "identity/entity-alias/id/"+aliasID2, map[string]interface{}{
_, err = client.Logical().Write("identity/entity-alias/id/"+aliasID2, map[string]interface{}{
"name": "bsmith",
})
if err == nil {

View File

@ -1,7 +1,6 @@
package identity
import (
"context"
"strings"
"testing"
@ -39,7 +38,7 @@ func TestIdentityStore_EntityDisabled(t *testing.T) {
}
// Tune the mount
err = client.Sys().TuneMountWithContext(context.Background(), "auth/approle", api.MountConfigInput{
err = client.Sys().TuneMount("auth/approle", api.MountConfigInput{
DefaultLeaseTTL: "5m",
MaxLeaseTTL: "5m",
})
@ -48,7 +47,7 @@ func TestIdentityStore_EntityDisabled(t *testing.T) {
}
// Create role
resp, err := client.Logical().WriteWithContext(context.Background(), "auth/approle/role/role-period", map[string]interface{}{
resp, err := client.Logical().Write("auth/approle/role/role-period", map[string]interface{}{
"period": "5m",
})
if err != nil {
@ -56,7 +55,7 @@ func TestIdentityStore_EntityDisabled(t *testing.T) {
}
// Get role_id
resp, err = client.Logical().ReadWithContext(context.Background(), "auth/approle/role/role-period/role-id")
resp, err = client.Logical().Read("auth/approle/role/role-period/role-id")
if err != nil {
t.Fatal(err)
}
@ -66,7 +65,7 @@ func TestIdentityStore_EntityDisabled(t *testing.T) {
roleID := resp.Data["role_id"]
// Get secret_id
resp, err = client.Logical().WriteWithContext(context.Background(), "auth/approle/role/role-period/secret-id", map[string]interface{}{})
resp, err = client.Logical().Write("auth/approle/role/role-period/secret-id", map[string]interface{}{})
if err != nil {
t.Fatal(err)
}
@ -76,7 +75,7 @@ func TestIdentityStore_EntityDisabled(t *testing.T) {
secretID := resp.Data["secret_id"]
// Login
resp, err = client.Logical().WriteWithContext(context.Background(), "auth/approle/login", map[string]interface{}{
resp, err = client.Logical().Write("auth/approle/login", map[string]interface{}{
"role_id": roleID,
"secret_id": secretID,
})
@ -96,7 +95,7 @@ func TestIdentityStore_EntityDisabled(t *testing.T) {
roleToken := resp.Auth.ClientToken
client.SetToken(roleToken)
resp, err = client.Auth().Token().LookupSelfWithContext(context.Background())
resp, err = client.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
@ -113,7 +112,7 @@ func TestIdentityStore_EntityDisabled(t *testing.T) {
}
client.SetToken(cluster.RootToken)
resp, err = client.Logical().WriteWithContext(context.Background(), "identity/entity/id/"+entityID, map[string]interface{}{
resp, err = client.Logical().Write("identity/entity/id/"+entityID, map[string]interface{}{
"disabled": true,
})
if err != nil {
@ -122,7 +121,7 @@ func TestIdentityStore_EntityDisabled(t *testing.T) {
// This call should now fail
client.SetToken(roleToken)
resp, err = client.Auth().Token().LookupSelfWithContext(context.Background())
resp, err = client.Auth().Token().LookupSelf()
if err == nil {
t.Fatalf("expected error, got %#v", *resp)
}
@ -132,7 +131,7 @@ func TestIdentityStore_EntityDisabled(t *testing.T) {
// Attempting to get a new token should also now fail
client.SetToken("")
resp, err = client.Logical().WriteWithContext(context.Background(), "auth/approle/login", map[string]interface{}{
resp, err = client.Logical().Write("auth/approle/login", map[string]interface{}{
"role_id": roleID,
"secret_id": secretID,
})
@ -144,7 +143,7 @@ func TestIdentityStore_EntityDisabled(t *testing.T) {
}
client.SetToken(cluster.RootToken)
resp, err = client.Logical().WriteWithContext(context.Background(), "identity/entity/id/"+entityID, map[string]interface{}{
resp, err = client.Logical().Write("identity/entity/id/"+entityID, map[string]interface{}{
"disabled": false,
})
if err != nil {
@ -152,14 +151,14 @@ func TestIdentityStore_EntityDisabled(t *testing.T) {
}
client.SetToken(roleToken)
resp, err = client.Auth().Token().LookupSelfWithContext(context.Background())
resp, err = client.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
// Getting a new token should now work again too
client.SetToken("")
resp, err = client.Logical().WriteWithContext(context.Background(), "auth/approle/login", map[string]interface{}{
resp, err = client.Logical().Write("auth/approle/login", map[string]interface{}{
"role_id": roleID,
"secret_id": secretID,
})
@ -203,7 +202,7 @@ func TestIdentityStore_EntityPoliciesInInitialAuth(t *testing.T) {
}
// Tune the mount
err = client.Sys().TuneMountWithContext(context.Background(), "auth/approle", api.MountConfigInput{
err = client.Sys().TuneMount("auth/approle", api.MountConfigInput{
DefaultLeaseTTL: "5m",
MaxLeaseTTL: "5m",
})
@ -212,7 +211,7 @@ func TestIdentityStore_EntityPoliciesInInitialAuth(t *testing.T) {
}
// Create role
resp, err := client.Logical().WriteWithContext(context.Background(), "auth/approle/role/role-period", map[string]interface{}{
resp, err := client.Logical().Write("auth/approle/role/role-period", map[string]interface{}{
"period": "5m",
})
if err != nil {
@ -220,7 +219,7 @@ func TestIdentityStore_EntityPoliciesInInitialAuth(t *testing.T) {
}
// Get role_id
resp, err = client.Logical().ReadWithContext(context.Background(), "auth/approle/role/role-period/role-id")
resp, err = client.Logical().Read("auth/approle/role/role-period/role-id")
if err != nil {
t.Fatal(err)
}
@ -230,7 +229,7 @@ func TestIdentityStore_EntityPoliciesInInitialAuth(t *testing.T) {
roleID := resp.Data["role_id"]
// Get secret_id
resp, err = client.Logical().WriteWithContext(context.Background(), "auth/approle/role/role-period/secret-id", map[string]interface{}{})
resp, err = client.Logical().Write("auth/approle/role/role-period/secret-id", map[string]interface{}{})
if err != nil {
t.Fatal(err)
}
@ -240,7 +239,7 @@ func TestIdentityStore_EntityPoliciesInInitialAuth(t *testing.T) {
secretID := resp.Data["secret_id"]
// Login
resp, err = client.Logical().WriteWithContext(context.Background(), "auth/approle/login", map[string]interface{}{
resp, err = client.Logical().Write("auth/approle/login", map[string]interface{}{
"role_id": roleID,
"secret_id": secretID,
})
@ -268,7 +267,7 @@ func TestIdentityStore_EntityPoliciesInInitialAuth(t *testing.T) {
// Check policies
client.SetToken(resp.Auth.ClientToken)
resp, err = client.Auth().Token().LookupSelfWithContext(context.Background())
resp, err = client.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}
@ -301,7 +300,7 @@ func TestIdentityStore_EntityPoliciesInInitialAuth(t *testing.T) {
// Write more policies into the entity
client.SetToken(cluster.RootToken)
resp, err = client.Logical().WriteWithContext(context.Background(), "identity/entity/id/"+entityID, map[string]interface{}{
resp, err = client.Logical().Write("identity/entity/id/"+entityID, map[string]interface{}{
"policies": []string{"foo", "bar"},
})
if err != nil {
@ -310,7 +309,7 @@ func TestIdentityStore_EntityPoliciesInInitialAuth(t *testing.T) {
// Reauthenticate to get a token with updated policies
client.SetToken("")
resp, err = client.Logical().WriteWithContext(context.Background(), "auth/approle/login", map[string]interface{}{
resp, err = client.Logical().Write("auth/approle/login", map[string]interface{}{
"role_id": roleID,
"secret_id": secretID,
})
@ -339,7 +338,7 @@ func TestIdentityStore_EntityPoliciesInInitialAuth(t *testing.T) {
// Validate the policies on lookup again -- this ensures that the right
// policies were encoded on the token but all were looked up successfully
client.SetToken(resp.Auth.ClientToken)
resp, err = client.Auth().Token().LookupSelfWithContext(context.Background())
resp, err = client.Auth().Token().LookupSelf()
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package identity
import (
"context"
"testing"
"github.com/hashicorp/vault/api"
@ -38,14 +37,14 @@ func TestIdentityStore_GroupAliasLocalMount(t *testing.T) {
}
// Extract out the mount accessor for LDAP auth
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}
ldapMountAccessor := auths["ldap/"].Accessor
// Create an external group
secret, err := client.Logical().WriteWithContext(context.Background(), "identity/group", map[string]interface{}{
secret, err := client.Logical().Write("identity/group", map[string]interface{}{
"type": "external",
})
if err != nil {
@ -54,7 +53,7 @@ func TestIdentityStore_GroupAliasLocalMount(t *testing.T) {
groupID := secret.Data["id"].(string)
// Attempt to create a group alias against a local mount should fail
secret, err = client.Logical().WriteWithContext(context.Background(), "identity/group-alias", map[string]interface{}{
secret, err = client.Logical().Write("identity/group-alias", map[string]interface{}{
"name": "testuser",
"mount_accessor": ldapMountAccessor,
"canonical_id": groupID,

View File

@ -1,7 +1,6 @@
package identity
import (
"context"
"testing"
"github.com/hashicorp/vault/api"
@ -37,7 +36,7 @@ func TestIdentityStore_ListGroupAlias(t *testing.T) {
t.Fatal(err)
}
mounts, err := client.Sys().ListAuthWithContext(context.Background())
mounts, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}
@ -53,7 +52,7 @@ func TestIdentityStore_ListGroupAlias(t *testing.T) {
t.Fatal("did not find github accessor")
}
resp, err := client.Logical().WriteWithContext(context.Background(), "identity/group", map[string]interface{}{
resp, err := client.Logical().Write("identity/group", map[string]interface{}{
"type": "external",
})
if err != nil {
@ -62,7 +61,7 @@ func TestIdentityStore_ListGroupAlias(t *testing.T) {
groupID := resp.Data["id"].(string)
resp, err = client.Logical().WriteWithContext(context.Background(), "identity/group-alias", map[string]interface{}{
resp, err = client.Logical().Write("identity/group-alias", map[string]interface{}{
"name": "groupalias",
"mount_accessor": githubAccessor,
"canonical_id": groupID,
@ -72,7 +71,7 @@ func TestIdentityStore_ListGroupAlias(t *testing.T) {
}
aliasID := resp.Data["id"].(string)
resp, err = client.Logical().ListWithContext(context.Background(), "identity/group-alias/id")
resp, err = client.Logical().List("identity/group-alias/id")
if err != nil {
t.Fatalf("err:%v resp:%#v", err, resp)
}
@ -106,7 +105,7 @@ func TestIdentityStore_ListGroupAlias(t *testing.T) {
}
// Now do the same with group info
resp, err = client.Logical().ListWithContext(context.Background(), "identity/group/id")
resp, err = client.Logical().List("identity/group/id")
if err != nil {
t.Fatalf("err:%v resp:%#v", err, resp)
}
@ -174,7 +173,7 @@ func TestIdentityStore_ExternalGroupMembershipsAcrossMounts(t *testing.T) {
}
// Extract out the mount accessor for LDAP auth
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}
@ -184,7 +183,7 @@ func TestIdentityStore_ExternalGroupMembershipsAcrossMounts(t *testing.T) {
defer cleanup()
// Configure LDAP auth
secret, err := client.Logical().WriteWithContext(context.Background(), "auth/ldap/config", map[string]interface{}{
secret, err := client.Logical().Write("auth/ldap/config", map[string]interface{}{
"url": cfg.Url,
"userattr": cfg.UserAttr,
"userdn": cfg.UserDN,
@ -198,7 +197,7 @@ func TestIdentityStore_ExternalGroupMembershipsAcrossMounts(t *testing.T) {
}
// Create a group in LDAP auth
_, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap/groups/testgroup1", map[string]interface{}{
_, err = client.Logical().Write("auth/ldap/groups/testgroup1", map[string]interface{}{
"policies": "testgroup1-policy",
})
if err != nil {
@ -206,7 +205,7 @@ func TestIdentityStore_ExternalGroupMembershipsAcrossMounts(t *testing.T) {
}
// Tie the group to a user
_, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap/users/hermes conrad", map[string]interface{}{
_, err = client.Logical().Write("auth/ldap/users/hermes conrad", map[string]interface{}{
"policies": "default",
"groups": "testgroup1",
})
@ -215,7 +214,7 @@ func TestIdentityStore_ExternalGroupMembershipsAcrossMounts(t *testing.T) {
}
// Create an external group
secret, err = client.Logical().WriteWithContext(context.Background(), "identity/group", map[string]interface{}{
secret, err = client.Logical().Write("identity/group", map[string]interface{}{
"type": "external",
})
if err != nil {
@ -224,7 +223,7 @@ func TestIdentityStore_ExternalGroupMembershipsAcrossMounts(t *testing.T) {
ldapExtGroupID1 := secret.Data["id"].(string)
// Associate a group from LDAP auth as a group-alias in the external group
_, err = client.Logical().WriteWithContext(context.Background(), "identity/group-alias", map[string]interface{}{
_, err = client.Logical().Write("identity/group-alias", map[string]interface{}{
"name": "testgroup1",
"mount_accessor": ldapMountAccessor1,
"canonical_id": ldapExtGroupID1,
@ -234,7 +233,7 @@ func TestIdentityStore_ExternalGroupMembershipsAcrossMounts(t *testing.T) {
}
// Login using LDAP
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap/login/hermes conrad", map[string]interface{}{
secret, err = client.Logical().Write("auth/ldap/login/hermes conrad", map[string]interface{}{
"password": "hermes",
})
if err != nil {
@ -248,7 +247,7 @@ func TestIdentityStore_ExternalGroupMembershipsAcrossMounts(t *testing.T) {
//
// Extract the entity ID of the token
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/token/lookup", map[string]interface{}{
secret, err = client.Logical().Write("auth/token/lookup", map[string]interface{}{
"token": ldapClientToken,
})
if err != nil {
@ -265,7 +264,7 @@ func TestIdentityStore_ExternalGroupMembershipsAcrossMounts(t *testing.T) {
}
// Extract the mount accessor
auths, err = client.Sys().ListAuthWithContext(context.Background())
auths, err = client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}
@ -273,7 +272,7 @@ func TestIdentityStore_ExternalGroupMembershipsAcrossMounts(t *testing.T) {
// Create an entity-alias asserting that the user "hermes conrad" from the first
// and second LDAP mounts as the same.
_, err = client.Logical().WriteWithContext(context.Background(), "identity/entity-alias", map[string]interface{}{
_, err = client.Logical().Write("identity/entity-alias", map[string]interface{}{
"name": "hermes conrad",
"mount_accessor": ldapMountAccessor2,
"canonical_id": entityID,
@ -286,7 +285,7 @@ func TestIdentityStore_ExternalGroupMembershipsAcrossMounts(t *testing.T) {
defer cleanup2()
// Configure LDAP auth
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap2/config", map[string]interface{}{
secret, err = client.Logical().Write("auth/ldap2/config", map[string]interface{}{
"url": cfg2.Url,
"userattr": cfg2.UserAttr,
"userdn": cfg2.UserDN,
@ -300,7 +299,7 @@ func TestIdentityStore_ExternalGroupMembershipsAcrossMounts(t *testing.T) {
}
// Create a group in second LDAP auth
_, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap2/groups/testgroup2", map[string]interface{}{
_, err = client.Logical().Write("auth/ldap2/groups/testgroup2", map[string]interface{}{
"policies": "testgroup2-policy",
})
if err != nil {
@ -308,7 +307,7 @@ func TestIdentityStore_ExternalGroupMembershipsAcrossMounts(t *testing.T) {
}
// Create a user in second LDAP auth
_, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap2/users/hermes conrad", map[string]interface{}{
_, err = client.Logical().Write("auth/ldap2/users/hermes conrad", map[string]interface{}{
"policies": "default",
"groups": "testgroup2",
})
@ -317,7 +316,7 @@ func TestIdentityStore_ExternalGroupMembershipsAcrossMounts(t *testing.T) {
}
// Create another external group
secret, err = client.Logical().WriteWithContext(context.Background(), "identity/group", map[string]interface{}{
secret, err = client.Logical().Write("identity/group", map[string]interface{}{
"type": "external",
})
if err != nil {
@ -326,7 +325,7 @@ func TestIdentityStore_ExternalGroupMembershipsAcrossMounts(t *testing.T) {
ldapExtGroupID2 := secret.Data["id"].(string)
// Create a group-alias tying the external group to "testgroup2" group in second LDAP
_, err = client.Logical().WriteWithContext(context.Background(), "identity/group-alias", map[string]interface{}{
_, err = client.Logical().Write("identity/group-alias", map[string]interface{}{
"name": "testgroup2",
"mount_accessor": ldapMountAccessor2,
"canonical_id": ldapExtGroupID2,
@ -336,7 +335,7 @@ func TestIdentityStore_ExternalGroupMembershipsAcrossMounts(t *testing.T) {
}
// Login using second LDAP
_, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap2/login/hermes conrad", map[string]interface{}{
_, err = client.Logical().Write("auth/ldap2/login/hermes conrad", map[string]interface{}{
"password": "hermes",
})
if err != nil {
@ -349,7 +348,7 @@ func TestIdentityStore_ExternalGroupMembershipsAcrossMounts(t *testing.T) {
//
// Check that entityID is present in both the external groups
secret, err = client.Logical().ReadWithContext(context.Background(), "identity/group/id/"+ldapExtGroupID1)
secret, err = client.Logical().Read("identity/group/id/" + ldapExtGroupID1)
if err != nil {
t.Fatal(err)
}
@ -366,7 +365,7 @@ func TestIdentityStore_ExternalGroupMembershipsAcrossMounts(t *testing.T) {
t.Fatalf("missing entity ID %q first external group with ID %q", entityID, ldapExtGroupID1)
}
secret, err = client.Logical().ReadWithContext(context.Background(), "identity/group/id/"+ldapExtGroupID2)
secret, err = client.Logical().Read("identity/group/id/" + ldapExtGroupID2)
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package identity
import (
"context"
"fmt"
"testing"
@ -39,7 +38,7 @@ func TestIdentityStore_ExternalGroupMemberships_DifferentMounts(t *testing.T) {
vault.TestWaitActive(t, core)
// Create a entity
secret, err := client.Logical().WriteWithContext(context.Background(), "identity/entity", map[string]interface{}{
secret, err := client.Logical().Write("identity/entity", map[string]interface{}{
"name": "testentityname",
})
require.NoError(t, err)
@ -53,7 +52,7 @@ func TestIdentityStore_ExternalGroupMemberships_DifferentMounts(t *testing.T) {
setupFunc := func(path string, cfg *ldaputil.ConfigEntry) string {
// Create an external group
resp, err := client.Logical().WriteWithContext(context.Background(), "identity/group", map[string]interface{}{
resp, err := client.Logical().Write("identity/group", map[string]interface{}{
"type": "external",
"name": path + "ldap_admin_staff",
"policies": []string{"admin-policy"},
@ -70,13 +69,13 @@ func TestIdentityStore_ExternalGroupMemberships_DifferentMounts(t *testing.T) {
require.NoError(t, err)
// Take out its accessor
auth, err := client.Sys().ListAuthWithContext(context.Background())
auth, err := client.Sys().ListAuth()
require.NoError(t, err)
accessor := auth[path+"/"].Accessor
require.NotEmpty(t, accessor)
// Create an external group alias
resp, err = client.Logical().WriteWithContext(context.Background(), "identity/group-alias", map[string]interface{}{
resp, err = client.Logical().Write("identity/group-alias", map[string]interface{}{
"name": "admin_staff",
"canonical_id": groupID,
"mount_accessor": accessor,
@ -84,20 +83,20 @@ func TestIdentityStore_ExternalGroupMemberships_DifferentMounts(t *testing.T) {
require.NoError(t, err)
// Create a user in Vault
_, err = client.Logical().WriteWithContext(context.Background(), "auth/"+path+"/users/hermes conrad", map[string]interface{}{
_, err = client.Logical().Write("auth/"+path+"/users/hermes conrad", map[string]interface{}{
"password": "hermes",
})
require.NoError(t, err)
// Create an entity alias
client.Logical().WriteWithContext(context.Background(), "identity/entity-alias", map[string]interface{}{
client.Logical().Write("identity/entity-alias", map[string]interface{}{
"name": "hermes conrad",
"canonical_id": entityID,
"mount_accessor": accessor,
})
// Configure LDAP auth
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/"+path+"/config", map[string]interface{}{
secret, err = client.Logical().Write("auth/"+path+"/config", map[string]interface{}{
"url": cfg.Url,
"userattr": cfg.UserAttr,
"userdn": cfg.UserDN,
@ -108,7 +107,7 @@ func TestIdentityStore_ExternalGroupMemberships_DifferentMounts(t *testing.T) {
})
require.NoError(t, err)
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/"+path+"/login/hermes conrad", map[string]interface{}{
secret, err = client.Logical().Write("auth/"+path+"/login/hermes conrad", map[string]interface{}{
"password": "hermes",
})
require.NoError(t, err)
@ -117,7 +116,7 @@ func TestIdentityStore_ExternalGroupMemberships_DifferentMounts(t *testing.T) {
require.NoError(t, err)
require.Contains(t, policies, "admin-policy")
secret, err = client.Logical().ReadWithContext(context.Background(), "identity/group/id/"+groupID)
secret, err = client.Logical().Read("identity/group/id/" + groupID)
require.NoError(t, err)
require.Contains(t, secret.Data["member_entity_ids"], entityID)
@ -128,16 +127,16 @@ func TestIdentityStore_ExternalGroupMemberships_DifferentMounts(t *testing.T) {
// Remove hermes conrad from admin_staff group
removeLdapGroupMember(t, config1, "admin_staff", "hermes conrad")
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap/login/hermes conrad", map[string]interface{}{
secret, err = client.Logical().Write("auth/ldap/login/hermes conrad", map[string]interface{}{
"password": "hermes",
})
require.NoError(t, err)
secret, err = client.Logical().ReadWithContext(context.Background(), "identity/group/id/"+groupID1)
secret, err = client.Logical().Read("identity/group/id/" + groupID1)
require.NoError(t, err)
require.NotContains(t, secret.Data["member_entity_ids"], entityID)
secret, err = client.Logical().ReadWithContext(context.Background(), "identity/group/id/"+groupID2)
secret, err = client.Logical().Read("identity/group/id/" + groupID2)
require.NoError(t, err)
require.Contains(t, secret.Data["member_entity_ids"], entityID)
}
@ -175,14 +174,14 @@ func TestIdentityStore_Integ_GroupAliases(t *testing.T) {
t.Fatal(err)
}
auth, err := client.Sys().ListAuthWithContext(context.Background())
auth, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}
accessor := auth["ldap/"].Accessor
secret, err := client.Logical().WriteWithContext(context.Background(), "identity/group", map[string]interface{}{
secret, err := client.Logical().Write("identity/group", map[string]interface{}{
"type": "external",
"name": "ldap_ship_crew",
})
@ -191,7 +190,7 @@ func TestIdentityStore_Integ_GroupAliases(t *testing.T) {
}
shipCrewGroupID := secret.Data["id"].(string)
secret, err = client.Logical().WriteWithContext(context.Background(), "identity/group", map[string]interface{}{
secret, err = client.Logical().Write("identity/group", map[string]interface{}{
"type": "external",
"name": "ldap_admin_staff",
})
@ -200,7 +199,7 @@ func TestIdentityStore_Integ_GroupAliases(t *testing.T) {
}
adminStaffGroupID := secret.Data["id"].(string)
secret, err = client.Logical().WriteWithContext(context.Background(), "identity/group", map[string]interface{}{
secret, err = client.Logical().Write("identity/group", map[string]interface{}{
"type": "external",
"name": "ldap_devops",
})
@ -209,7 +208,7 @@ func TestIdentityStore_Integ_GroupAliases(t *testing.T) {
}
devopsGroupID := secret.Data["id"].(string)
secret, err = client.Logical().WriteWithContext(context.Background(), "identity/group-alias", map[string]interface{}{
secret, err = client.Logical().Write("identity/group-alias", map[string]interface{}{
"name": "ship_crew",
"canonical_id": shipCrewGroupID,
"mount_accessor": accessor,
@ -218,7 +217,7 @@ func TestIdentityStore_Integ_GroupAliases(t *testing.T) {
t.Fatal(err)
}
secret, err = client.Logical().WriteWithContext(context.Background(), "identity/group-alias", map[string]interface{}{
secret, err = client.Logical().Write("identity/group-alias", map[string]interface{}{
"name": "admin_staff",
"canonical_id": adminStaffGroupID,
"mount_accessor": accessor,
@ -227,7 +226,7 @@ func TestIdentityStore_Integ_GroupAliases(t *testing.T) {
t.Fatal(err)
}
secret, err = client.Logical().WriteWithContext(context.Background(), "identity/group-alias", map[string]interface{}{
secret, err = client.Logical().Write("identity/group-alias", map[string]interface{}{
"name": "devops",
"canonical_id": devopsGroupID,
"mount_accessor": accessor,
@ -236,7 +235,7 @@ func TestIdentityStore_Integ_GroupAliases(t *testing.T) {
t.Fatal(err)
}
secret, err = client.Logical().ReadWithContext(context.Background(), "identity/group/id/"+shipCrewGroupID)
secret, err = client.Logical().Read("identity/group/id/" + shipCrewGroupID)
if err != nil {
t.Fatal(err)
}
@ -247,7 +246,7 @@ func TestIdentityStore_Integ_GroupAliases(t *testing.T) {
t.Fatalf("bad: group alias: %#v\n", aliasMap)
}
secret, err = client.Logical().ReadWithContext(context.Background(), "identity/group/id/"+adminStaffGroupID)
secret, err = client.Logical().Read("identity/group/id/" + adminStaffGroupID)
if err != nil {
t.Fatal(err)
}
@ -262,7 +261,7 @@ func TestIdentityStore_Integ_GroupAliases(t *testing.T) {
defer cleanup()
// Configure LDAP auth
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap/config", map[string]interface{}{
secret, err = client.Logical().Write("auth/ldap/config", map[string]interface{}{
"url": cfg.Url,
"userattr": cfg.UserAttr,
"userdn": cfg.UserDN,
@ -276,7 +275,7 @@ func TestIdentityStore_Integ_GroupAliases(t *testing.T) {
}
// Create a local group in LDAP backend
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap/groups/devops", map[string]interface{}{
secret, err = client.Logical().Write("auth/ldap/groups/devops", map[string]interface{}{
"policies": "default",
})
if err != nil {
@ -284,7 +283,7 @@ func TestIdentityStore_Integ_GroupAliases(t *testing.T) {
}
// Create a local group in LDAP backend
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap/groups/engineers", map[string]interface{}{
secret, err = client.Logical().Write("auth/ldap/groups/engineers", map[string]interface{}{
"policies": "default",
})
if err != nil {
@ -292,7 +291,7 @@ func TestIdentityStore_Integ_GroupAliases(t *testing.T) {
}
// Create a local user in LDAP
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap/users/hermes conrad", map[string]interface{}{
secret, err = client.Logical().Write("auth/ldap/users/hermes conrad", map[string]interface{}{
"policies": "default",
"groups": "engineers,devops",
})
@ -301,7 +300,7 @@ func TestIdentityStore_Integ_GroupAliases(t *testing.T) {
}
// Login with LDAP and create a token
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap/login/hermes conrad", map[string]interface{}{
secret, err = client.Logical().Write("auth/ldap/login/hermes conrad", map[string]interface{}{
"password": "hermes",
})
if err != nil {
@ -310,7 +309,7 @@ func TestIdentityStore_Integ_GroupAliases(t *testing.T) {
token := secret.Auth.ClientToken
// Lookup the token to get the entity ID
secret, err = client.Auth().Token().LookupWithContext(context.Background(), token)
secret, err = client.Auth().Token().Lookup(token)
if err != nil {
t.Fatal(err)
}
@ -327,7 +326,7 @@ func TestIdentityStore_Integ_GroupAliases(t *testing.T) {
addLdapGroupMember(t, cfg, "ship_crew", "hermes conrad")
// Re-login with LDAP
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap/login/hermes conrad", map[string]interface{}{
secret, err = client.Logical().Write("auth/ldap/login/hermes conrad", map[string]interface{}{
"password": "hermes",
})
if err != nil {
@ -407,7 +406,7 @@ func TestIdentityStore_Integ_GroupAliases(t *testing.T) {
t.Fatalf("failed to remove entity ID from the group")
}
_, err = client.Auth().Token().RenewWithContext(context.Background(), token, 0)
_, err = client.Auth().Token().Renew(token, 0)
if err != nil {
t.Fatal(err)
}
@ -418,7 +417,7 @@ func TestIdentityStore_Integ_GroupAliases(t *testing.T) {
assertMember(t, client, entityID, "engineer", devopsGroupID, true)
// Remove user hermes conrad from the devops group in LDAP backend
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap/users/hermes conrad", map[string]interface{}{
secret, err = client.Logical().Write("auth/ldap/users/hermes conrad", map[string]interface{}{
"policies": "default",
"groups": "engineers",
})
@ -428,7 +427,7 @@ func TestIdentityStore_Integ_GroupAliases(t *testing.T) {
// Renewing the token now should remove its entity ID from the devops
// group
_, err = client.Auth().Token().RenewWithContext(context.Background(), token, 0)
_, err = client.Auth().Token().Renew(token, 0)
if err != nil {
t.Fatal(err)
}
@ -471,7 +470,7 @@ func TestIdentityStore_Integ_RemoveFromExternalGroup(t *testing.T) {
t.Fatal(err)
}
auth, err := client.Sys().ListAuthWithContext(context.Background())
auth, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}
@ -479,7 +478,7 @@ func TestIdentityStore_Integ_RemoveFromExternalGroup(t *testing.T) {
accessor := auth["ldap/"].Accessor
adminPolicy := "admin_policy"
secret, err := client.Logical().WriteWithContext(context.Background(), "identity/group", map[string]interface{}{
secret, err := client.Logical().Write("identity/group", map[string]interface{}{
"type": "external",
"name": "ldap_admin_staff",
"policies": []string{adminPolicy},
@ -490,7 +489,7 @@ func TestIdentityStore_Integ_RemoveFromExternalGroup(t *testing.T) {
adminStaffGroupID := secret.Data["id"].(string)
adminGroupName := "admin_staff"
secret, err = client.Logical().WriteWithContext(context.Background(), "identity/group-alias", map[string]interface{}{
secret, err = client.Logical().Write("identity/group-alias", map[string]interface{}{
"name": adminGroupName,
"canonical_id": adminStaffGroupID,
"mount_accessor": accessor,
@ -499,7 +498,7 @@ func TestIdentityStore_Integ_RemoveFromExternalGroup(t *testing.T) {
t.Fatal(err)
}
secret, err = client.Logical().ReadWithContext(context.Background(), "identity/group/id/"+adminStaffGroupID)
secret, err = client.Logical().Read("identity/group/id/" + adminStaffGroupID)
if err != nil {
t.Fatal(err)
}
@ -514,7 +513,7 @@ func TestIdentityStore_Integ_RemoveFromExternalGroup(t *testing.T) {
defer cleanup()
// Configure LDAP auth
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap/config", map[string]interface{}{
secret, err = client.Logical().Write("auth/ldap/config", map[string]interface{}{
"url": cfg.Url,
"userattr": cfg.UserAttr,
"userdn": cfg.UserDN,
@ -528,7 +527,7 @@ func TestIdentityStore_Integ_RemoveFromExternalGroup(t *testing.T) {
}
// Create a local user in LDAP
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap/users/hermes conrad", map[string]interface{}{
secret, err = client.Logical().Write("auth/ldap/users/hermes conrad", map[string]interface{}{
"policies": "default",
})
if err != nil {
@ -536,7 +535,7 @@ func TestIdentityStore_Integ_RemoveFromExternalGroup(t *testing.T) {
}
// Login with LDAP and create a token
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap/login/hermes conrad", map[string]interface{}{
secret, err = client.Logical().Write("auth/ldap/login/hermes conrad", map[string]interface{}{
"password": "hermes",
})
if err != nil {
@ -552,7 +551,7 @@ func TestIdentityStore_Integ_RemoveFromExternalGroup(t *testing.T) {
}
// Lookup the token to get the entity ID
secret, err = client.Auth().Token().LookupWithContext(context.Background(), token)
secret, err = client.Auth().Token().Lookup(token)
if err != nil {
t.Fatal(err)
}
@ -564,7 +563,7 @@ func TestIdentityStore_Integ_RemoveFromExternalGroup(t *testing.T) {
removeLdapGroupMember(t, cfg, adminGroupName, "hermes conrad")
// Re-login with LDAP
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap/login/hermes conrad", map[string]interface{}{
secret, err = client.Logical().Write("auth/ldap/login/hermes conrad", map[string]interface{}{
"password": "hermes",
})
if err != nil {
@ -585,7 +584,7 @@ func TestIdentityStore_Integ_RemoveFromExternalGroup(t *testing.T) {
addLdapGroupMember(t, cfg, adminGroupName, "hermes conrad")
// Re-login with LDAP
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap/login/hermes conrad", map[string]interface{}{
secret, err = client.Logical().Write("auth/ldap/login/hermes conrad", map[string]interface{}{
"password": "hermes",
})
if err != nil {
@ -607,7 +606,7 @@ func TestIdentityStore_Integ_RemoveFromExternalGroup(t *testing.T) {
oldToken := client.Token()
client.SetToken(secret.Auth.ClientToken)
secret, err = client.Auth().Token().RenewSelfWithContext(context.Background(), 1)
secret, err = client.Auth().Token().RenewSelf(1)
if err != nil {
t.Fatal(err)
}
@ -624,7 +623,7 @@ func TestIdentityStore_Integ_RemoveFromExternalGroup(t *testing.T) {
func assertMember(t *testing.T, client *api.Client, entityID, groupName, groupID string, expectFound bool) {
t.Helper()
secret, err := client.Logical().ReadWithContext(context.Background(), "identity/group/id/"+groupID)
secret, err := client.Logical().Read("identity/group/id/" + groupID)
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package identity
import (
"context"
"fmt"
"net/http"
"reflect"
@ -60,18 +59,18 @@ path "secret/foo" {
}
`
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
return fmt.Errorf("failed to list auth mount")
}
mountAccessor := auths["userpass/"].Accessor
err = client.Sys().PutPolicyWithContext(context.Background(), "mfa_policy", rules)
err = client.Sys().PutPolicy("mfa_policy", rules)
if err != nil {
return fmt.Errorf("failed to create mfa_policy: %v", err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/vaultmfa", map[string]interface{}{
_, err = client.Logical().Write("auth/userpass/users/vaultmfa", map[string]interface{}{
"password": "testpassword",
"policies": "mfa_policy",
})
@ -79,7 +78,7 @@ path "secret/foo" {
return fmt.Errorf("failed to configure userpass backend: %v", err)
}
secret, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/login/vaultmfa", map[string]interface{}{
secret, err := client.Logical().Write("auth/userpass/login/vaultmfa", map[string]interface{}{
"password": "testpassword",
})
if err != nil {
@ -88,7 +87,7 @@ path "secret/foo" {
userpassToken := secret.Auth.ClientToken
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/token/lookup", map[string]interface{}{
secret, err = client.Logical().Write("auth/token/lookup", map[string]interface{}{
"token": userpassToken,
})
if err != nil {
@ -103,7 +102,7 @@ path "secret/foo" {
"integration_key": integration_key,
"api_hostname": api_hostname,
}
_, err = client.Logical().WriteWithContext(context.Background(), "sys/mfa/method/duo/my_duo", mfaConfigData)
_, err = client.Logical().Write("sys/mfa/method/duo/my_duo", mfaConfigData)
if err != nil {
return fmt.Errorf("failed to persist TOTP MFA configuration: %v", err)
}
@ -112,7 +111,7 @@ path "secret/foo" {
genericData := map[string]interface{}{
"somedata": "which can only be read if MFA succeeds",
}
_, err = client.Logical().WriteWithContext(context.Background(), "secret/foo", genericData)
_, err = client.Logical().Write("secret/foo", genericData)
if err != nil {
return fmt.Errorf("failed to store data in generic backend: %v", err)
}
@ -180,19 +179,19 @@ func TestInteg_LoginMFADUO(t *testing.T) {
func mfaGenerateLoginDUOTest(client *api.Client) error {
var err error
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
return fmt.Errorf("failed to list auth mount")
}
mountAccessor := auths["userpass/"].Accessor
_, err = client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/vaultmfa", map[string]interface{}{
_, err = client.Logical().Write("auth/userpass/users/vaultmfa", map[string]interface{}{
"password": "testpassword",
})
if err != nil {
return fmt.Errorf("failed to configure userpass backend: %v", err)
}
secret, err := client.Logical().WriteWithContext(context.Background(), "identity/entity", map[string]interface{}{
secret, err := client.Logical().Write("identity/entity", map[string]interface{}{
"name": "test",
})
if err != nil {
@ -200,7 +199,7 @@ func mfaGenerateLoginDUOTest(client *api.Client) error {
}
entityID := secret.Data["id"].(string)
_, err = client.Logical().WriteWithContext(context.Background(), "identity/entity-alias", map[string]interface{}{
_, err = client.Logical().Write("identity/entity-alias", map[string]interface{}{
"name": "vaultmfa",
"canonical_id": entityID,
"mount_accessor": mountAccessor,
@ -219,7 +218,7 @@ func mfaGenerateLoginDUOTest(client *api.Client) error {
"integration_key": integration_key,
"api_hostname": api_hostname,
}
resp, err := client.Logical().WriteWithContext(context.Background(), "identity/mfa/method/duo", mfaConfigData)
resp, err := client.Logical().Write("identity/mfa/method/duo", mfaConfigData)
if err != nil || (resp == nil) {
return fmt.Errorf("bad: resp: %#v\n err: %v", resp, err)
@ -231,7 +230,7 @@ func mfaGenerateLoginDUOTest(client *api.Client) error {
}
// creating MFAEnforcementConfig
_, err = client.Logical().WriteWithContext(context.Background(), "identity/mfa/login-enforcement/randomName", map[string]interface{}{
_, err = client.Logical().Write("identity/mfa/login-enforcement/randomName", map[string]interface{}{
"auth_method_accessors": []string{mountAccessor},
"auth_method_types": []string{"userpass"},
"identity_entity_ids": []string{entityID},
@ -243,7 +242,7 @@ func mfaGenerateLoginDUOTest(client *api.Client) error {
}
}
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/userpass/login/vaultmfa", map[string]interface{}{
secret, err = client.Logical().Write("auth/userpass/login/vaultmfa", map[string]interface{}{
"password": "testpassword",
})
if err != nil {
@ -273,7 +272,7 @@ func mfaGenerateLoginDUOTest(client *api.Client) error {
}
// validation
secret, err = client.Logical().WriteWithContext(context.Background(), "sys/mfa/validate", map[string]interface{}{
secret, err = client.Logical().Write("sys/mfa/validate", map[string]interface{}{
"mfa_request_id": secret.Auth.MFARequirement.MFARequestID,
"mfa_payload": map[string][]string{
methodID: {},

View File

@ -1,7 +1,6 @@
package identity
import (
"context"
"fmt"
"reflect"
"testing"
@ -44,7 +43,7 @@ func TestOktaEngineMFA(t *testing.T) {
t.Fatalf("failed to enable okta auth: %v", err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/okta/config", map[string]interface{}{
_, err = client.Logical().Write("auth/okta/config", map[string]interface{}{
"base_url": "okta.com",
"org_name": org_name,
"api_token": api_token,
@ -53,14 +52,14 @@ func TestOktaEngineMFA(t *testing.T) {
t.Fatalf("error configuring okta mount: %v", err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/okta/groups/testgroup", map[string]interface{}{
_, err = client.Logical().Write("auth/okta/groups/testgroup", map[string]interface{}{
"policies": "default",
})
if err != nil {
t.Fatalf("error configuring okta group, %v", err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/okta/login/<okta username>", map[string]interface{}{
_, err = client.Logical().Write("auth/okta/login/<okta username>", map[string]interface{}{
"password": "<okta password>",
})
if err != nil {
@ -102,20 +101,20 @@ path "secret/foo" {
}
`
err = client.Sys().PutPolicyWithContext(context.Background(), "mfa_policy", rules)
err = client.Sys().PutPolicy("mfa_policy", rules)
if err != nil {
return fmt.Errorf("failed to create mfa_policy: %v", err)
}
// listing auth mounts to find the mount accessor for the userpass
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
return fmt.Errorf("error listing auth mounts")
}
mountAccessor := auths["userpass/"].Accessor
// creating a user in userpass
_, err = client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/testuser", map[string]interface{}{
_, err = client.Logical().Write("auth/userpass/users/testuser", map[string]interface{}{
"password": "testpassword",
})
if err != nil {
@ -123,7 +122,7 @@ path "secret/foo" {
}
// creating an identity with email metadata to be used for MFA validation
secret, err := client.Logical().WriteWithContext(context.Background(), "identity/entity", map[string]interface{}{
secret, err := client.Logical().Write("identity/entity", map[string]interface{}{
"name": "test-entity",
"policies": "mfa_policy",
"metadata": map[string]string{
@ -136,7 +135,7 @@ path "secret/foo" {
entityID := secret.Data["id"].(string)
// assigning the entity ID to the testuser alias
_, err = client.Logical().WriteWithContext(context.Background(), "identity/entity-alias", map[string]interface{}{
_, err = client.Logical().Write("identity/entity-alias", map[string]interface{}{
"name": "testuser",
"canonical_id": entityID,
"mount_accessor": mountAccessor,
@ -152,7 +151,7 @@ path "secret/foo" {
"primary_email": true,
"username_format": "{{entity.metadata.email}}",
}
_, err = client.Logical().WriteWithContext(context.Background(), "sys/mfa/method/okta/my_okta", mfaConfigData)
_, err = client.Logical().Write("sys/mfa/method/okta/my_okta", mfaConfigData)
if err != nil {
return fmt.Errorf("failed to persist TOTP MFA configuration: %v", err)
}
@ -161,7 +160,7 @@ path "secret/foo" {
genericData := map[string]interface{}{
"somedata": "which can only be read if MFA succeeds",
}
_, err = client.Logical().WriteWithContext(context.Background(), "secret/foo", genericData)
_, err = client.Logical().Write("secret/foo", genericData)
if err != nil {
return fmt.Errorf("failed to store data in generic backend: %v", err)
}
@ -172,7 +171,7 @@ path "secret/foo" {
defer client.SetToken(originalToken)
// login to the testuser
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/userpass/login/testuser", map[string]interface{}{
secret, err = client.Logical().Write("auth/userpass/login/testuser", map[string]interface{}{
"password": "testpassword",
})
if err != nil {
@ -182,7 +181,7 @@ path "secret/foo" {
userpassToken := secret.Auth.ClientToken
client.SetToken(userpassToken)
secret, err = client.Logical().ReadWithContext(context.Background(), "secret/foo")
secret, err = client.Logical().Read("secret/foo")
if err != nil {
return fmt.Errorf("failed to read the secret: %v", err)
}
@ -225,20 +224,20 @@ func TestInteg_LoginMFAOkta(t *testing.T) {
func mfaGenerateOktaLoginMFATest(client *api.Client) error {
var err error
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
return fmt.Errorf("failed to list auth mounts")
}
mountAccessor := auths["userpass/"].Accessor
_, err = client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/testuser", map[string]interface{}{
_, err = client.Logical().Write("auth/userpass/users/testuser", map[string]interface{}{
"password": "testpassword",
})
if err != nil {
return fmt.Errorf("failed to configure userpass backend: %v", err)
}
secret, err := client.Logical().WriteWithContext(context.Background(), "identity/entity", map[string]interface{}{
secret, err := client.Logical().Write("identity/entity", map[string]interface{}{
"name": "test-entity",
"metadata": map[string]string{
"email": "<okta username>",
@ -249,7 +248,7 @@ func mfaGenerateOktaLoginMFATest(client *api.Client) error {
}
entityID := secret.Data["id"].(string)
_, err = client.Logical().WriteWithContext(context.Background(), "identity/entity-alias", map[string]interface{}{
_, err = client.Logical().Write("identity/entity-alias", map[string]interface{}{
"name": "testuser",
"canonical_id": entityID,
"mount_accessor": mountAccessor,
@ -270,7 +269,7 @@ func mfaGenerateOktaLoginMFATest(client *api.Client) error {
"primary_email": true,
"username_format": "{{entity.metadata.email}}",
}
resp, err := client.Logical().WriteWithContext(context.Background(), "identity/mfa/method-id/okta", mfaConfigData)
resp, err := client.Logical().Write("identity/mfa/method-id/okta", mfaConfigData)
if err != nil || (resp == nil) {
return fmt.Errorf("bad: resp: %#v\n err: %v", resp, err)
@ -281,7 +280,7 @@ func mfaGenerateOktaLoginMFATest(client *api.Client) error {
return fmt.Errorf("method ID is empty")
}
// creating MFAEnforcementConfig
_, err = client.Logical().WriteWithContext(context.Background(), "identity/mfa/login-enforcement/randomName", map[string]interface{}{
_, err = client.Logical().Write("identity/mfa/login-enforcement/randomName", map[string]interface{}{
"auth_method_accessors": []string{mountAccessor},
"auth_method_types": []string{"userpass"},
"identity_entity_ids": []string{entityID},
@ -293,7 +292,7 @@ func mfaGenerateOktaLoginMFATest(client *api.Client) error {
}
}
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/userpass/login/testuser", map[string]interface{}{
secret, err = client.Logical().Write("auth/userpass/login/testuser", map[string]interface{}{
"password": "testpassword",
})
if err != nil {
@ -323,7 +322,7 @@ func mfaGenerateOktaLoginMFATest(client *api.Client) error {
}
// validation
secret, err = client.Logical().WriteWithContext(context.Background(), "sys/mfa/validate", map[string]interface{}{
secret, err = client.Logical().Write("sys/mfa/validate", map[string]interface{}{
"mfa_request_id": secret.Auth.MFARequirement.MFARequestID,
"mfa_payload": map[string][]string{
methodID: {},
@ -339,7 +338,7 @@ func mfaGenerateOktaLoginMFATest(client *api.Client) error {
}
client.SetToken(client.Token())
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/token/lookup", map[string]interface{}{
secret, err = client.Logical().Write("auth/token/lookup", map[string]interface{}{
"token": userpassToken,
})
if err != nil {

View File

@ -45,7 +45,7 @@ func TestLoginMfaGenerateTOTPTestAuditIncluded(t *testing.T) {
client := cluster.Cores[0].Client
// Enable the audit backend
err := client.Sys().EnableAuditWithOptionsWithContext(context.Background(), "noop", &api.EnableAuditOptions{Type: "noop"})
err := client.Sys().EnableAuditWithOptions("noop", &api.EnableAuditOptions{Type: "noop"})
if err != nil {
t.Fatal(err)
}
@ -54,7 +54,7 @@ func TestLoginMfaGenerateTOTPTestAuditIncluded(t *testing.T) {
mountInfo := &api.MountInput{
Type: "totp",
}
err = client.Sys().MountWithContext(context.Background(), "totp", mountInfo)
err = client.Sys().Mount("totp", mountInfo)
if err != nil {
t.Fatalf("failed to mount totp backend: %v", err)
}
@ -68,14 +68,14 @@ func TestLoginMfaGenerateTOTPTestAuditIncluded(t *testing.T) {
}
// Creating a user in the userpass auth mount
_, err = client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/testuser", map[string]interface{}{
_, err = client.Logical().Write("auth/userpass/users/testuser", map[string]interface{}{
"password": "testpassword",
})
if err != nil {
t.Fatalf("failed to configure userpass backend: %v", err)
}
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
t.Fatalf("bb")
}
@ -93,7 +93,7 @@ func TestLoginMfaGenerateTOTPTestAuditIncluded(t *testing.T) {
var entityID string
var groupID string
{
resp, err := userClient.Logical().WriteWithContext(context.Background(), "identity/entity", map[string]interface{}{
resp, err := userClient.Logical().Write("identity/entity", map[string]interface{}{
"name": "test-entity",
"metadata": map[string]string{
"email": "test@hashicorp.com",
@ -106,7 +106,7 @@ func TestLoginMfaGenerateTOTPTestAuditIncluded(t *testing.T) {
entityID = resp.Data["id"].(string)
// Create a group
resp, err = client.Logical().WriteWithContext(context.Background(), "identity/group", map[string]interface{}{
resp, err = client.Logical().Write("identity/group", map[string]interface{}{
"name": "engineering",
"member_entity_ids": []string{entityID},
})
@ -115,7 +115,7 @@ func TestLoginMfaGenerateTOTPTestAuditIncluded(t *testing.T) {
}
groupID = resp.Data["id"].(string)
_, err = client.Logical().WriteWithContext(context.Background(), "identity/entity-alias", map[string]interface{}{
_, err = client.Logical().Write("identity/entity-alias", map[string]interface{}{
"name": "testuser",
"canonical_id": entityID,
"mount_accessor": mountAccessor,
@ -133,7 +133,7 @@ func TestLoginMfaGenerateTOTPTestAuditIncluded(t *testing.T) {
// login MFA
{
// create a config
resp1, err := client.Logical().WriteWithContext(context.Background(), "identity/mfa/method/totp", map[string]interface{}{
resp1, err := client.Logical().Write("identity/mfa/method/totp", map[string]interface{}{
"issuer": "yCorp",
"period": 5,
"algorithm": "SHA1",
@ -152,7 +152,7 @@ func TestLoginMfaGenerateTOTPTestAuditIncluded(t *testing.T) {
t.Fatalf("method ID is empty")
}
secret, err := client.Logical().WriteWithContext(context.Background(), fmt.Sprintf("identity/mfa/method/totp/admin-generate"), map[string]interface{}{
secret, err := client.Logical().Write(fmt.Sprintf("identity/mfa/method/totp/admin-generate"), map[string]interface{}{
"entity_id": entityID,
"method_id": methodID,
})
@ -161,21 +161,21 @@ func TestLoginMfaGenerateTOTPTestAuditIncluded(t *testing.T) {
}
totpURL := secret.Data["url"].(string)
_, err = client.Logical().WriteWithContext(context.Background(), "totp/keys/loginMFA", map[string]interface{}{
_, err = client.Logical().Write("totp/keys/loginMFA", map[string]interface{}{
"url": totpURL,
})
if err != nil {
t.Fatalf("failed to register a TOTP URL: %v", err)
}
secret, err = client.Logical().ReadWithContext(context.Background(), "totp/code/loginMFA")
secret, err = client.Logical().Read("totp/code/loginMFA")
if err != nil {
t.Fatalf("failed to create totp passcode: %v", err)
}
totpPasscode = secret.Data["code"].(string)
// creating MFAEnforcementConfig
_, err = client.Logical().WriteWithContext(context.Background(), "identity/mfa/login-enforcement/randomName", map[string]interface{}{
_, err = client.Logical().Write("identity/mfa/login-enforcement/randomName", map[string]interface{}{
"auth_method_accessors": []string{mountAccessor},
"auth_method_types": []string{"userpass"},
"identity_group_ids": []string{groupID},
@ -189,7 +189,7 @@ func TestLoginMfaGenerateTOTPTestAuditIncluded(t *testing.T) {
// MFA single-phase login
userClient.AddHeader("X-Vault-MFA", fmt.Sprintf("%s:%s", methodID, totpPasscode))
secret, err = userClient.Logical().WriteWithContext(context.Background(), "auth/userpass/login/testuser", map[string]interface{}{
secret, err = userClient.Logical().Write("auth/userpass/login/testuser", map[string]interface{}{
"password": "testpassword",
})
if err != nil {
@ -199,7 +199,7 @@ func TestLoginMfaGenerateTOTPTestAuditIncluded(t *testing.T) {
userpassToken = secret.Auth.ClientToken
userClient.SetToken(client.Token())
secret, err = userClient.Logical().WriteWithContext(context.Background(), "auth/token/lookup", map[string]interface{}{
secret, err = userClient.Logical().Write("auth/token/lookup", map[string]interface{}{
"token": userpassToken,
})
if err != nil {
@ -219,7 +219,7 @@ func TestLoginMfaGenerateTOTPTestAuditIncluded(t *testing.T) {
headers := user2Client.Headers()
headers.Del("X-Vault-MFA")
user2Client.SetHeaders(headers)
secret, err = user2Client.Logical().WriteWithContext(context.Background(), "auth/userpass/login/testuser", map[string]interface{}{
secret, err = user2Client.Logical().Write("auth/userpass/login/testuser", map[string]interface{}{
"password": "testpassword",
})
if err != nil {
@ -256,13 +256,13 @@ func TestLoginMfaGenerateTOTPTestAuditIncluded(t *testing.T) {
// waiting for 5 seconds so that a fresh code could be generated
time.Sleep(5 * time.Second)
// getting a fresh totp passcode for the validation step
totpResp, err := client.Logical().ReadWithContext(context.Background(), "totp/code/loginMFA")
totpResp, err := client.Logical().Read("totp/code/loginMFA")
if err != nil {
t.Fatalf("failed to create totp passcode: %v", err)
}
totpPasscode = totpResp.Data["code"].(string)
secret, err = user2Client.Logical().WriteWithContext(context.Background(), "sys/mfa/validate", map[string]interface{}{
secret, err = user2Client.Logical().Write("sys/mfa/validate", map[string]interface{}{
"mfa_request_id": secret.Auth.MFARequirement.MFARequestID,
"mfa_payload": map[string][]string{
methodID: {totpPasscode},
@ -291,7 +291,7 @@ func TestLoginMfaGenerateTOTPTestAuditIncluded(t *testing.T) {
}
// check for login request expiration
secret, err = user2Client.Logical().WriteWithContext(context.Background(), "auth/userpass/login/testuser", map[string]interface{}{
secret, err = user2Client.Logical().Write("auth/userpass/login/testuser", map[string]interface{}{
"password": "testpassword",
})
if err != nil {
@ -302,7 +302,7 @@ func TestLoginMfaGenerateTOTPTestAuditIncluded(t *testing.T) {
t.Fatalf("two phase login returned nil MFARequirement")
}
_, err = user2Client.Logical().WriteWithContext(context.Background(), "sys/mfa/validate", map[string]interface{}{
_, err = user2Client.Logical().Write("sys/mfa/validate", map[string]interface{}{
"mfa_request_id": secret.Auth.MFARequirement.MFARequestID,
"mfa_payload": map[string][]string{
methodID: {totpPasscode},
@ -316,7 +316,7 @@ func TestLoginMfaGenerateTOTPTestAuditIncluded(t *testing.T) {
}
// Destroy the secret so that the token can self generate
_, err = userClient.Logical().WriteWithContext(context.Background(), fmt.Sprintf("identity/mfa/method/totp/admin-destroy"), map[string]interface{}{
_, err = userClient.Logical().Write(fmt.Sprintf("identity/mfa/method/totp/admin-destroy"), map[string]interface{}{
"entity_id": entityID,
"method_id": methodID,
})

View File

@ -529,7 +529,7 @@ func TestOIDC_Auth_Code_Flow_Confidential_CAP_Client(t *testing.T) {
client.SetToken(clientToken)
// Update allowed client IDs before the authentication flow
_, err = client.Logical().WriteWithContext(context.Background(), "identity/oidc/provider/test-provider", map[string]interface{}{
_, err = client.Logical().Write("identity/oidc/provider/test-provider", map[string]interface{}{
"allowed_client_ids": []string{clientID},
})
require.NoError(t, err)
@ -599,7 +599,7 @@ func TestOIDC_Auth_Code_Flow_Confidential_CAP_Client(t *testing.T) {
// Assert that the access token is no longer able to obtain user info
// after removing the client from the provider's allowed client ids
_, err = client.Logical().WriteWithContext(context.Background(), "identity/oidc/provider/test-provider", map[string]interface{}{
_, err = client.Logical().Write("identity/oidc/provider/test-provider", map[string]interface{}{
"allowed_client_ids": []string{},
})
require.NoError(t, err)
@ -860,7 +860,7 @@ func TestOIDC_Auth_Code_Flow_Public_CAP_Client(t *testing.T) {
client.SetToken(clientToken)
// Update allowed client IDs before the authentication flow
_, err = client.Logical().WriteWithContext(context.Background(), "identity/oidc/provider/test-provider", map[string]interface{}{
_, err = client.Logical().Write("identity/oidc/provider/test-provider", map[string]interface{}{
"allowed_client_ids": []string{clientID},
})
require.NoError(t, err)
@ -935,7 +935,7 @@ func TestOIDC_Auth_Code_Flow_Public_CAP_Client(t *testing.T) {
// Assert that the access token is no longer able to obtain user info
// after removing the client from the provider's allowed client ids
_, err = client.Logical().WriteWithContext(context.Background(), "identity/oidc/provider/test-provider", map[string]interface{}{
_, err = client.Logical().Write("identity/oidc/provider/test-provider", map[string]interface{}{
"allowed_client_ids": []string{},
})
require.NoError(t, err)

View File

@ -237,7 +237,7 @@ func TestKV_Patch_RootToken(t *testing.T) {
client.SetToken(cluster.RootToken)
// Enable KVv2
err := client.Sys().MountWithContext(context.Background(), "kv", &api.MountInput{
err := client.Sys().Mount("kv", &api.MountInput{
Type: "kv-v2",
})
if err != nil {
@ -252,7 +252,7 @@ func TestKV_Patch_RootToken(t *testing.T) {
},
}
return client.Logical().WriteWithContext(context.Background(), "kv/data/foo", data)
return client.Logical().Write("kv/data/foo", data)
})
if err != nil {
@ -273,7 +273,7 @@ func TestKV_Patch_RootToken(t *testing.T) {
}
secretRaw, err := kvRequestWithRetry(t, func() (interface{}, error) {
return client.Logical().ReadWithContext(context.Background(), "kv/data/foo")
return client.Logical().Read("kv/data/foo")
})
if err != nil {
t.Fatal(err)

View File

@ -48,7 +48,7 @@ func TestKVv2_UpgradePaths(t *testing.T) {
client := core.Client
// Enable KVv2
err := client.Sys().MountWithContext(context.Background(), "kv", &api.MountInput{
err := client.Sys().Mount("kv", &api.MountInput{
Type: "kv-v2",
})
if err != nil {

View File

@ -49,7 +49,7 @@ func TestMountTableMetrics(t *testing.T) {
}
// Mount new kv
if err = client.Sys().MountWithContext(context.Background(), "kv", &api.MountInput{
if err = client.Sys().Mount("kv", &api.MountInput{
Type: "kv",
Options: map[string]string{
"version": "2",
@ -166,7 +166,7 @@ func TestLeaderReElectionMetrics(t *testing.T) {
t.Errorf("unseal metric or leader metric are missing")
}
err = client.Sys().StepDownWithContext(context.Background())
err = client.Sys().StepDown()
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package mfa
import (
"context"
"fmt"
"strings"
"testing"
@ -38,7 +37,7 @@ func TestLoginMFA_Method_CRUD(t *testing.T) {
t.Fatalf("failed to enable userpass auth: %v", err)
}
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}
@ -111,7 +110,7 @@ func TestLoginMFA_Method_CRUD(t *testing.T) {
t.Run(tc.methodName, func(t *testing.T) {
// create a new method config
myPath := fmt.Sprintf("identity/mfa/method/%s", tc.methodName)
resp, err := client.Logical().WriteWithContext(context.Background(), myPath, tc.configData)
resp, err := client.Logical().Write(myPath, tc.configData)
if err != nil {
t.Fatal(err)
}
@ -124,7 +123,7 @@ func TestLoginMFA_Method_CRUD(t *testing.T) {
myNewPath := fmt.Sprintf("%s/%s", myPath, methodId)
// read it back
resp, err = client.Logical().ReadWithContext(context.Background(), myNewPath)
resp, err = client.Logical().Read(myNewPath)
if err != nil {
t.Fatal(err)
}
@ -134,7 +133,7 @@ func TestLoginMFA_Method_CRUD(t *testing.T) {
}
// listing should show it
resp, err = client.Logical().ListWithContext(context.Background(), myPath)
resp, err = client.Logical().List(myPath)
if err != nil {
t.Fatal(err)
}
@ -144,12 +143,12 @@ func TestLoginMFA_Method_CRUD(t *testing.T) {
// update it
tc.configData[tc.keyToUpdate] = tc.valueToUpdate
_, err = client.Logical().WriteWithContext(context.Background(), myNewPath, tc.configData)
_, err = client.Logical().Write(myNewPath, tc.configData)
if err != nil {
t.Fatal(err)
}
resp, err = client.Logical().ReadWithContext(context.Background(), myNewPath)
resp, err = client.Logical().Read(myNewPath)
if err != nil {
t.Fatal(err)
}
@ -166,13 +165,13 @@ func TestLoginMFA_Method_CRUD(t *testing.T) {
}
// delete it
_, err = client.Logical().DeleteWithContext(context.Background(), myNewPath)
_, err = client.Logical().Delete(myNewPath)
if err != nil {
t.Fatal(err)
}
// try to read it again - should 404
resp, err = client.Logical().ReadWithContext(context.Background(), myNewPath)
resp, err = client.Logical().Read(myNewPath)
if !(resp == nil && err == nil) {
t.Fatal("expected a 404 but didn't get one")
}
@ -200,7 +199,7 @@ func TestLoginMFA_LoginEnforcement_CRUD(t *testing.T) {
configIDs := make([]string, 0)
for i := 0; i < 2; i++ {
resp, err := client.Logical().WriteWithContext(context.Background(), "identity/mfa/method/totp", map[string]interface{}{
resp, err := client.Logical().Write("identity/mfa/method/totp", map[string]interface{}{
"issuer": fmt.Sprintf("fooCorp%d", i),
"period": 10,
"algorithm": "SHA1",
@ -224,7 +223,7 @@ func TestLoginMFA_LoginEnforcement_CRUD(t *testing.T) {
t.Fatal(err)
}
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}
@ -235,19 +234,19 @@ func TestLoginMFA_LoginEnforcement_CRUD(t *testing.T) {
}
// create a few entities
resp, err := client.Logical().WriteWithContext(context.Background(), "identity/entity", map[string]interface{}{"name": "bob"})
resp, err := client.Logical().Write("identity/entity", map[string]interface{}{"name": "bob"})
if err != nil {
t.Fatal(err)
}
bobId := resp.Data["id"].(string)
resp, err = client.Logical().WriteWithContext(context.Background(), "identity/entity", map[string]interface{}{"name": "alice"})
resp, err = client.Logical().Write("identity/entity", map[string]interface{}{"name": "alice"})
if err != nil {
t.Fatal(err)
}
aliceId := resp.Data["id"].(string)
// create a few groups
resp, err = client.Logical().WriteWithContext(context.Background(), "identity/group", map[string]interface{}{
resp, err = client.Logical().Write("identity/group", map[string]interface{}{
"metadata": map[string]interface{}{"rad": true},
"member_entity_ids": []string{aliceId},
})
@ -256,7 +255,7 @@ func TestLoginMFA_LoginEnforcement_CRUD(t *testing.T) {
}
radGroupId := resp.Data["id"].(string)
resp, err = client.Logical().WriteWithContext(context.Background(), "identity/group", map[string]interface{}{
resp, err = client.Logical().Write("identity/group", map[string]interface{}{
"metadata": map[string]interface{}{"sad": true},
"member_entity_ids": []string{bobId},
})
@ -272,13 +271,13 @@ func TestLoginMFA_LoginEnforcement_CRUD(t *testing.T) {
}
// create a login enforcement config
_, err = client.Logical().WriteWithContext(context.Background(), myPath, data)
_, err = client.Logical().Write(myPath, data)
if err != nil {
t.Fatal(err)
}
// read it back
resp, err = client.Logical().ReadWithContext(context.Background(), myPath)
resp, err = client.Logical().Read(myPath)
if err != nil {
t.Fatal(err)
}
@ -293,7 +292,7 @@ func TestLoginMFA_LoginEnforcement_CRUD(t *testing.T) {
}
// listing should show it
resp, err = client.Logical().ListWithContext(context.Background(), "identity/mfa/login-enforcement")
resp, err = client.Logical().List("identity/mfa/login-enforcement")
if err != nil {
t.Fatal(err)
}
@ -304,13 +303,13 @@ func TestLoginMFA_LoginEnforcement_CRUD(t *testing.T) {
// update it
data["identity_group_ids"] = []string{radGroupId, sadGroupId}
data["identity_entity_ids"] = []string{bobId, aliceId}
_, err = client.Logical().WriteWithContext(context.Background(), myPath, data)
_, err = client.Logical().Write(myPath, data)
if err != nil {
t.Fatal(err)
}
// read it back
resp, err = client.Logical().ReadWithContext(context.Background(), myPath)
resp, err = client.Logical().Read(myPath)
if err != nil {
t.Fatal(err)
}
@ -325,13 +324,13 @@ func TestLoginMFA_LoginEnforcement_CRUD(t *testing.T) {
}
// delete it
_, err = client.Logical().DeleteWithContext(context.Background(), myPath)
_, err = client.Logical().Delete(myPath)
if err != nil {
t.Fatal(err)
}
// try to read it back again - should 404
resp, err = client.Logical().ReadWithContext(context.Background(), myPath)
resp, err = client.Logical().Read(myPath)
// when both the response and the error are nil on a read request, that gets translated into a 404
if !(resp == nil && err == nil) {
@ -352,7 +351,7 @@ func TestLoginMFA_LoginEnforcement_MethodIdsIsRequired(t *testing.T) {
client := cluster.Cores[0].Client
// create a login enforcement config, which should fail
_, err := client.Logical().WriteWithContext(context.Background(), "identity/mfa/login-enforcement/foo", map[string]interface{}{})
_, err := client.Logical().Write("identity/mfa/login-enforcement/foo", map[string]interface{}{})
if err == nil {
t.Fatal("expected an error but didn't get one")
}
@ -378,7 +377,7 @@ func TestLoginMFA_LoginEnforcement_RequiredParameters(t *testing.T) {
configIDs := make([]string, 0)
for i := 0; i < 2; i++ {
resp, err := client.Logical().WriteWithContext(context.Background(), "identity/mfa/method/totp", map[string]interface{}{
resp, err := client.Logical().Write("identity/mfa/method/totp", map[string]interface{}{
"issuer": fmt.Sprintf("fooCorp%d", i),
"period": 10,
"algorithm": "SHA1",
@ -395,7 +394,7 @@ func TestLoginMFA_LoginEnforcement_RequiredParameters(t *testing.T) {
}
// create a login enforcement config, which should fail
_, err := client.Logical().WriteWithContext(context.Background(), "identity/mfa/login-enforcement/foo", map[string]interface{}{
_, err := client.Logical().Write("identity/mfa/login-enforcement/foo", map[string]interface{}{
"mfa_method_ids": []string{configIDs[0], configIDs[1]},
})
if err == nil {
@ -417,7 +416,7 @@ func TestLoginMFA_UpdateNonExistentConfig(t *testing.T) {
vault.TestWaitActive(t, core)
client := cluster.Cores[0].Client
_, err := client.Logical().WriteWithContext(context.Background(), "mfa/method/totp/a51884c6-51f2-bdc3-f4c5-0da64fe4d061", map[string]interface{}{
_, err := client.Logical().Write("mfa/method/totp/a51884c6-51f2-bdc3-f4c5-0da64fe4d061", map[string]interface{}{
"issuer": "yCorp",
"period": 10,
"algorithm": "SHA1",

View File

@ -1,7 +1,6 @@
package misc
import (
"context"
"testing"
"github.com/hashicorp/go-hclog"
@ -32,14 +31,14 @@ func TestRecoverFromPanic(t *testing.T) {
vault.TestWaitActive(t, core.Core)
client := core.Client
err := client.Sys().MountWithContext(context.Background(), "noop", &api.MountInput{
err := client.Sys().Mount("noop", &api.MountInput{
Type: "noop",
})
if err != nil {
t.Fatal(err)
}
_, err = client.Logical().ReadWithContext(context.Background(), "noop/panic")
_, err = client.Logical().Read("noop/panic")
if err == nil {
t.Fatal("expected error")
}

View File

@ -1,7 +1,6 @@
package misc
import (
"context"
"path"
"testing"
@ -42,18 +41,18 @@ func TestRecovery(t *testing.T) {
client := cluster.Cores[0].Client
rootToken = client.Token()
fooVal := map[string]interface{}{"bar": 1.0}
_, err = client.Logical().WriteWithContext(context.Background(), "secret/foo", fooVal)
_, err = client.Logical().Write("secret/foo", fooVal)
if err != nil {
t.Fatal(err)
}
secret, err := client.Logical().ListWithContext(context.Background(), "secret/")
secret, err := client.Logical().List("secret/")
if err != nil {
t.Fatal(err)
}
if diff := deep.Equal(secret.Data["keys"], []interface{}{"foo"}); len(diff) > 0 {
t.Fatalf("got=%v, want=%v, diff: %v", secret.Data["keys"], []string{"foo"}, diff)
}
mounts, err := cluster.Cores[0].Client.Sys().ListMountsWithContext(context.Background())
mounts, err := cluster.Cores[0].Client.Sys().ListMounts()
if err != nil {
t.Fatal(err)
}
@ -96,7 +95,7 @@ func TestRecovery(t *testing.T) {
}
client.SetToken(recoveryToken)
secret, err := client.Logical().ListWithContext(context.Background(), path.Join("sys/raw/logical", secretUUID))
secret, err := client.Logical().List(path.Join("sys/raw/logical", secretUUID))
if err != nil {
t.Fatal(err)
}
@ -104,7 +103,7 @@ func TestRecovery(t *testing.T) {
t.Fatalf("got=%v, want=%v, diff: %v", secret.Data, []string{"foo"}, diff)
}
_, err = client.Logical().DeleteWithContext(context.Background(), path.Join("sys/raw/logical", secretUUID, "foo"))
_, err = client.Logical().Delete(path.Join("sys/raw/logical", secretUUID, "foo"))
if err != nil {
t.Fatal(err)
}
@ -132,7 +131,7 @@ func TestRecovery(t *testing.T) {
client := cluster.Cores[0].Client
client.SetToken(rootToken)
secret, err := client.Logical().ListWithContext(context.Background(), "secret/")
secret, err := client.Logical().List("secret/")
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package policy
import (
"context"
"fmt"
"testing"
@ -59,7 +58,7 @@ path "secret/{{ identity.groups.names.foobar.name}}/*" {
vault.TestWaitActive(t, core)
client := cluster.Cores[0].Client
resp, err := client.Logical().WriteWithContext(context.Background(), "identity/entity", map[string]interface{}{
resp, err := client.Logical().Write("identity/entity", map[string]interface{}{
"name": "entity_name",
"policies": []string{
"goodPolicy1",
@ -71,7 +70,7 @@ path "secret/{{ identity.groups.names.foobar.name}}/*" {
}
entityID := resp.Data["id"].(string)
resp, err = client.Logical().WriteWithContext(context.Background(), "identity/group", map[string]interface{}{
resp, err = client.Logical().Write("identity/group", map[string]interface{}{
"policies": []string{
"goodPolicy2",
},
@ -85,7 +84,7 @@ path "secret/{{ identity.groups.names.foobar.name}}/*" {
}
groupID := resp.Data["id"]
resp, err = client.Logical().WriteWithContext(context.Background(), "identity/group", map[string]interface{}{
resp, err = client.Logical().Write("identity/group", map[string]interface{}{
"name": "foobar",
})
if err != nil {
@ -103,14 +102,14 @@ path "secret/{{ identity.groups.names.foobar.name}}/*" {
// Create an external group and renew the token. This should add external
// group policies to the token.
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}
userpassAccessor := auths["userpass/"].Accessor
// Create an alias
resp, err = client.Logical().WriteWithContext(context.Background(), "identity/entity-alias", map[string]interface{}{
resp, err = client.Logical().Write("identity/entity-alias", map[string]interface{}{
"name": "testuser",
"mount_accessor": userpassAccessor,
"canonical_id": entityID,
@ -120,7 +119,7 @@ path "secret/{{ identity.groups.names.foobar.name}}/*" {
}
// Add a user to userpass backend
_, err = client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/testuser", map[string]interface{}{
_, err = client.Logical().Write("auth/userpass/users/testuser", map[string]interface{}{
"password": "testpassword",
})
if err != nil {
@ -130,17 +129,17 @@ path "secret/{{ identity.groups.names.foobar.name}}/*" {
// Write in policies
goodPolicy1 = fmt.Sprintf(goodPolicy1, userpassAccessor)
goodPolicy2 = fmt.Sprintf(goodPolicy2, groupID)
err = client.Sys().PutPolicyWithContext(context.Background(), "goodPolicy1", goodPolicy1)
err = client.Sys().PutPolicy("goodPolicy1", goodPolicy1)
if err != nil {
t.Fatal(err)
}
err = client.Sys().PutPolicyWithContext(context.Background(), "goodPolicy2", goodPolicy2)
err = client.Sys().PutPolicy("goodPolicy2", goodPolicy2)
if err != nil {
t.Fatal(err)
}
// Authenticate
secret, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/login/testuser", map[string]interface{}{
secret, err := client.Logical().Write("auth/userpass/login/testuser", map[string]interface{}{
"password": "testpassword",
})
if err != nil {
@ -182,7 +181,7 @@ path "secret/{{ identity.groups.names.foobar.name}}/*" {
runTests := func(failGroupName bool) {
for _, test := range tests {
resp, err := client.Logical().WriteWithContext(context.Background(), test.path, map[string]interface{}{"zip": "zap"})
resp, err := client.Logical().Write(test.path, map[string]interface{}{"zip": "zap"})
fail := test.fail
if test.name == "bad group name" {
fail = failGroupName
@ -205,7 +204,7 @@ path "secret/{{ identity.groups.names.foobar.name}}/*" {
client.SetToken(rootToken)
// Test that a policy with bad group membership doesn't kill the other paths
err = client.Sys().PutPolicyWithContext(context.Background(), "badPolicy1", badPolicy1)
err = client.Sys().PutPolicy("badPolicy1", badPolicy1)
if err != nil {
t.Fatal(err)
}
@ -214,7 +213,7 @@ path "secret/{{ identity.groups.names.foobar.name}}/*" {
// Test that adding group membership now allows access
client.SetToken(rootToken)
resp, err = client.Logical().WriteWithContext(context.Background(), "identity/group", map[string]interface{}{
resp, err = client.Logical().Write("identity/group", map[string]interface{}{
"id": foobarGroupID,
"member_entity_ids": []string{
entityID,

View File

@ -1,7 +1,6 @@
package policy
import (
"context"
"testing"
"time"
@ -52,7 +51,7 @@ func TestPolicy_NoDefaultPolicy(t *testing.T) {
cleanup, cfg := ldaphelper.PrepareTestContainer(t, "latest")
defer cleanup()
_, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap/config", map[string]interface{}{
_, err = client.Logical().Write("auth/ldap/config", map[string]interface{}{
"url": cfg.Url,
"userattr": cfg.UserAttr,
"userdn": cfg.UserDN,
@ -67,7 +66,7 @@ func TestPolicy_NoDefaultPolicy(t *testing.T) {
}
// Create a local user in LDAP
secret, err := client.Logical().WriteWithContext(context.Background(), "auth/ldap/users/hermes conrad", map[string]interface{}{
secret, err := client.Logical().Write("auth/ldap/users/hermes conrad", map[string]interface{}{
"policies": "foo",
})
if err != nil {
@ -75,7 +74,7 @@ func TestPolicy_NoDefaultPolicy(t *testing.T) {
}
// Login with LDAP and create a token
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap/login/hermes conrad", map[string]interface{}{
secret, err = client.Logical().Write("auth/ldap/login/hermes conrad", map[string]interface{}{
"password": "hermes",
})
if err != nil {
@ -84,7 +83,7 @@ func TestPolicy_NoDefaultPolicy(t *testing.T) {
token := secret.Auth.ClientToken
// Lookup the token to get the entity ID
secret, err = client.Auth().Token().LookupWithContext(context.Background(), token)
secret, err = client.Auth().Token().Lookup(token)
if err != nil {
t.Fatal(err)
}
@ -129,7 +128,7 @@ func TestPolicy_NoConfiguredPolicy(t *testing.T) {
cleanup, cfg := ldaphelper.PrepareTestContainer(t, "latest")
defer cleanup()
_, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap/config", map[string]interface{}{
_, err = client.Logical().Write("auth/ldap/config", map[string]interface{}{
"url": cfg.Url,
"userattr": cfg.UserAttr,
"userdn": cfg.UserDN,
@ -144,13 +143,13 @@ func TestPolicy_NoConfiguredPolicy(t *testing.T) {
}
// Create a local user in LDAP without any policies configured
secret, err := client.Logical().WriteWithContext(context.Background(), "auth/ldap/users/hermes conrad", map[string]interface{}{})
secret, err := client.Logical().Write("auth/ldap/users/hermes conrad", map[string]interface{}{})
if err != nil {
t.Fatal(err)
}
// Login with LDAP and create a token
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/ldap/login/hermes conrad", map[string]interface{}{
secret, err = client.Logical().Write("auth/ldap/login/hermes conrad", map[string]interface{}{
"password": "hermes",
})
if err != nil {
@ -159,7 +158,7 @@ func TestPolicy_NoConfiguredPolicy(t *testing.T) {
token := secret.Auth.ClientToken
// Lookup the token to get the entity ID
secret, err = client.Auth().Token().LookupWithContext(context.Background(), token)
secret, err = client.Auth().Token().Lookup(token)
if err != nil {
t.Fatal(err)
}
@ -171,7 +170,7 @@ func TestPolicy_NoConfiguredPolicy(t *testing.T) {
// Renew the token with an increment of 2 hours to ensure that lease renewal
// occurred and can be checked against the default lease duration with a
// big enough delta.
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/token/renew", map[string]interface{}{
secret, err = client.Logical().Write("auth/token/renew", map[string]interface{}{
"token": token,
"increment": "2h",
})
@ -245,20 +244,20 @@ func TestPolicy_TokenRenewal(t *testing.T) {
if len(tc.tokenPolicies) > 0 {
data["token_policies"] = tc.tokenPolicies
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/testuser", data)
_, err = client.Logical().Write("auth/userpass/users/testuser", data)
if err != nil {
t.Fatal(err)
}
// Set up entity if we're testing against an identity_policies
if len(tc.identityPolicies) > 0 {
auths, err := client.Sys().ListAuthWithContext(context.Background())
auths, err := client.Sys().ListAuth()
if err != nil {
t.Fatal(err)
}
userpassAccessor := auths["userpass/"].Accessor
resp, err := client.Logical().WriteWithContext(context.Background(), "identity/entity", map[string]interface{}{
resp, err := client.Logical().Write("identity/entity", map[string]interface{}{
"name": "test-entity",
"policies": tc.identityPolicies,
})
@ -268,7 +267,7 @@ func TestPolicy_TokenRenewal(t *testing.T) {
entityID := resp.Data["id"].(string)
// Create an alias
resp, err = client.Logical().WriteWithContext(context.Background(), "identity/entity-alias", map[string]interface{}{
resp, err = client.Logical().Write("identity/entity-alias", map[string]interface{}{
"name": "testuser",
"mount_accessor": userpassAccessor,
"canonical_id": entityID,
@ -279,7 +278,7 @@ func TestPolicy_TokenRenewal(t *testing.T) {
}
// Authenticate
secret, err := client.Logical().WriteWithContext(context.Background(), "auth/userpass/login/testuser", map[string]interface{}{
secret, err := client.Logical().Write("auth/userpass/login/testuser", map[string]interface{}{
"password": "testpassword",
})
if err != nil {
@ -303,7 +302,7 @@ func TestPolicy_TokenRenewal(t *testing.T) {
}
// Renew token
secret, err = client.Logical().WriteWithContext(context.Background(), "auth/token/renew", map[string]interface{}{
secret, err = client.Logical().Write("auth/token/renew", map[string]interface{}{
"token": clientToken,
})
if err != nil {

View File

@ -1,7 +1,6 @@
package quotas
import (
"context"
"fmt"
"testing"
"time"
@ -44,21 +43,21 @@ func setupMounts(t *testing.T, client *api.Client) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/foo", map[string]interface{}{
_, err = client.Logical().Write("auth/userpass/users/foo", map[string]interface{}{
"password": "bar",
})
if err != nil {
t.Fatal(err)
}
err = client.Sys().MountWithContext(context.Background(), "pki", &api.MountInput{
err = client.Sys().Mount("pki", &api.MountInput{
Type: "pki",
})
if err != nil {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "pki/root/generate/internal", map[string]interface{}{
_, err = client.Logical().Write("pki/root/generate/internal", map[string]interface{}{
"common_name": "testvault.com",
"ttl": "200h",
"ip_sans": "127.0.0.1",
@ -67,7 +66,7 @@ func setupMounts(t *testing.T, client *api.Client) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "pki/roles/test", map[string]interface{}{
_, err = client.Logical().Write("pki/roles/test", map[string]interface{}{
"require_cn": false,
"allowed_domains": "testvault.com",
"allow_subdomains": true,
@ -81,10 +80,10 @@ func setupMounts(t *testing.T, client *api.Client) {
func teardownMounts(t *testing.T, client *api.Client) {
t.Helper()
if err := client.Sys().UnmountWithContext(context.Background(), "pki"); err != nil {
if err := client.Sys().Unmount("pki"); err != nil {
t.Fatal(err)
}
if err := client.Sys().DisableAuthWithContext(context.Background(), "userpass"); err != nil {
if err := client.Sys().DisableAuth("userpass"); err != nil {
t.Fatal(err)
}
}
@ -135,25 +134,25 @@ func TestQuotas_RateLimit_DupName(t *testing.T) {
vault.TestWaitActive(t, core)
// create a rate limit quota w/ 'secret' path
_, err := client.Logical().WriteWithContext(context.Background(), "sys/quotas/rate-limit/secret-rlq", map[string]interface{}{
_, err := client.Logical().Write("sys/quotas/rate-limit/secret-rlq", map[string]interface{}{
"rate": 7.7,
"path": "secret",
})
require.NoError(t, err)
s, err := client.Logical().ReadWithContext(context.Background(), "sys/quotas/rate-limit/secret-rlq")
s, err := client.Logical().Read("sys/quotas/rate-limit/secret-rlq")
require.NoError(t, err)
require.NotEmpty(t, s.Data)
// create a rate limit quota w/ empty path (same name)
_, err = client.Logical().WriteWithContext(context.Background(), "sys/quotas/rate-limit/secret-rlq", map[string]interface{}{
_, err = client.Logical().Write("sys/quotas/rate-limit/secret-rlq", map[string]interface{}{
"rate": 7.7,
"path": "",
})
require.NoError(t, err)
// list again and verify that only 1 item is returned
s, err = client.Logical().ListWithContext(context.Background(), "sys/quotas/rate-limit")
s, err = client.Logical().List("sys/quotas/rate-limit")
require.NoError(t, err)
require.Len(t, s.Data, 1, "incorrect number of quotas")
@ -169,25 +168,25 @@ func TestQuotas_RateLimit_DupPath(t *testing.T) {
client := cluster.Cores[0].Client
vault.TestWaitActive(t, core)
// create a global rate limit quota
_, err := client.Logical().WriteWithContext(context.Background(), "sys/quotas/rate-limit/global-rlq", map[string]interface{}{
_, err := client.Logical().Write("sys/quotas/rate-limit/global-rlq", map[string]interface{}{
"rate": 10,
"path": "",
})
require.NoError(t, err)
// create a rate limit quota w/ 'secret' path
_, err = client.Logical().WriteWithContext(context.Background(), "sys/quotas/rate-limit/secret-rlq", map[string]interface{}{
_, err = client.Logical().Write("sys/quotas/rate-limit/secret-rlq", map[string]interface{}{
"rate": 7.7,
"path": "secret",
})
require.NoError(t, err)
s, err := client.Logical().ReadWithContext(context.Background(), "sys/quotas/rate-limit/secret-rlq")
s, err := client.Logical().Read("sys/quotas/rate-limit/secret-rlq")
require.NoError(t, err)
require.NotEmpty(t, s.Data)
// create a rate limit quota w/ empty path (same name)
_, err = client.Logical().WriteWithContext(context.Background(), "sys/quotas/rate-limit/secret-rlq", map[string]interface{}{
_, err = client.Logical().Write("sys/quotas/rate-limit/secret-rlq", map[string]interface{}{
"rate": 7.7,
"path": "",
})
@ -208,18 +207,18 @@ func TestQuotas_RateLimitQuota_ExemptPaths(t *testing.T) {
client := cluster.Cores[0].Client
vault.TestWaitActive(t, core)
_, err := client.Logical().WriteWithContext(context.Background(), "sys/quotas/rate-limit/rlq", map[string]interface{}{
_, err := client.Logical().Write("sys/quotas/rate-limit/rlq", map[string]interface{}{
"rate": 7.7,
})
require.NoError(t, err)
// ensure exempt paths are not empty by default
resp, err := client.Logical().ReadWithContext(context.Background(), "sys/quotas/config")
resp, err := client.Logical().Read("sys/quotas/config")
require.NoError(t, err)
require.NotEmpty(t, resp.Data["rate_limit_exempt_paths"].([]interface{}), "expected no exempt paths by default")
reqFunc := func(numSuccess, numFail *atomic.Int32) {
_, err := client.Logical().ReadWithContext(context.Background(), "sys/quotas/rate-limit/rlq")
_, err := client.Logical().Read("sys/quotas/rate-limit/rlq")
if err != nil {
numFail.Add(1)
@ -237,7 +236,7 @@ func TestQuotas_RateLimitQuota_ExemptPaths(t *testing.T) {
// allow time (1s) for rate limit to refill before updating the quota config
time.Sleep(time.Second)
_, err = client.Logical().WriteWithContext(context.Background(), "sys/quotas/config", map[string]interface{}{
_, err = client.Logical().Write("sys/quotas/config", map[string]interface{}{
"rate_limit_exempt_paths": []string{"sys/quotas/rate-limit"},
})
require.NoError(t, err)
@ -258,14 +257,14 @@ func TestQuotas_RateLimitQuota_Mount(t *testing.T) {
client := cluster.Cores[0].Client
vault.TestWaitActive(t, core)
err := client.Sys().MountWithContext(context.Background(), "pki", &api.MountInput{
err := client.Sys().Mount("pki", &api.MountInput{
Type: "pki",
})
if err != nil {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "pki/root/generate/internal", map[string]interface{}{
_, err = client.Logical().Write("pki/root/generate/internal", map[string]interface{}{
"common_name": "testvault.com",
"ttl": "200h",
"ip_sans": "127.0.0.1",
@ -274,7 +273,7 @@ func TestQuotas_RateLimitQuota_Mount(t *testing.T) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "pki/roles/test", map[string]interface{}{
_, err = client.Logical().Write("pki/roles/test", map[string]interface{}{
"require_cn": false,
"allowed_domains": "testvault.com",
"allow_subdomains": true,
@ -286,7 +285,7 @@ func TestQuotas_RateLimitQuota_Mount(t *testing.T) {
}
reqFunc := func(numSuccess, numFail *atomic.Int32) {
_, err := client.Logical().ReadWithContext(context.Background(), "pki/cert/ca_chain")
_, err := client.Logical().Read("pki/cert/ca_chain")
if err != nil {
numFail.Add(1)
@ -298,7 +297,7 @@ func TestQuotas_RateLimitQuota_Mount(t *testing.T) {
// Create a rate limit quota with a low RPS of 7.7, which means we can process
// ⌈7.7⌉*2 requests in the span of roughly a second -- 8 initially, followed
// by a refill rate of 7.7 per-second.
_, err = client.Logical().WriteWithContext(context.Background(), "sys/quotas/rate-limit/rlq", map[string]interface{}{
_, err = client.Logical().Write("sys/quotas/rate-limit/rlq", map[string]interface{}{
"rate": 7.7,
"path": "pki/",
})
@ -322,7 +321,7 @@ func TestQuotas_RateLimitQuota_Mount(t *testing.T) {
}
// update the rate limit quota with a high RPS such that no requests should fail
_, err = client.Logical().WriteWithContext(context.Background(), "sys/quotas/rate-limit/rlq", map[string]interface{}{
_, err = client.Logical().Write("sys/quotas/rate-limit/rlq", map[string]interface{}{
"rate": 10000.0,
"path": "pki/",
})
@ -348,14 +347,14 @@ func TestQuotas_RateLimitQuota_MountPrecedence(t *testing.T) {
vault.TestWaitActive(t, core)
// create PKI mount
err := client.Sys().MountWithContext(context.Background(), "pki", &api.MountInput{
err := client.Sys().Mount("pki", &api.MountInput{
Type: "pki",
})
if err != nil {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "pki/root/generate/internal", map[string]interface{}{
_, err = client.Logical().Write("pki/root/generate/internal", map[string]interface{}{
"common_name": "testvault.com",
"ttl": "200h",
"ip_sans": "127.0.0.1",
@ -364,7 +363,7 @@ func TestQuotas_RateLimitQuota_MountPrecedence(t *testing.T) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "pki/roles/test", map[string]interface{}{
_, err = client.Logical().Write("pki/roles/test", map[string]interface{}{
"require_cn": false,
"allowed_domains": "testvault.com",
"allow_subdomains": true,
@ -376,7 +375,7 @@ func TestQuotas_RateLimitQuota_MountPrecedence(t *testing.T) {
}
// create a root rate limit quota
_, err = client.Logical().WriteWithContext(context.Background(), "sys/quotas/rate-limit/root-rlq", map[string]interface{}{
_, err = client.Logical().Write("sys/quotas/rate-limit/root-rlq", map[string]interface{}{
"name": "root-rlq",
"rate": 14.7,
})
@ -385,7 +384,7 @@ func TestQuotas_RateLimitQuota_MountPrecedence(t *testing.T) {
}
// create a mount rate limit quota with a lower RPS than the root rate limit quota
_, err = client.Logical().WriteWithContext(context.Background(), "sys/quotas/rate-limit/mount-rlq", map[string]interface{}{
_, err = client.Logical().Write("sys/quotas/rate-limit/mount-rlq", map[string]interface{}{
"name": "mount-rlq",
"rate": 7.7,
"path": "pki/",
@ -396,7 +395,7 @@ func TestQuotas_RateLimitQuota_MountPrecedence(t *testing.T) {
// ensure mount rate limit quota takes precedence over root rate limit quota
reqFunc := func(numSuccess, numFail *atomic.Int32) {
_, err := client.Logical().ReadWithContext(context.Background(), "pki/cert/ca_chain")
_, err := client.Logical().Read("pki/cert/ca_chain")
if err != nil {
numFail.Add(1)
@ -440,7 +439,7 @@ func TestQuotas_RateLimitQuota(t *testing.T) {
t.Fatal(err)
}
_, err = client.Logical().WriteWithContext(context.Background(), "auth/userpass/users/foo", map[string]interface{}{
_, err = client.Logical().Write("auth/userpass/users/foo", map[string]interface{}{
"password": "bar",
})
if err != nil {
@ -450,7 +449,7 @@ func TestQuotas_RateLimitQuota(t *testing.T) {
// Create a rate limit quota with a low RPS of 7.7, which means we can process
// ⌈7.7⌉*2 requests in the span of roughly a second -- 8 initially, followed
// by a refill rate of 7.7 per-second.
_, err = client.Logical().WriteWithContext(context.Background(), "sys/quotas/rate-limit/rlq", map[string]interface{}{
_, err = client.Logical().Write("sys/quotas/rate-limit/rlq", map[string]interface{}{
"rate": 7.7,
})
if err != nil {
@ -458,7 +457,7 @@ func TestQuotas_RateLimitQuota(t *testing.T) {
}
reqFunc := func(numSuccess, numFail *atomic.Int32) {
_, err := client.Logical().ReadWithContext(context.Background(), "sys/quotas/rate-limit/rlq")
_, err := client.Logical().Read("sys/quotas/rate-limit/rlq")
if err != nil {
numFail.Add(1)
@ -486,7 +485,7 @@ func TestQuotas_RateLimitQuota(t *testing.T) {
time.Sleep(time.Second)
// update the rate limit quota with a high RPS such that no requests should fail
_, err = client.Logical().WriteWithContext(context.Background(), "sys/quotas/rate-limit/rlq", map[string]interface{}{
_, err = client.Logical().Write("sys/quotas/rate-limit/rlq", map[string]interface{}{
"rate": 10000.0,
})
if err != nil {

View File

@ -32,7 +32,7 @@ func TestRaft_Autopilot_Disable(t *testing.T) {
client := cluster.Cores[0].Client
state, err := client.Sys().RaftAutopilotStateWithContext(context.Background())
state, err := client.Sys().RaftAutopilotState()
require.NoError(t, err)
require.Nil(t, nil, state)
}
@ -47,7 +47,7 @@ func TestRaft_Autopilot_Stabilization_And_State(t *testing.T) {
// Check that autopilot execution state is running
client := cluster.Cores[0].Client
state, err := client.Sys().RaftAutopilotStateWithContext(context.Background())
state, err := client.Sys().RaftAutopilotState()
require.NoError(t, err)
require.Equal(t, true, state.Healthy)
require.Len(t, state.Servers, 1)
@ -55,7 +55,7 @@ func TestRaft_Autopilot_Stabilization_And_State(t *testing.T) {
require.Equal(t, "alive", state.Servers["core-0"].NodeStatus)
require.Equal(t, "leader", state.Servers["core-0"].Status)
config, err := client.Sys().RaftAutopilotConfigurationWithContext(context.Background())
config, err := client.Sys().RaftAutopilotConfiguration()
require.NoError(t, err)
// Wait for 110% of the stabilization time to add nodes
@ -78,7 +78,7 @@ func TestRaft_Autopilot_Stabilization_And_State(t *testing.T) {
joinFunc(core)
time.Sleep(2 * time.Second)
state, err = client.Sys().RaftAutopilotStateWithContext(context.Background())
state, err = client.Sys().RaftAutopilotState()
require.NoError(t, err)
require.Equal(t, false, state.Healthy)
require.Len(t, state.Servers, numServers)
@ -91,7 +91,7 @@ func TestRaft_Autopilot_Stabilization_And_State(t *testing.T) {
deadline := time.Now().Add(stabilizationWaitDuration)
healthy := false
for time.Now().Before(deadline) {
state, err := client.Sys().RaftAutopilotStateWithContext(context.Background())
state, err := client.Sys().RaftAutopilotState()
require.NoError(t, err)
if state.Healthy {
healthy = true
@ -108,7 +108,7 @@ func TestRaft_Autopilot_Stabilization_And_State(t *testing.T) {
deadline = time.Now().Add(2 * autopilot.DefaultReconcileInterval)
failed := true
for time.Now().Before(deadline) {
state, err = client.Sys().RaftAutopilotStateWithContext(context.Background())
state, err = client.Sys().RaftAutopilotState()
require.NoError(t, err)
if state.Servers[nodeID].Status == "voter" {
failed = false
@ -123,7 +123,7 @@ func TestRaft_Autopilot_Stabilization_And_State(t *testing.T) {
}
joinAndStabilizeFunc(cluster.Cores[1], "core-1", 2)
joinAndStabilizeFunc(cluster.Cores[2], "core-2", 3)
state, err = client.Sys().RaftAutopilotStateWithContext(context.Background())
state, err = client.Sys().RaftAutopilotState()
require.NoError(t, err)
require.Equal(t, []string{"core-0", "core-1", "core-2"}, state.Voters)
}
@ -138,13 +138,13 @@ func TestRaft_Autopilot_Configuration(t *testing.T) {
client := cluster.Cores[0].Client
configCheckFunc := func(config *api.AutopilotConfig) {
conf, err := client.Sys().RaftAutopilotConfigurationWithContext(context.Background())
conf, err := client.Sys().RaftAutopilotConfiguration()
require.NoError(t, err)
require.Equal(t, config, conf)
}
writeConfigFunc := func(config map[string]interface{}, expectError bool) {
resp, err := client.Logical().WriteWithContext(context.Background(), "sys/storage/raft/autopilot/configuration", config)
resp, err := client.Logical().Write("sys/storage/raft/autopilot/configuration", config)
if expectError {
require.Error(t, err)
return
@ -242,7 +242,7 @@ func TestRaft_Autopilot_Stabilization_Delay(t *testing.T) {
// Check that autopilot execution state is running
client := cluster.Cores[0].Client
state, err := client.Sys().RaftAutopilotStateWithContext(context.Background())
state, err := client.Sys().RaftAutopilotState()
require.NotNil(t, state)
require.NoError(t, err)
require.Equal(t, true, state.Healthy)
@ -251,12 +251,12 @@ func TestRaft_Autopilot_Stabilization_Delay(t *testing.T) {
require.Equal(t, "alive", state.Servers["core-0"].NodeStatus)
require.Equal(t, "leader", state.Servers["core-0"].Status)
_, err = client.Logical().WriteWithContext(context.Background(), "sys/storage/raft/autopilot/configuration", map[string]interface{}{
_, err = client.Logical().Write("sys/storage/raft/autopilot/configuration", map[string]interface{}{
"server_stabilization_time": "5s",
})
require.NoError(t, err)
config, err := client.Sys().RaftAutopilotConfigurationWithContext(context.Background())
config, err := client.Sys().RaftAutopilotConfiguration()
require.NoError(t, err)
// Wait for 110% of the stabilization time to add nodes
@ -295,7 +295,7 @@ func TestRaft_Autopilot_Stabilization_Delay(t *testing.T) {
deadline := time.Now().Add(stabilizationWaitDuration)
var core1healthy, core2healthy bool
for time.Now().Before(deadline) {
state, err := client.Sys().RaftAutopilotStateWithContext(context.Background())
state, err := client.Sys().RaftAutopilotState()
require.NoError(t, err)
core1healthy = state.Servers["core-1"] != nil && state.Servers["core-1"].Healthy
core2healthy = state.Servers["core-2"] != nil && state.Servers["core-2"].Healthy
@ -306,12 +306,12 @@ func TestRaft_Autopilot_Stabilization_Delay(t *testing.T) {
}
time.Sleep(2 * time.Second) // wait for reconciliation
state, err = client.Sys().RaftAutopilotStateWithContext(context.Background())
state, err = client.Sys().RaftAutopilotState()
require.NoError(t, err)
require.Equal(t, []string{"core-0", "core-1"}, state.Voters)
for time.Now().Before(core2shouldBeHealthyAt) {
state, err := client.Sys().RaftAutopilotStateWithContext(context.Background())
state, err := client.Sys().RaftAutopilotState()
require.NoError(t, err)
core2healthy = state.Servers["core-2"].Healthy
time.Sleep(1 * time.Second)
@ -320,7 +320,7 @@ func TestRaft_Autopilot_Stabilization_Delay(t *testing.T) {
deadline = time.Now().Add(10 * time.Second)
for time.Now().Before(deadline) {
state, err = client.Sys().RaftAutopilotStateWithContext(context.Background())
state, err = client.Sys().RaftAutopilotState()
if err != nil {
t.Fatal(err)
}
@ -343,7 +343,7 @@ func TestRaft_AutoPilot_Peersets_Equivalent(t *testing.T) {
// Create a very large stabilization time so we can test the state between
// joining and promotions
client := cluster.Cores[0].Client
_, err := client.Logical().WriteWithContext(context.Background(), "sys/storage/raft/autopilot/configuration", map[string]interface{}{
_, err := client.Logical().Write("sys/storage/raft/autopilot/configuration", map[string]interface{}{
"server_stabilization_time": "1h",
})
require.NoError(t, err)

View File

@ -105,7 +105,7 @@ func TestRaft_BoltDBMetrics(t *testing.T) {
// Write a few keys
for i := 0; i < 50; i++ {
_, err := leaderClient.Logical().WriteWithContext(context.Background(), fmt.Sprintf("secret/%d", i), map[string]interface{}{
_, err := leaderClient.Logical().Write(fmt.Sprintf("secret/%d", i), map[string]interface{}{
fmt.Sprintf("foo%d", i): fmt.Sprintf("bar%d", i),
})
if err != nil {
@ -282,7 +282,7 @@ func TestRaft_Join(t *testing.T) {
req.LeaderClientCert = string(cluster.CACertPEM)
req.LeaderClientKey = string(cluster.CAKeyPEM)
}
resp, err := client.Sys().RaftJoinWithContext(context.Background(), req)
resp, err := client.Sys().RaftJoin(req)
if err != nil {
t.Fatal(err)
}
@ -294,14 +294,14 @@ func TestRaft_Join(t *testing.T) {
joinFunc(cluster.Cores[1].Client, false)
joinFunc(cluster.Cores[2].Client, false)
_, err := cluster.Cores[0].Client.Logical().WriteWithContext(context.Background(), "sys/storage/raft/remove-peer", map[string]interface{}{
_, err := cluster.Cores[0].Client.Logical().Write("sys/storage/raft/remove-peer", map[string]interface{}{
"server_id": "core-1",
})
if err != nil {
t.Fatal(err)
}
_, err = cluster.Cores[0].Client.Logical().WriteWithContext(context.Background(), "sys/storage/raft/remove-peer", map[string]interface{}{
_, err = cluster.Cores[0].Client.Logical().Write("sys/storage/raft/remove-peer", map[string]interface{}{
"server_id": "core-2",
})
if err != nil {
@ -331,7 +331,7 @@ func TestRaft_RemovePeer(t *testing.T) {
"core-2": true,
})
_, err := client.Logical().WriteWithContext(context.Background(), "sys/storage/raft/remove-peer", map[string]interface{}{
_, err := client.Logical().Write("sys/storage/raft/remove-peer", map[string]interface{}{
"server_id": "core-2",
})
if err != nil {
@ -343,7 +343,7 @@ func TestRaft_RemovePeer(t *testing.T) {
"core-1": true,
})
_, err = client.Logical().WriteWithContext(context.Background(), "sys/storage/raft/remove-peer", map[string]interface{}{
_, err = client.Logical().Write("sys/storage/raft/remove-peer", map[string]interface{}{
"server_id": "core-1",
})
if err != nil {
@ -425,7 +425,7 @@ func TestRaft_Configuration(t *testing.T) {
}
client := cluster.Cores[0].Client
secret, err := client.Logical().ReadWithContext(context.Background(), "sys/storage/raft/configuration")
secret, err := client.Logical().Read("sys/storage/raft/configuration")
if err != nil {
t.Fatal(err)
}
@ -481,7 +481,7 @@ func TestRaft_SnapshotAPI(t *testing.T) {
// Write a few keys
for i := 0; i < 10; i++ {
_, err := leaderClient.Logical().WriteWithContext(context.Background(), fmt.Sprintf("secret/%d", i), map[string]interface{}{
_, err := leaderClient.Logical().Write(fmt.Sprintf("secret/%d", i), map[string]interface{}{
"test": "data",
})
if err != nil {
@ -491,7 +491,7 @@ func TestRaft_SnapshotAPI(t *testing.T) {
// Take a snapshot
buf := new(bytes.Buffer)
err := leaderClient.Sys().RaftSnapshotWithContext(context.Background(), buf)
err := leaderClient.Sys().RaftSnapshot(buf)
if err != nil {
t.Fatal(err)
}
@ -505,7 +505,7 @@ func TestRaft_SnapshotAPI(t *testing.T) {
// Write a few more keys
for i := 10; i < 20; i++ {
_, err := leaderClient.Logical().WriteWithContext(context.Background(), fmt.Sprintf("secret/%d", i), map[string]interface{}{
_, err := leaderClient.Logical().Write(fmt.Sprintf("secret/%d", i), map[string]interface{}{
"test": "data",
})
if err != nil {
@ -513,13 +513,13 @@ func TestRaft_SnapshotAPI(t *testing.T) {
}
}
// Restore snapshot
err = leaderClient.Sys().RaftSnapshotRestoreWithContext(context.Background(), bytes.NewReader(snap), false)
err = leaderClient.Sys().RaftSnapshotRestore(bytes.NewReader(snap), false)
if err != nil {
t.Fatal(err)
}
// List kv to make sure we removed the extra keys
secret, err := leaderClient.Logical().ListWithContext(context.Background(), "secret/")
secret, err := leaderClient.Logical().List("secret/")
if err != nil {
t.Fatal(err)
}
@ -546,7 +546,7 @@ func TestRaft_SnapshotAPI_MidstreamFailure(t *testing.T) {
// will never make it into the tar part, it'll fail merely when trying to
// decompress the stream.
for i := 0; i < 1000; i++ {
_, err := leaderClient.Logical().WriteWithContext(context.Background(), fmt.Sprintf("secret/%d", i), map[string]interface{}{
_, err := leaderClient.Logical().Write(fmt.Sprintf("secret/%d", i), map[string]interface{}{
"test": "data",
})
if err != nil {
@ -567,7 +567,7 @@ func TestRaft_SnapshotAPI_MidstreamFailure(t *testing.T) {
setErr(errors.New("seal failure"))
// Take a snapshot
err := leaderClient.Sys().RaftSnapshotWithContext(context.Background(), w)
err := leaderClient.Sys().RaftSnapshot(w)
w.Close()
if err == nil || err != api.ErrIncompleteSnapshot {
t.Fatalf("expected err=%v, got: %v", api.ErrIncompleteSnapshot, err)
@ -646,7 +646,7 @@ func TestRaft_SnapshotAPI_RekeyRotate_Backward(t *testing.T) {
// Write a few keys
for i := 0; i < 10; i++ {
_, err := leaderClient.Logical().WriteWithContext(context.Background(), fmt.Sprintf("secret/%d", i), map[string]interface{}{
_, err := leaderClient.Logical().Write(fmt.Sprintf("secret/%d", i), map[string]interface{}{
"test": "data",
})
if err != nil {
@ -688,7 +688,7 @@ func TestRaft_SnapshotAPI_RekeyRotate_Backward(t *testing.T) {
if tCaseLocal.Rotate {
// Rotate
err = leaderClient.Sys().RotateWithContext(context.Background())
err = leaderClient.Sys().Rotate()
if err != nil {
t.Fatal(err)
}
@ -741,7 +741,7 @@ func TestRaft_SnapshotAPI_RekeyRotate_Backward(t *testing.T) {
// Write some data so we can make sure we can read it later. This is testing
// that we correctly reload the keyring
_, err = leaderClient.Logical().WriteWithContext(context.Background(), "secret/foo", map[string]interface{}{
_, err = leaderClient.Logical().Write("secret/foo", map[string]interface{}{
"test": "data",
})
if err != nil {
@ -756,7 +756,7 @@ func TestRaft_SnapshotAPI_RekeyRotate_Backward(t *testing.T) {
activeCore := testhelpers.DeriveStableActiveCore(t, cluster)
// Read the value.
data, err := activeCore.Client.Logical().ReadWithContext(context.Background(), "secret/foo")
data, err := activeCore.Client.Logical().Read("secret/foo")
if err != nil {
t.Fatal(err)
}
@ -847,7 +847,7 @@ func TestRaft_SnapshotAPI_RekeyRotate_Forward(t *testing.T) {
// Write a few keys
for i := 0; i < 10; i++ {
_, err := leaderClient.Logical().WriteWithContext(context.Background(), fmt.Sprintf("secret/%d", i), map[string]interface{}{
_, err := leaderClient.Logical().Write(fmt.Sprintf("secret/%d", i), map[string]interface{}{
"test": "data",
})
if err != nil {
@ -900,7 +900,7 @@ func TestRaft_SnapshotAPI_RekeyRotate_Forward(t *testing.T) {
}
// Rotate
err = leaderClient.Sys().RotateWithContext(context.Background())
err = leaderClient.Sys().Rotate()
if err != nil {
t.Fatal(err)
}
@ -998,7 +998,7 @@ func TestRaft_SnapshotAPI_RekeyRotate_Forward(t *testing.T) {
// Write some data so we can make sure we can read it later. This is testing
// that we correctly reload the keyring
_, err = leaderClient.Logical().WriteWithContext(context.Background(), "secret/foo", map[string]interface{}{
_, err = leaderClient.Logical().Write("secret/foo", map[string]interface{}{
"test": "data",
})
if err != nil {
@ -1013,7 +1013,7 @@ func TestRaft_SnapshotAPI_RekeyRotate_Forward(t *testing.T) {
activeCore := testhelpers.DeriveStableActiveCore(t, cluster)
// Read the value.
data, err := activeCore.Client.Logical().ReadWithContext(context.Background(), "secret/foo")
data, err := activeCore.Client.Logical().Read("secret/foo")
if err != nil {
t.Fatal(err)
}
@ -1034,7 +1034,7 @@ func TestRaft_SnapshotAPI_DifferentCluster(t *testing.T) {
// Write a few keys
for i := 0; i < 10; i++ {
_, err := leaderClient.Logical().WriteWithContext(context.Background(), fmt.Sprintf("secret/%d", i), map[string]interface{}{
_, err := leaderClient.Logical().Write(fmt.Sprintf("secret/%d", i), map[string]interface{}{
"test": "data",
})
if err != nil {
@ -1136,7 +1136,7 @@ func BenchmarkRaft_SingleNode(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
key := fmt.Sprintf("secret/%x", md5.Sum([]byte(fmt.Sprintf("%s-%d", testName, i))))
_, err := leaderClient.Logical().WriteWithContext(context.Background(), key, map[string]interface{}{
_, err := leaderClient.Logical().Write(key, map[string]interface{}{
"test": data,
})
if err != nil {
@ -1177,7 +1177,7 @@ func TestRaft_Join_InitStatus(t *testing.T) {
LeaderAPIAddr: leaderAPI,
LeaderCACert: string(cluster.CACertPEM),
}
resp, err := client.Sys().RaftJoinWithContext(context.Background(), req)
resp, err := client.Sys().RaftJoin(req)
if err != nil {
t.Fatal(err)
}
@ -1190,7 +1190,7 @@ func TestRaft_Join_InitStatus(t *testing.T) {
t.Helper()
client := cluster.Cores[coreIdx].Client
initialized, err := client.Sys().InitStatusWithContext(context.Background())
initialized, err := client.Sys().InitStatus()
if err != nil {
t.Fatal(err)
}
@ -1199,7 +1199,7 @@ func TestRaft_Join_InitStatus(t *testing.T) {
t.Errorf("core %d: expected init=%v, sys/init returned %v", coreIdx, expected, initialized)
}
status, err := client.Sys().SealStatusWithContext(context.Background())
status, err := client.Sys().SealStatus()
if err != nil {
t.Fatal(err)
}
@ -1208,7 +1208,7 @@ func TestRaft_Join_InitStatus(t *testing.T) {
t.Errorf("core %d: expected init=%v, sys/seal-status returned %v", coreIdx, expected, status.Initialized)
}
health, err := client.Sys().HealthWithContext(context.Background())
health, err := client.Sys().Health()
if err != nil {
t.Fatal(err)
}

View File

@ -1,7 +1,6 @@
package raftha
import (
"context"
"sync/atomic"
"testing"
@ -87,7 +86,7 @@ func testRaftHANewCluster(t *testing.T, bundler teststorage.PhysicalBackendBundl
req.LeaderClientCert = string(cluster.CACertPEM)
req.LeaderClientKey = string(cluster.CAKeyPEM)
}
resp, err := client.Sys().RaftJoinWithContext(context.Background(), req)
resp, err := client.Sys().RaftJoin(req)
if err != nil {
t.Fatal(err)
}
@ -108,14 +107,14 @@ func testRaftHANewCluster(t *testing.T, bundler teststorage.PhysicalBackendBundl
})
// Test remove peers
_, err := leaderClient.Logical().WriteWithContext(context.Background(), "sys/storage/raft/remove-peer", map[string]interface{}{
_, err := leaderClient.Logical().Write("sys/storage/raft/remove-peer", map[string]interface{}{
"server_id": "core-1",
})
if err != nil {
t.Fatal(err)
}
_, err = leaderClient.Logical().WriteWithContext(context.Background(), "sys/storage/raft/remove-peer", map[string]interface{}{
_, err = leaderClient.Logical().Write("sys/storage/raft/remove-peer", map[string]interface{}{
"server_id": "core-2",
})
if err != nil {
@ -203,7 +202,7 @@ func TestRaft_HA_ExistingCluster(t *testing.T) {
leaderClient := cluster.Cores[0].Client
leaderClient.SetToken(clusterRootToken)
{
_, err := leaderClient.Logical().WriteWithContext(context.Background(), "sys/storage/raft/bootstrap", nil)
_, err := leaderClient.Logical().Write("sys/storage/raft/bootstrap", nil)
if err != nil {
t.Fatal(err)
}
@ -221,7 +220,7 @@ func TestRaft_HA_ExistingCluster(t *testing.T) {
req := &api.RaftJoinRequest{
LeaderCACert: string(cluster.CACertPEM),
}
resp, err := client.Sys().RaftJoinWithContext(context.Background(), req)
resp, err := client.Sys().RaftJoin(req)
if err != nil {
t.Fatal(err)
}

View File

@ -108,7 +108,7 @@ func TestIdentityStore_EntityDisabled(t *testing.T) {
}
// Tune the mount
err = client.Sys().TuneMountWithContext(context.Background(), "auth/headtest", api.MountConfigInput{
err = client.Sys().TuneMount("auth/headtest", api.MountConfigInput{
AllowedResponseHeaders: []string{"WwW-AuthenTicate"},
})
if err != nil {

Some files were not shown because too many files have changed in this diff Show More