mirror of
https://github.com/minio/minio.git
synced 2025-01-23 20:53:18 -05:00
loginServer should be a member of lockServer (#3441)
Add a unit test to catch a missing LoginHandler method in lockServer.
This commit is contained in:
parent
f53fcdf10e
commit
29d72b84c0
@ -34,7 +34,6 @@ const lockCheckValidityInterval = 2 * time.Minute
|
|||||||
// LockArgs besides lock name, holds Token and Timestamp for session
|
// LockArgs besides lock name, holds Token and Timestamp for session
|
||||||
// authentication and validation server restart.
|
// authentication and validation server restart.
|
||||||
type LockArgs struct {
|
type LockArgs struct {
|
||||||
loginServer
|
|
||||||
Name string
|
Name string
|
||||||
Token string
|
Token string
|
||||||
Timestamp time.Time
|
Timestamp time.Time
|
||||||
@ -70,6 +69,7 @@ func isWriteLock(lri []lockRequesterInfo) bool {
|
|||||||
|
|
||||||
// lockServer is type for RPC handlers
|
// lockServer is type for RPC handlers
|
||||||
type lockServer struct {
|
type lockServer struct {
|
||||||
|
loginServer
|
||||||
rpcPath string
|
rpcPath string
|
||||||
mutex sync.Mutex
|
mutex sync.Mutex
|
||||||
lockMap map[string][]lockRequesterInfo
|
lockMap map[string][]lockRequesterInfo
|
||||||
|
@ -48,26 +48,20 @@ func createLockTestServer(t *testing.T) (string, *lockServer, string) {
|
|||||||
t.Fatalf("unable initialize config file, %s", err)
|
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{
|
locker := &lockServer{
|
||||||
|
loginServer: loginServer{},
|
||||||
rpcPath: "rpc-path",
|
rpcPath: "rpc-path",
|
||||||
mutex: sync.Mutex{},
|
mutex: sync.Mutex{},
|
||||||
lockMap: make(map[string][]lockRequesterInfo),
|
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
|
return testPath, locker, token
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user