fix: moved authenticated requests to helper
Some checks failed
CI / build (push) Failing after 3m19s
CI / lint (push) Failing after 2m50s
CI / pkl-validate (push) Successful in 10s
CI / integration-tests (push) Has been skipped
CI / conformance-tests (latest) (push) Has been skipped

This commit is contained in:
2026-02-03 22:44:23 +01:00
parent ca99733c9c
commit 35a789d5d9
3 changed files with 38 additions and 94 deletions

View File

@@ -3,7 +3,6 @@ package main
import (
"context"
"encoding/json"
"io"
"log"
"net/http"
"strconv"
@@ -55,20 +54,9 @@ func TestCreate(t *testing.T) {
require.NotNil(t, result.ProgressResult, "Create should return ProgressResult")
require.Eventually(t, func() bool {
client := &http.Client{}
var props StatusGeneralResponse
request, err := http.NewRequest("GET", config.URL+"/api2/json/nodes/"+config.NODE+"/lxc", nil)
if err != nil {
t.Logf("Something unexpected happened")
return false
}
request.Header.Set("Authorization", "PVEAPIToken="+username+"="+token)
resp, err := client.Do(request)
data, err := io.ReadAll(resp.Body)
data, _ := authenticatedRequest(http.MethodGet, config.URL+"/api2/json/nodes/"+config.NODE+"/lxc", createAuthorizationString(username, token), nil)
json.Unmarshal(data, &props)
@@ -206,20 +194,9 @@ func TestDelete(t *testing.T) {
require.NotNil(t, result.ProgressResult, "Create should return ProgressResult")
require.Eventually(t, func() bool {
client := &http.Client{}
var props StatusGeneralResponse
request, err := http.NewRequest("GET", config.URL+"/api2/json/nodes/"+config.NODE+"/lxc", nil)
if err != nil {
t.Logf("Something unexpected happened")
return false
}
request.Header.Set("Authorization", "PVEAPIToken="+username+"="+token)
resp, err := client.Do(request)
data, err := io.ReadAll(resp.Body)
data, _ := authenticatedRequest(http.MethodGet, config.URL+"/api2/json/nodes/"+config.NODE+"/lxc", createAuthorizationString(username, token), nil)
json.Unmarshal(data, &props)