authenticate: fix wrong condition checking in VerifySession (#1146)

The code checks session client not nil, but using databroker client in
the body instead.
This commit is contained in:
Cuong Manh Le 2020-07-28 21:18:39 +07:00 committed by GitHub
parent bec908b9af
commit fd544b7072
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 1 deletions

View file

@ -466,6 +466,25 @@ func TestAuthenticate_SessionValidatorMiddleware(t *testing.T) {
cookieCipher: aead,
encryptedEncoder: signer,
sharedEncoder: signer,
dataBrokerClient: mockDataBrokerServiceClient{
get: func(ctx context.Context, in *databroker.GetRequest, opts ...grpc.CallOption) (*databroker.GetResponse, error) {
data, err := ptypes.MarshalAny(&session.Session{
Id: "SESSION_ID",
})
if err != nil {
return nil, err
}
return &databroker.GetResponse{
Record: &databroker.Record{
Version: "0001",
Type: data.GetTypeUrl(),
Id: "SESSION_ID",
Data: data,
},
}, nil
},
},
}
r := httptest.NewRequest("GET", "/", nil)
state, err := tt.session.LoadSession(r)