mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-28 10:01:11 +02:00
fix expiration tests
This commit is contained in:
parent
97f23fe941
commit
af12d056ba
@ -285,7 +285,10 @@ func benchmarkExpirationBackend(b *testing.B, physicalBackend physical.Backend,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
exp.router.Mount(noop, "prod/aws/", &MountEntry{UUID: meUUID}, view)
|
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor"}, view)
|
||||||
|
if err != nil {
|
||||||
|
b.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
// Register fake leases
|
// Register fake leases
|
||||||
for i := 0; i < numLeases; i++ {
|
for i := 0; i < numLeases; i++ {
|
||||||
@ -341,7 +344,10 @@ func TestExpiration_Restore(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
exp.router.Mount(noop, "prod/aws/", &MountEntry{UUID: meUUID}, view)
|
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor"}, view)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
paths := []string{
|
paths := []string{
|
||||||
"prod/aws/foo",
|
"prod/aws/foo",
|
||||||
@ -508,7 +514,10 @@ func TestExpiration_Revoke(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
exp.router.Mount(noop, "prod/aws/", &MountEntry{UUID: meUUID}, view)
|
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor"}, view)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
req := &logical.Request{
|
req := &logical.Request{
|
||||||
Operation: logical.ReadOperation,
|
Operation: logical.ReadOperation,
|
||||||
@ -551,7 +560,10 @@ func TestExpiration_RevokeOnExpire(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
exp.router.Mount(noop, "prod/aws/", &MountEntry{UUID: meUUID}, view)
|
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor"}, view)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
req := &logical.Request{
|
req := &logical.Request{
|
||||||
Operation: logical.ReadOperation,
|
Operation: logical.ReadOperation,
|
||||||
@ -605,7 +617,10 @@ func TestExpiration_RevokePrefix(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
exp.router.Mount(noop, "prod/aws/", &MountEntry{UUID: meUUID}, view)
|
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor"}, view)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
paths := []string{
|
paths := []string{
|
||||||
"prod/aws/foo",
|
"prod/aws/foo",
|
||||||
@ -670,7 +685,10 @@ func TestExpiration_RevokeByToken(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
exp.router.Mount(noop, "prod/aws/", &MountEntry{UUID: meUUID}, view)
|
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor"}, view)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
paths := []string{
|
paths := []string{
|
||||||
"prod/aws/foo",
|
"prod/aws/foo",
|
||||||
@ -800,7 +818,10 @@ func TestExpiration_Renew(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
exp.router.Mount(noop, "prod/aws/", &MountEntry{UUID: meUUID}, view)
|
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor"}, view)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
req := &logical.Request{
|
req := &logical.Request{
|
||||||
Operation: logical.ReadOperation,
|
Operation: logical.ReadOperation,
|
||||||
@ -867,7 +888,10 @@ func TestExpiration_Renew_NotRenewable(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
exp.router.Mount(noop, "prod/aws/", &MountEntry{UUID: meUUID}, view)
|
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor"}, view)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
req := &logical.Request{
|
req := &logical.Request{
|
||||||
Operation: logical.ReadOperation,
|
Operation: logical.ReadOperation,
|
||||||
@ -914,7 +938,10 @@ func TestExpiration_Renew_RevokeOnExpire(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
exp.router.Mount(noop, "prod/aws/", &MountEntry{UUID: meUUID}, view)
|
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor"}, view)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
req := &logical.Request{
|
req := &logical.Request{
|
||||||
Operation: logical.ReadOperation,
|
Operation: logical.ReadOperation,
|
||||||
@ -987,7 +1014,10 @@ func TestExpiration_revokeEntry(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
exp.router.Mount(noop, "", &MountEntry{UUID: meUUID}, view)
|
err = exp.router.Mount(noop, "foo/bar/", &MountEntry{Path: "foo/bar/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor"}, view)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
le := &leaseEntry{
|
le := &leaseEntry{
|
||||||
LeaseID: "foo/bar/1234",
|
LeaseID: "foo/bar/1234",
|
||||||
@ -1014,13 +1044,10 @@ func TestExpiration_revokeEntry(t *testing.T) {
|
|||||||
|
|
||||||
req := noop.Requests[0]
|
req := noop.Requests[0]
|
||||||
if req.Operation != logical.RevokeOperation {
|
if req.Operation != logical.RevokeOperation {
|
||||||
t.Fatalf("Bad: %v", req)
|
t.Fatalf("bad: operation; req: %#v", req)
|
||||||
}
|
|
||||||
if req.Path != le.Path {
|
|
||||||
t.Fatalf("Bad: %v", req)
|
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(req.Data, le.Data) {
|
if !reflect.DeepEqual(req.Data, le.Data) {
|
||||||
t.Fatalf("Bad: %v", req)
|
t.Fatalf("bad: data; req: %#v\n le: %#v\n", req, le)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1118,7 +1145,10 @@ func TestExpiration_renewEntry(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
exp.router.Mount(noop, "", &MountEntry{UUID: meUUID}, view)
|
err = exp.router.Mount(noop, "foo/bar/", &MountEntry{Path: "foo/bar/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor"}, view)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
le := &leaseEntry{
|
le := &leaseEntry{
|
||||||
LeaseID: "foo/bar/1234",
|
LeaseID: "foo/bar/1234",
|
||||||
@ -1151,9 +1181,6 @@ func TestExpiration_renewEntry(t *testing.T) {
|
|||||||
if req.Operation != logical.RenewOperation {
|
if req.Operation != logical.RenewOperation {
|
||||||
t.Fatalf("Bad: %v", req)
|
t.Fatalf("Bad: %v", req)
|
||||||
}
|
}
|
||||||
if req.Path != le.Path {
|
|
||||||
t.Fatalf("Bad: %v", req)
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(req.Data, le.Data) {
|
if !reflect.DeepEqual(req.Data, le.Data) {
|
||||||
t.Fatalf("Bad: %v", req)
|
t.Fatalf("Bad: %v", req)
|
||||||
}
|
}
|
||||||
@ -1184,7 +1211,10 @@ func TestExpiration_renewAuthEntry(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
exp.router.Mount(noop, "auth/foo/", &MountEntry{UUID: meUUID}, view)
|
err = exp.router.Mount(noop, "auth/foo/", &MountEntry{Path: "auth/foo/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor"}, view)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
le := &leaseEntry{
|
le := &leaseEntry{
|
||||||
LeaseID: "auth/foo/1234",
|
LeaseID: "auth/foo/1234",
|
||||||
@ -1355,6 +1385,7 @@ func TestExpiration_RevokeForce(t *testing.T) {
|
|||||||
Table: mountTableType,
|
Table: mountTableType,
|
||||||
Path: "badrenew/",
|
Path: "badrenew/",
|
||||||
Type: "badrenew",
|
Type: "badrenew",
|
||||||
|
Accessor: "badrenewaccessor",
|
||||||
}
|
}
|
||||||
|
|
||||||
err := core.mount(me)
|
err := core.mount(me)
|
||||||
|
@ -29,7 +29,7 @@ func mockRollback(t *testing.T) (*RollbackManager, *NoopBackend) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := router.Mount(backend, "foo", &MountEntry{UUID: meUUID}, view); err != nil {
|
if err := router.Mount(backend, "foo", &MountEntry{UUID: meUUID, Accessor: "noopaccessor"}, view); err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,7 +255,10 @@ func testTokenStore(t testing.TB, c *Core) *TokenStore {
|
|||||||
ts := tokenstore.(*TokenStore)
|
ts := tokenstore.(*TokenStore)
|
||||||
|
|
||||||
router := NewRouter()
|
router := NewRouter()
|
||||||
router.Mount(ts, "auth/token/", &MountEntry{Table: credentialTableType, UUID: ""}, ts.view)
|
err = router.Mount(ts, "auth/token/", &MountEntry{Table: credentialTableType, UUID: "authtokenuuid", Path: "auth/token", Accessor: "authtokenaccessor"}, ts.view)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
subview := c.systemBarrierView.SubView(expirationSubPath)
|
subview := c.systemBarrierView.SubView(expirationSubPath)
|
||||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user