logical/consul: actual test that the token works
This commit is contained in:
parent
55a3423c60
commit
3270349456
|
@ -10,6 +10,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/hashicorp/consul/api"
|
||||||
"github.com/hashicorp/vault/logical"
|
"github.com/hashicorp/vault/logical"
|
||||||
logicaltest "github.com/hashicorp/vault/logical/testing"
|
logicaltest "github.com/hashicorp/vault/logical/testing"
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
|
@ -25,7 +26,7 @@ func TestBackend_basic(t *testing.T) {
|
||||||
Steps: []logicaltest.TestStep{
|
Steps: []logicaltest.TestStep{
|
||||||
testAccStepConfig(t, config),
|
testAccStepConfig(t, config),
|
||||||
testAccStepWritePolicy(t, "test", testPolicy),
|
testAccStepWritePolicy(t, "test", testPolicy),
|
||||||
testAccStepReadToken(t, "test"),
|
testAccStepReadToken(t, "test", config),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -84,7 +85,8 @@ func testAccStepConfig(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccStepReadToken(t *testing.T, name string) logicaltest.TestStep {
|
func testAccStepReadToken(
|
||||||
|
t *testing.T, name string, conf map[string]interface{}) logicaltest.TestStep {
|
||||||
return logicaltest.TestStep{
|
return logicaltest.TestStep{
|
||||||
Operation: logical.ReadOperation,
|
Operation: logical.ReadOperation,
|
||||||
Path: name,
|
Path: name,
|
||||||
|
@ -97,17 +99,23 @@ func testAccStepReadToken(t *testing.T, name string) logicaltest.TestStep {
|
||||||
}
|
}
|
||||||
log.Printf("[WARN] Generated token: %s", d.Token)
|
log.Printf("[WARN] Generated token: %s", d.Token)
|
||||||
|
|
||||||
/*
|
|
||||||
// Build a client and verify that the credentials work
|
// Build a client and verify that the credentials work
|
||||||
creds := aws.Creds(d.AccessKey, d.SecretKey, "")
|
config := api.DefaultConfig()
|
||||||
client := ec2.New(creds, "us-east-1", nil)
|
config.Address = conf["address"].(string)
|
||||||
|
config.Token = d.Token
|
||||||
log.Printf("[WARN] Verifying that the generated credentials work...")
|
client, err := api.NewClient(config)
|
||||||
_, err := client.DescribeInstances(&ec2.DescribeInstancesRequest{})
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("[WARN] Verifying that the generated token works...")
|
||||||
|
_, err = client.KV().Put(&api.KVPair{
|
||||||
|
Key: "foo",
|
||||||
|
Value: []byte("bar"),
|
||||||
|
}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue