Slamet Hendry 4e73cb07a0 All tests passed. Initial commit.
Change-Id: I0934876e3647659f1b527b93c330292bb139fcd6
2013-07-14 21:12:30 +07:00

34 lines
910 B
Go

package identitytest
import (
"encoding/json"
"io/ioutil"
)
//SetupUser() is used to retrieve externally stored testing credentials.
//The testing credentials are stored outside
//the source code so they do not get checked in, assuming the user.json is
//in .gitignore / .hgignore. "user.json" should contain the following where
//... is the actual value from the test user account credentials.
//{
// "TenantId":"...",
// "TenantName": "...",
// "AccessKey": "...",
// "SecretKey": "...",
// "UserName": "...",
// "Password": "...",
// "Host": "https://.../v2.0/tokens"
//}
func SetupUser(jsonFile string) (acct struct {
TenantId, TenantName, AccessKey, SecretKey, UserName, Password, Host string
},) {
usrJson, err := ioutil.ReadFile(jsonFile)
if err != nil {
panic("ReadFile json failed")
}
if err = json.Unmarshal(usrJson, &acct); err != nil {
panic("Unmarshal json failed")
}
return acct
}