Skip to content

Commit 8e22b9f

Browse files
author
Sam Stenvall
committed
Don't expose the client's username and password (mentioned in #25)
The setters were never used and the getter was only used in an integration test, which could be modified to not require it.
1 parent 321a140 commit 8e22b9f

2 files changed

Lines changed: 5 additions & 20 deletions

File tree

upcloud/client/client.go

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,16 @@ type Client struct {
3434
func New(userName, password string) *Client {
3535
client := Client{}
3636

37-
client.SetUserName(userName)
38-
client.SetPassword(password)
37+
client.userName = userName
38+
client.password = password
3939
client.httpClient = cleanhttp.DefaultClient()
4040
client.SetTimeout(time.Second * DEFAULT_TIMEOUT)
41-
4241
client.SetAPIVersion(DEFAULT_API_VERSION)
4342
client.SetAPIBaseUrl(DEFAULT_API_BASEURL)
4443

4544
return &client
4645
}
4746

48-
// GetUserName returns the user name the client uses
49-
func (c *Client) GetUserName() string {
50-
return c.userName
51-
}
52-
53-
// SetUserName sets the client user to the specified user
54-
func (c *Client) SetUserName(userName string) {
55-
c.userName = userName
56-
}
57-
58-
// SetPassword sets the client password to the specified password
59-
func (c *Client) SetPassword(password string) {
60-
c.password = password
61-
}
62-
6347
// SetTimeout sets the client timeout to the specified amount of seconds
6448
func (c *Client) SetTimeout(timeout time.Duration) {
6549
c.httpClient.Timeout = timeout

upcloud/service/service_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,11 @@ func teardown() {
9797
// TestGetAccount tests that the GetAccount() method returns proper data
9898
func TestGetAccount(t *testing.T) {
9999
account, err := svc.GetAccount()
100+
username, _ := getCredentials()
100101
handleError(err)
101102

102-
if account.UserName != svc.client.GetUserName() {
103-
t.Errorf("TestGetAccoun expected %s, got %s", svc.client.GetUserName(), account.UserName)
103+
if account.UserName != username {
104+
t.Errorf("TestGetAccount expected %s, got %s", username, account.UserName)
104105
}
105106
}
106107

0 commit comments

Comments
 (0)