Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token revocation refactor #4512

Merged
merged 17 commits into from
May 10, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add HandlerFunc on NoopBackend, adjust locks, and add test
  • Loading branch information
calvn committed May 5, 2018
commit 80247263936ecb9988c5fc3bd77f6117f05effd3
7 changes: 4 additions & 3 deletions vault/expiration_test.go
Original file line number Diff line number Diff line change
@@ -773,7 +773,7 @@ func TestExpiration_RevokeByToken_Blocking(t *testing.T) {
noop := &NoopBackend{}
// Request handle with a timeout context that simulates blocking lease revocation.
noop.RequestHandler = func(ctx context.Context, req *logical.Request) (*logical.Response, error) {
ctx, cancel := context.WithTimeout(ctx, 3*time.Second)
ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
defer cancel()

select {
@@ -836,8 +836,9 @@ func TestExpiration_RevokeByToken_Blocking(t *testing.T) {
}
noop.Unlock()

// Wait for some time, and relock
time.Sleep(3 * time.Second)
// Wait for a bit for timeouts to trigger and pending revocations to go
// through and then we relock
time.Sleep(200 * time.Millisecond)

noop.Lock()
defer noop.Unlock()
6 changes: 3 additions & 3 deletions vault/router_test.go
Original file line number Diff line number Diff line change
@@ -31,15 +31,15 @@ type NoopBackend struct {
}

func (n *NoopBackend) HandleRequest(ctx context.Context, req *logical.Request) (*logical.Response, error) {
n.Lock()
defer n.Unlock()

var err error
resp := n.Response
if n.RequestHandler != nil {
resp, err = n.RequestHandler(ctx, req)
}

n.Lock()
defer n.Unlock()

requestCopy := *req
n.Paths = append(n.Paths, req.Path)
n.Requests = append(n.Requests, &requestCopy)