Skip to content

Add test related to creating group with sample attributes - #40558

Merged
edewit merged 5 commits into
keycloak:mainfrom
shuji-oh:16947-add_example_creating_group_with_attributes
Aug 12, 2026
Merged

Add test related to creating group with sample attributes#40558
edewit merged 5 commits into
keycloak:mainfrom
shuji-oh:16947-add_example_creating_group_with_attributes

Conversation

@shuji-oh

@shuji-oh shuji-oh commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

This PR adds a test case for creating a group with attributes to illustrate proper usage of the API.

The added test covers a group with sample attributes such as accessLevel and project.

Closes #16947

Local test results:

  Groups
    ✔ create group with attributes
    ✔ list groups
    ✔ count groups
    ✔ count groups with filter
    ✔ get single groups
    ✔ update single groups (40ms)
    1) list subgroups
    role-mappings
      ✔ add a role to group
      ✔ list available role-mappings
      ✔ list role-mappings
      ✔ list realm role-mappings of group
      ✔ list realm composite role-mappings of group
      ✔ del realm role-mappings from group
    client role-mappings
      ✔ add a client role to group
      ✔ list available client role-mappings for group
      ✔ list client role-mappings of group
      ✔ list composite client role-mappings for group
      ✔ del client role-mappings from group (39ms)

@shuji-oh
shuji-oh requested a review from a team as a code owner June 17, 2025 17:17
@shuji-oh shuji-oh changed the title add test related to creating group with sample attributes Add test related to creating group with sample attributes Jun 17, 2025
Signed-off-by: shuji-oh <syuji0116@gmail.com>
@edewit
edewit enabled auto-merge (squash) July 23, 2026 08:43
@shuji-oh
shuji-oh requested a review from a team as a code owner July 24, 2026 07:12
Copilot AI balanced review requested due to automatic review settings July 24, 2026 11:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an admin-client test demonstrating group creation with attributes.

Changes:

  • Creates a group with sample attributes.
  • Updates the expected group count.

Comment thread js/libs/keycloak-admin-client/test/groups.spec.ts
Comment thread js/libs/keycloak-admin-client/test/groups.spec.ts
Copilot AI review requested due to automatic review settings July 30, 2026 12:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

js/libs/keycloak-admin-client/test/groups.spec.ts:50

  • The assertion only verifies the existing create API behavior and does not prove that attributes were serialized and persisted. Fetch the created group and assert both attribute arrays so a regression that silently drops attributes fails this test.
    expect(group.id).to.be.ok;

js/libs/keycloak-admin-client/test/groups.spec.ts:49

  • This new top-level group is never removed: the suite teardown only deletes currentGroup, so basic-group remains in the shared realm and can affect later suites. Retain this group's ID and delete it in the after hook as well.
    const group = await kcAdminClient.groups.create({
      name: "basic-group",
      attributes: {
        accessLevel: ["internal"],
        project: ["alpha"],
      },
    });

Copilot AI review requested due to automatic review settings August 11, 2026 22:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (2)

js/libs/keycloak-admin-client/test/groups.spec.ts:49

  • The new basic-group is never deleted because the suite's after hook only removes currentGroup. This leaks state from the suite and makes repeated or filtered runs susceptible to stale groups and incorrect counts; delete this group after its assertions or track it for cleanup in the hook.
    const group = await kcAdminClient.groups.create({
      name: "basic-group",
      attributes: {
        accessLevel: ["internal"],
        project: ["alpha"],
      },
    });

js/libs/keycloak-admin-client/test/groups.spec.ts:50

  • This test only verifies that some group was created, so it still passes if the client or server silently drops attributes. Read the group back by ID and assert that both attribute arrays were persisted.
    expect(group.id).to.be.ok;

@edewit
edewit merged commit 553c539 into keycloak:main Aug 12, 2026
70 checks passed
ruchikajha95 pushed a commit to ruchikajha95/keycloak that referenced this pull request Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

group.spec.ts does not contain example of how to add attributes while creating groups

4 participants