(t *testing.T)
| 92 | } |
| 93 | |
| 94 | func TestAdminUsersGet(t *testing.T) { |
| 95 | s := makeTestServer(t) |
| 96 | |
| 97 | // First add a user |
| 98 | addRequest := newRequest("1", "admin.users.add", map[string]interface{}{ |
| 99 | "adminToken": "test-admin-token", |
| 100 | "name": "Bob", |
| 101 | "token": "bob-token-456", |
| 102 | }).toJSON(t) |
| 103 | addResponse := executeRequest(t, s, addRequest) |
| 104 | |
| 105 | expectedAdd := map[string]interface{}{ |
| 106 | "jsonrpc": "2.0", |
| 107 | "id": "1", |
| 108 | } |
| 109 | if diff := compareJSON(expectedAdd, addResponse); diff != "" { |
| 110 | t.Errorf("Add response mismatch:\n%s", diff) |
| 111 | } |
| 112 | |
| 113 | // Extract the userId from the add response |
| 114 | addData := addResponse["result"].(map[string]interface{}) |
| 115 | userId := addData["id"].(string) |
| 116 | |
| 117 | // Now get the specific user |
| 118 | getRequest := newRequest("2", "admin.users.get", map[string]interface{}{ |
| 119 | "adminToken": "test-admin-token", |
| 120 | "userId": userId, |
| 121 | }).toJSON(t) |
| 122 | getResponse := executeRequest(t, s, getRequest) |
| 123 | |
| 124 | expectedGet := map[string]interface{}{ |
| 125 | "jsonrpc": "2.0", |
| 126 | "id": "2", |
| 127 | } |
| 128 | if diff := compareJSON(expectedGet, getResponse); diff != "" { |
| 129 | t.Errorf("Get response mismatch:\n%s", diff) |
| 130 | } |
| 131 | |
| 132 | // Verify the user data |
| 133 | users := getResponse["result"].([]interface{}) |
| 134 | if len(users) != 1 { |
| 135 | t.Fatalf("Expected 1 user, got %d", len(users)) |
| 136 | } |
| 137 | |
| 138 | user := users[0].(map[string]interface{}) |
| 139 | expectedUser := map[string]interface{}{ |
| 140 | "name": "Bob", |
| 141 | "token": "bob-token-456", |
| 142 | } |
| 143 | if diff := compareJSON(expectedUser, user); diff != "" { |
| 144 | t.Errorf("User data mismatch:\n%s", diff) |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | func TestAdminUsersDelete(t *testing.T) { |
| 149 | s := makeTestServer(t) |
nothing calls this directly
no test coverage detected