mirror of
https://github.com/khairul169/vaulterm.git
synced 2026-09-15 17:03:30 +07:00
feat: add hosts management
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user