loginServer should be a member of lockServer (#3441)

Add a unit test to catch a missing LoginHandler method in lockServer.
master
Krishnan Parthasarathi 8 years ago committed by Harshavardhana
parent f53fcdf10e
commit 29d72b84c0
  1. 2
      cmd/lock-rpc-server.go
  2. 30
      cmd/lock-rpc-server_test.go

@ -34,7 +34,6 @@ const lockCheckValidityInterval = 2 * time.Minute
// LockArgs besides lock name, holds Token and Timestamp for session
// authentication and validation server restart.
type LockArgs struct {
loginServer
Name string
Token string
Timestamp time.Time
@ -70,6 +69,7 @@ func isWriteLock(lri []lockRequesterInfo) bool {
// lockServer is type for RPC handlers
type lockServer struct {
loginServer
rpcPath string
mutex sync.Mutex
lockMap map[string][]lockRequesterInfo

@ -48,26 +48,20 @@ func createLockTestServer(t *testing.T) (string, *lockServer, string) {
t.Fatalf("unable initialize config file, %s", err)
}
jwt, err := newJWT(defaultJWTExpiry, serverConfig.GetCredential())
if err != nil {
t.Fatalf("unable to get new JWT, %s", err)
}
err = jwt.Authenticate(serverConfig.GetCredential().AccessKeyID, serverConfig.GetCredential().SecretAccessKey)
if err != nil {
t.Fatalf("unable for JWT to authenticate, %s", err)
}
token, err := jwt.GenerateToken(serverConfig.GetCredential().AccessKeyID)
if err != nil {
t.Fatalf("unable for JWT to generate token, %s", err)
}
locker := &lockServer{
rpcPath: "rpc-path",
mutex: sync.Mutex{},
lockMap: make(map[string][]lockRequesterInfo),
loginServer: loginServer{},
rpcPath: "rpc-path",
mutex: sync.Mutex{},
lockMap: make(map[string][]lockRequesterInfo),
}
creds := serverConfig.GetCredential()
loginArgs := RPCLoginArgs{Username: creds.AccessKeyID, Password: creds.SecretAccessKey}
loginReply := RPCLoginReply{}
err = locker.LoginHandler(&loginArgs, &loginReply)
if err != nil {
t.Fatalf("Failed to login to lock server - %v", err)
}
token := loginReply.Token
return testPath, locker, token
}

Loading…
Cancel
Save