diff --git a/.github/workflows/test-zabbix.yml b/.github/workflows/test-zabbix.yml index 4649fe9..c197b1d 100644 --- a/.github/workflows/test-zabbix.yml +++ b/.github/workflows/test-zabbix.yml @@ -62,7 +62,7 @@ jobs: TEST_ZABBIX_PASSWORD: zabbix run: | while true ; do - output=$(curl -X POST -H 'Content-Type: application/json-rpc' -d '{"jsonrpc":"2.0","method":"user.login","params":{"user":"'$TEST_ZABBIX_USER'","password":"'$TEST_ZABBIX_PASSWORD'"},"id":1,"auth":null}' $TEST_ZABBIX_URL || echo error) + output=$(curl -X POST -H 'Content-Type: application/json-rpc' -d '{"jsonrpc":"2.0","method":"user.login","params":{"username":"'$TEST_ZABBIX_USER'","password":"'$TEST_ZABBIX_PASSWORD'"},"id":1,"auth":null}' $TEST_ZABBIX_URL || echo error) echo $output echo $output | grep -v error > /dev/null && break echo "Waiting 5s for Zabbix Server to be ready..." diff --git a/base.go b/base.go index dd5cd6c..8802de5 100644 --- a/base.go +++ b/base.go @@ -166,8 +166,8 @@ func (api *API) CallWithErrorParse(method string, params interface{}, result int // Login Calls "user.login" API method and fills api.Auth field. // This method modifies API structure and should not be called concurrently with other methods. -func (api *API) Login(user, password string) (auth string, err error) { - params := map[string]string{"user": user, "password": password} +func (api *API) Login(username, password string) (auth string, err error) { + params := map[string]string{"username": username, "password": password} response, err := api.CallWithError("user.login", params) if err != nil { return diff --git a/base_test.go b/base_test.go index 0d59773..6c25e87 100644 --- a/base_test.go +++ b/base_test.go @@ -42,7 +42,7 @@ func testGetAPI(t *testing.T) *zapi.API { return _api } - url, user, password := os.Getenv("TEST_ZABBIX_URL"), os.Getenv("TEST_ZABBIX_USER"), os.Getenv("TEST_ZABBIX_PASSWORD") + url, username, password := os.Getenv("TEST_ZABBIX_URL"), os.Getenv("TEST_ZABBIX_USER"), os.Getenv("TEST_ZABBIX_PASSWORD") _api = zapi.NewAPI(url) _api.SetClient(http.DefaultClient) v := os.Getenv("TEST_ZABBIX_VERBOSE") @@ -50,8 +50,8 @@ func testGetAPI(t *testing.T) *zapi.API { _api.Logger = log.New(os.Stderr, "[zabbix] ", 0) } - if user != "" { - auth, err := _api.Login(user, password) + if username != "" { + auth, err := _api.Login(username, password) if err != nil { t.Fatal(err) } diff --git a/tests.sh b/tests.sh index fa4636c..8681e49 100644 --- a/tests.sh +++ b/tests.sh @@ -11,7 +11,7 @@ if ! [[ "$ZABBIX_VERSION" == "$TEST_ZABBIX_VERSION"* ]]; then fi # Check login -ZABBIX_TOKEN=$(curl -s -X POST -H 'Content-Type: application/json-rpc' -d "{\"jsonrpc\":\"2.0\",\"method\":\"user.login\",\"id\":1,\"params\":{\"user\":\"$TEST_ZABBIX_USER\",\"password\":\"$TEST_ZABBIX_PASSWORD\"}}" "$TEST_ZABBIX_URL" | jq -c -r .result) +ZABBIX_TOKEN=$(curl -s -X POST -H 'Content-Type: application/json-rpc' -d "{\"jsonrpc\":\"2.0\",\"method\":\"user.login\",\"id\":1,\"params\":{\"username\":\"$TEST_ZABBIX_USER\",\"password\":\"$TEST_ZABBIX_PASSWORD\"}}" "$TEST_ZABBIX_URL" | jq -c -r .result) if [[ "$ZABBIX_VERSION" == "null" ]]; then echo "Zabbix login failed" exit 2