@ -33,16 +33,19 @@ func testAdminCmd(cmd cmdType, t *testing.T) {
}
}
defer os . RemoveAll ( rootPath )
defer os . RemoveAll ( rootPath )
adminServer := adminCmd { }
creds := serverConfig . GetCredential ( )
creds := serverConfig . GetCredential ( )
token , err := authenticateNode ( creds . AccessKey , creds . SecretKey )
if err != nil {
t . Fatal ( err )
}
adminServer := adminCmd { }
args := LoginRPCArgs {
args := LoginRPCArgs {
Username : creds . AccessKey ,
AuthToken : token ,
Password : creds . SecretKey ,
Version : Version ,
Version : Version ,
RequestTime : UTCNow ( ) ,
RequestTime : UTCNow ( ) ,
}
}
reply := LoginRPCReply { }
err = adminServer . Login ( & args , & LoginRPCReply { } )
err = adminServer . Login ( & args , & reply )
if err != nil {
if err != nil {
t . Fatalf ( "Failed to login to admin server - %v" , err )
t . Fatalf ( "Failed to login to admin server - %v" , err )
}
}
@ -52,7 +55,7 @@ func testAdminCmd(cmd cmdType, t *testing.T) {
<- globalServiceSignalCh
<- globalServiceSignalCh
} ( )
} ( )
ga := AuthRPCArgs { AuthToken : reply . Au thT oken}
ga := AuthRPCArgs { AuthToken : token }
genReply := AuthRPCReply { }
genReply := AuthRPCReply { }
switch cmd {
switch cmd {
case restartCmd :
case restartCmd :
@ -91,21 +94,25 @@ func TestReInitDisks(t *testing.T) {
// Setup admin rpc server for an XL backend.
// Setup admin rpc server for an XL backend.
globalIsXL = true
globalIsXL = true
adminServer := adminCmd { }
adminServer := adminCmd { }
creds := serverConfig . GetCredential ( )
creds := serverConfig . GetCredential ( )
token , err := authenticateNode ( creds . AccessKey , creds . SecretKey )
if err != nil {
t . Fatal ( err )
}
args := LoginRPCArgs {
args := LoginRPCArgs {
Username : creds . AccessKey ,
AuthToken : token ,
Password : creds . SecretKey ,
Version : Version ,
Version : Version ,
RequestTime : UTCNow ( ) ,
RequestTime : UTCNow ( ) ,
}
}
reply := LoginRPCReply { }
err = adminServer . Login ( & args , & LoginRPCReply { } )
err = adminServer . Login ( & args , & reply )
if err != nil {
if err != nil {
t . Fatalf ( "Failed to login to admin server - %v" , err )
t . Fatalf ( "Failed to login to admin server - %v" , err )
}
}
authArgs := AuthRPCArgs {
authArgs := AuthRPCArgs {
AuthToken : reply . Au thT oken,
AuthToken : token ,
}
}
authReply := AuthRPCReply { }
authReply := AuthRPCReply { }
@ -114,12 +121,15 @@ func TestReInitDisks(t *testing.T) {
t . Errorf ( "Expected to pass, but failed with %v" , err )
t . Errorf ( "Expected to pass, but failed with %v" , err )
}
}
token , err = authenticateNode ( creds . AccessKey , creds . SecretKey )
if err != nil {
t . Fatal ( err )
}
// Negative test case with admin rpc server setup for FS.
// Negative test case with admin rpc server setup for FS.
globalIsXL = false
globalIsXL = false
fsAdminServer := adminCmd { }
fsAdminServer := adminCmd { }
fsArgs := LoginRPCArgs {
fsArgs := LoginRPCArgs {
Username : creds . AccessKey ,
AuthToken : token ,
Password : creds . SecretKey ,
Version : Version ,
Version : Version ,
RequestTime : UTCNow ( ) ,
RequestTime : UTCNow ( ) ,
}
}
@ -130,7 +140,7 @@ func TestReInitDisks(t *testing.T) {
}
}
authArgs = AuthRPCArgs {
authArgs = AuthRPCArgs {
AuthToken : fsReply . Au thT oken,
AuthToken : token ,
}
}
authReply = AuthRPCReply { }
authReply = AuthRPCReply { }
// Attempt ReInitDisks service on a FS backend.
// Attempt ReInitDisks service on a FS backend.
@ -154,9 +164,14 @@ func TestGetConfig(t *testing.T) {
adminServer := adminCmd { }
adminServer := adminCmd { }
creds := serverConfig . GetCredential ( )
creds := serverConfig . GetCredential ( )
token , err := authenticateNode ( creds . AccessKey , creds . SecretKey )
if err != nil {
t . Fatal ( err )
}
args := LoginRPCArgs {
args := LoginRPCArgs {
Username : creds . AccessKey ,
AuthToken : token ,
Password : creds . SecretKey ,
Version : Version ,
Version : Version ,
RequestTime : UTCNow ( ) ,
RequestTime : UTCNow ( ) ,
}
}
@ -167,7 +182,7 @@ func TestGetConfig(t *testing.T) {
}
}
authArgs := AuthRPCArgs {
authArgs := AuthRPCArgs {
AuthToken : reply . Au thT oken,
AuthToken : token ,
}
}
configReply := ConfigReply { }
configReply := ConfigReply { }
@ -198,9 +213,12 @@ func TestWriteAndCommitConfig(t *testing.T) {
adminServer := adminCmd { }
adminServer := adminCmd { }
creds := serverConfig . GetCredential ( )
creds := serverConfig . GetCredential ( )
token , err := authenticateNode ( creds . AccessKey , creds . SecretKey )
if err != nil {
t . Fatal ( err )
}
args := LoginRPCArgs {
args := LoginRPCArgs {
Username : creds . AccessKey ,
AuthToken : token ,
Password : creds . SecretKey ,
Version : Version ,
Version : Version ,
RequestTime : UTCNow ( ) ,
RequestTime : UTCNow ( ) ,
}
}
@ -215,7 +233,7 @@ func TestWriteAndCommitConfig(t *testing.T) {
tmpFileName := mustGetUUID ( )
tmpFileName := mustGetUUID ( )
wArgs := WriteConfigArgs {
wArgs := WriteConfigArgs {
AuthRPCArgs : AuthRPCArgs {
AuthRPCArgs : AuthRPCArgs {
AuthToken : reply . Au thT oken,
AuthToken : token ,
} ,
} ,
TmpFileName : tmpFileName ,
TmpFileName : tmpFileName ,
Buf : buf ,
Buf : buf ,
@ -232,7 +250,7 @@ func TestWriteAndCommitConfig(t *testing.T) {
cArgs := CommitConfigArgs {
cArgs := CommitConfigArgs {
AuthRPCArgs : AuthRPCArgs {
AuthRPCArgs : AuthRPCArgs {
AuthToken : reply . Au thT oken,
AuthToken : token ,
} ,
} ,
FileName : tmpFileName ,
FileName : tmpFileName ,
}
}