MCPcopy Create free account
hub / github.com/asternic/wuzapi / TestAdminUsersDelete

Function TestAdminUsersDelete

stdio_test.go:148–195  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

146}
147
148func TestAdminUsersDelete(t *testing.T) {
149 s := makeTestServer(t)
150
151 // First add a user
152 addRequest := newRequest("1", "admin.users.add", map[string]interface{}{
153 "adminToken": "test-admin-token",
154 "name": "Charlie",
155 "token": "charlie-token-789",
156 }).toJSON(t)
157 addResponse := executeRequest(t, s, addRequest)
158
159 addData := addResponse["result"].(map[string]interface{})
160 userId := addData["id"].(string)
161
162 // Delete the user
163 deleteRequest := newRequest("2", "admin.users.delete", map[string]interface{}{
164 "adminToken": "test-admin-token",
165 "userId": userId,
166 }).toJSON(t)
167 deleteResponse := executeRequest(t, s, deleteRequest)
168
169 expectedDelete := map[string]interface{}{
170 "jsonrpc": "2.0",
171 "id": "2",
172 }
173 if diff := compareJSON(expectedDelete, deleteResponse); diff != "" {
174 t.Errorf("Delete response mismatch:\n%s", diff)
175 }
176
177 // Verify user is gone by listing
178 listRequest := newRequest("3", "admin.users.list", map[string]interface{}{
179 "adminToken": "test-admin-token",
180 }).toJSON(t)
181 listResponse := executeRequest(t, s, listRequest)
182
183 expectedList := map[string]interface{}{
184 "jsonrpc": "2.0",
185 "id": "3",
186 }
187 if diff := compareJSON(expectedList, listResponse); diff != "" {
188 t.Errorf("List response mismatch:\n%s", diff)
189 }
190
191 users := listResponse["result"].([]interface{})
192 if len(users) != 0 {
193 t.Errorf("Expected 0 users after deletion, got %d", len(users))
194 }
195}
196
197func TestSessionStatus(t *testing.T) {
198 s := makeTestServer(t)

Callers

nothing calls this directly

Calls 5

makeTestServerFunction · 0.85
newRequestFunction · 0.85
executeRequestFunction · 0.85
compareJSONFunction · 0.85
toJSONMethod · 0.80

Tested by

no test coverage detected