func TestBackendHandleRequest_renewAuth(t *testing.T) { b := &Backend{} resp, err := b.HandleRequest(logical.RenewAuthRequest( "/foo", &logical.Auth{}, nil)) if err != nil { t.Fatalf("err: %s", err) } if !resp.IsError() { t.Fatalf("bad: %#v", resp) } }
// renewAuthEntry is used to attempt renew of an auth entry func (m *ExpirationManager) renewAuthEntry(le *leaseEntry, increment time.Duration) (*logical.Response, error) { auth := *le.Auth auth.LeaseIssue = le.IssueTime auth.LeaseIncrement = increment auth.ClientToken = "" req := logical.RenewAuthRequest(le.Path, &auth, nil) resp, err := m.router.Route(req) if err != nil { return nil, fmt.Errorf("failed to renew entry: %v", err) } return resp, nil }
// renewAuthEntry is used to attempt renew of an auth entry. Only the token // store should get the actual token ID intact. func (m *ExpirationManager) renewAuthEntry(req *logical.Request, le *leaseEntry, increment time.Duration) (*logical.Response, error) { auth := *le.Auth auth.IssueTime = le.IssueTime auth.Increment = increment if strings.HasPrefix(le.Path, "auth/token/") { auth.ClientToken = le.ClientToken } else { auth.ClientToken = "" } authReq := logical.RenewAuthRequest(le.Path, &auth, nil) authReq.Connection = req.Connection resp, err := m.router.Route(authReq) if err != nil { return nil, fmt.Errorf("failed to renew entry: %v", err) } return resp, nil }
func TestBackendHandleRequest_renewAuthCallback(t *testing.T) { var called uint32 callback := func(*logical.Request, *FieldData) (*logical.Response, error) { atomic.AddUint32(&called, 1) return nil, nil } b := &Backend{ AuthRenew: callback, } _, err := b.HandleRequest(logical.RenewAuthRequest( "/foo", &logical.Auth{}, nil)) if err != nil { t.Fatalf("err: %s", err) } if v := atomic.LoadUint32(&called); v != 1 { t.Fatalf("bad: %#v", v) } }