Commit 4bf74d8a authored by rithu leena john's avatar rithu leena john Committed by GitHub

Merge pull request #862 from rithujohn191/update-api

api: Update timestamp type for RefreshTokenRef to int64.
parents 84af5273 921090f0
This diff is collapsed.
...@@ -105,8 +105,8 @@ message RefreshTokenRef { ...@@ -105,8 +105,8 @@ message RefreshTokenRef {
// ID of the refresh token. // ID of the refresh token.
string id = 1; string id = 1;
string client_id = 2; string client_id = 2;
string created_at = 3; int64 created_at = 5;
string last_used = 4; int64 last_used = 6;
} }
// ListRefreshReq is a request to enumerate the refresh tokens of a user. // ListRefreshReq is a request to enumerate the refresh tokens of a user.
......
...@@ -19,7 +19,7 @@ import ( ...@@ -19,7 +19,7 @@ import (
// apiVersion increases every time a new call is added to the API. Clients should use this info // apiVersion increases every time a new call is added to the API. Clients should use this info
// to determine if the server supports specific features. // to determine if the server supports specific features.
const apiVersion = 1 const apiVersion = 2
// NewAPI returns a server which implements the gRPC API interface. // NewAPI returns a server which implements the gRPC API interface.
func NewAPI(s storage.Storage, logger logrus.FieldLogger) api.DexServer { func NewAPI(s storage.Storage, logger logrus.FieldLogger) api.DexServer {
...@@ -226,8 +226,8 @@ func (d dexAPI) ListRefresh(ctx context.Context, req *api.ListRefreshReq) (*api. ...@@ -226,8 +226,8 @@ func (d dexAPI) ListRefresh(ctx context.Context, req *api.ListRefreshReq) (*api.
r := api.RefreshTokenRef{ r := api.RefreshTokenRef{
Id: session.ID, Id: session.ID,
ClientId: session.ClientID, ClientId: session.ClientID,
CreatedAt: session.CreatedAt.String(), CreatedAt: session.CreatedAt.Unix(),
LastUsed: session.LastUsed.String(), LastUsed: session.LastUsed.Unix(),
} }
refreshTokenRefs = append(refreshTokenRefs, &r) refreshTokenRefs = append(refreshTokenRefs, &r)
} }
......
...@@ -146,10 +146,21 @@ func TestRefreshToken(t *testing.T) { ...@@ -146,10 +146,21 @@ func TestRefreshToken(t *testing.T) {
UserId: subjectString, UserId: subjectString,
} }
if _, err := serv.ListRefresh(ctx, &listReq); err != nil { listResp, err := serv.ListRefresh(ctx, &listReq)
if err != nil {
t.Fatalf("Unable to list refresh tokens for user: %v", err) t.Fatalf("Unable to list refresh tokens for user: %v", err)
} }
for _, tok := range listResp.RefreshTokens {
if tok.CreatedAt != r.CreatedAt.Unix() {
t.Errorf("Expected CreatedAt timestamp %v, got %v", r.CreatedAt.Unix(), tok.CreatedAt)
}
if tok.LastUsed != r.LastUsed.Unix() {
t.Errorf("Expected LastUsed timestamp %v, got %v", r.LastUsed.Unix(), tok.LastUsed)
}
}
revokeReq := api.RevokeRefreshReq{ revokeReq := api.RevokeRefreshReq{
UserId: subjectString, UserId: subjectString,
ClientId: r.ClientID, ClientId: r.ClientID,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment