OSDN Git Service

fix authn_test (#289)
author李永峰 <wliyongfeng@gmail.com>
Mon, 15 Jan 2018 11:43:34 +0000 (19:43 +0800)
committerPaladz <yzhu101@uottawa.ca>
Mon, 15 Jan 2018 11:43:34 +0000 (19:43 +0800)
net/http/authn/authn_test.go

index e0e7d72..1c28c26 100644 (file)
@@ -16,11 +16,10 @@ import (
 func TestAuthenticate(t *testing.T) {
        ctx := context.Background()
 
-       var token *string
        tokenDB := dbm.NewDB("testdb", "leveldb", "temp")
        defer os.RemoveAll("temp")
-       accessTokens := accesstoken.NewStore(tokenDB)
-       token, err := accessTokens.Create(ctx, "alice", "test")
+       tokenStore := accesstoken.NewStore(tokenDB)
+       token, err := tokenStore.Create(ctx, "alice", "test")
        if err != nil {
                t.Errorf("create token error")
        }
@@ -29,11 +28,11 @@ func TestAuthenticate(t *testing.T) {
                id, tok string
                want    error
        }{
-               {"alice", *token, nil},
+               {"alice", token.Token, nil},
                {"alice", "alice:abcsdsdfassdfsefsfsfesfesfefsefa", ErrInvalidToken},
        }
 
-       api := NewAPI(accessTokens)
+       api := NewAPI(tokenStore)
 
        for _, c := range cases {
                var username, password string