Skip to content

Commit 68185fa

Browse files
fix: Correct tenant query test and request struct
- Updates the `TestQueryUsersWithTenant` to create a tenant-specific client and verify the request URL. - Corrects the `QueryUsersRequest` struct to use `string` for `Limit` and `Offset` fields, and adds the `TenantID` field. - Updates the test cases to reflect the struct changes.
1 parent b4dd686 commit 68185fa

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

auth/user_mgt_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,23 +2013,23 @@ func TestQueryUsersWithTenant(t *testing.T) {
20132013
s := echoServer([]byte(resp), t)
20142014
defer s.Close()
20152015

2016+
tenantClient, err := s.Client.TenantManager.AuthForTenant("test-tenant")
2017+
if err != nil {
2018+
t.Fatalf("Failed to create tenant client: %v", err)
2019+
}
2020+
20162021
query := &QueryUsersRequest{
20172022
ReturnUserInfo: true,
2018-
TenantID: "test-tenant",
20192023
}
20202024

2021-
_, err := s.Client.QueryUsers(context.Background(), query)
2025+
_, err = tenantClient.QueryUsers(context.Background(), query)
20222026
if err != nil {
2023-
t.Fatalf("QueryUsers() = %v", err)
2024-
}
2025-
2026-
var req map[string]interface{}
2027-
if err := json.Unmarshal(s.Rbody, &req); err != nil {
2028-
t.Fatal(err)
2027+
t.Fatalf("QueryUsers() with tenant client = %v", err)
20292028
}
20302029

2031-
if req["tenantId"] != "test-tenant" {
2032-
t.Errorf("QueryUsers() tenantId = %q; want = %q", req["tenantId"], "test-tenant")
2030+
wantPath := "/projects/mock-project-id/tenants/test-tenant/accounts:query"
2031+
if s.Req[0].RequestURI != wantPath {
2032+
t.Errorf("QueryUsers() URL = %q; want = %q", s.Req[0].RequestURI, wantPath)
20332033
}
20342034
}
20352035

0 commit comments

Comments
 (0)