Skip to content

Commit 39a9293

Browse files
committed
Use bearer token instead of password.
1 parent f60223e commit 39a9293

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

‎.github/workflows/integrationtest.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ jobs:
1616
- name: run tests
1717
env:
1818
TEST_USER: ${{ secrets.SUNSYNK_USERNAME }}
19-
TEST_PASSWORD: ${{ secrets.SUNSYNK_PASSWORD }}
19+
TEST_BEARER_TOKEN: ${{ secrets.SUNSYNK_BEARER_TOKEN }}
2020
TEST_INVERTER_SN: ${{ secrets.SUNSYNK_INVERTER_SN }}
2121
run: go test -v -count=1 -tags integration ./integration

‎configuration/configuration.go‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,22 @@ func ReadConfigurationFromFile(fileName string) (*Configuration, error) {
9090
return configuration, err
9191
}
9292

93-
// New constructs a configuration object with a specified username/password
93+
// New constructs a configuration object with a specified username/bearer token
9494
// combination using the default region 1 (London) endpoint
95-
func New(user string, password string) (*Configuration, error) {
95+
func New(user string, bearerToken string) (*Configuration, error) {
9696
if user == "" {
9797
return nil, errors.New("'user' cannot be empty")
9898
}
99-
if password == "" {
99+
if bearerToken == "" {
100100
return nil, errors.New("'password' cannot be empty")
101101
}
102-
return &Configuration{User: user, Password: password, Endpoint: DefaultEndpoint}, nil
102+
return &Configuration{User: user, Bearer: bearerToken, Endpoint: DefaultEndpoint}, nil
103103
}
104104

105-
// NewWithEndpoint constructs a configuration object with username/password credentials and an
105+
// NewWithEndpoint constructs a configuration object with username/bearer token credentials and an
106106
// overridden API endpoint
107-
func NewWithEndpoint(user string, password string, endpoint string) (*Configuration, error) {
108-
config, err := New(user, password)
107+
func NewWithEndpoint(user string, bearerToken string, endpoint string) (*Configuration, error) {
108+
config, err := New(user, bearerToken)
109109
if err != nil {
110110
return nil, err
111111
}

‎integration/integration_test.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ func getConfigFromVars() *configuration.Configuration {
3737
if username == "" {
3838
panic("the TEST_USER environment variable must be set")
3939
}
40-
password := os.Getenv("TEST_PASSWORD")
41-
if password == "" {
42-
panic("the TEST_PASSWORD environment variable must be set")
40+
bearerToken := os.Getenv("TEST_BEARER_TOKEN")
41+
if bearerToken == "" {
42+
panic("the TEST_BEARER_TOKEN environment variable must be set")
4343
}
44-
config, err := configuration.New(username, password)
44+
config, err := configuration.New(username, bearerToken)
4545
if err != nil {
4646
panic(err)
4747
}

0 commit comments

Comments
 (0)