feat: add hosts management

This commit is contained in:
2024-11-09 10:33:07 +00:00
parent 31c43836f4
commit d931235fb3
27 changed files with 742 additions and 94 deletions
+30 -1
View File
@@ -21,7 +21,7 @@ func TestHostsCreate(t *testing.T) {
test := NewTestWithAuth(t)
data := map[string]interface{}{
"type": "pve",
"type": "ssh",
"label": "test ssh",
"host": "10.0.0.102",
"port": 22,
@@ -72,3 +72,32 @@ func TestHostsCreate(t *testing.T) {
assert.Equal(t, http.StatusCreated, status)
assert.NotNil(t, res["id"])
}
func TestHostsUpdate(t *testing.T) {
test := NewTestWithAuth(t)
id := "01jc3v9w609f8e2wzw60amv195"
data := map[string]interface{}{
"type": "ssh",
"label": "test ssh update",
"host": "10.0.0.102",
"port": 22,
"keyId": "01jc3wkctzqrcz8qhwynr4p9pe",
}
res, status, err := test.Fetch("PUT", "/hosts/"+id, &FetchOptions{Body: data})
assert.NoError(t, err)
assert.Equal(t, http.StatusOK, status)
assert.NotNil(t, res["id"])
}
func TestHostsDelete(t *testing.T) {
test := NewTestWithAuth(t)
id := "01jc3v9w609f8e2wzw60amv195"
_, status, err := test.Fetch("DELETE", "/hosts/"+id, nil)
assert.NoError(t, err)
assert.Equal(t, http.StatusOK, status)
}