1
0
Fork 0
mirror of synced 2024-07-04 22:11:23 +12:00

Test filtering by user name

This commit is contained in:
adrinr 2023-03-15 20:48:34 +01:00
parent a91e4b4da1
commit ad2a23d113
5 changed files with 38 additions and 2 deletions

View file

@ -54,7 +54,7 @@ export interface User extends Document {
userGroups?: string[]
onboardedAt?: string
scimInfo?: {
username: string
userName: string
externalId: string
isSync: boolean
firstSync: number

View file

@ -79,6 +79,7 @@
"@types/jsonwebtoken": "8.5.1",
"@types/koa": "2.13.4",
"@types/koa__router": "8.0.8",
"@types/lodash": "^4.14.191",
"@types/node": "14.18.20",
"@types/node-fetch": "2.6.1",
"@types/pouchdb": "6.4.0",
@ -89,6 +90,7 @@
"copyfiles": "2.4.1",
"eslint": "6.8.0",
"jest": "28.1.1",
"lodash": "4.17.21",
"nodemon": "2.0.15",
"pouchdb-adapter-memory": "7.2.2",
"prettier": "2.3.1",

View file

@ -1,4 +1,5 @@
import tk from "timekeeper"
import _ from "lodash"
import { mocks, structures } from "@budibase/backend-core/tests"
import {
ScimCreateUserRequest,
@ -7,6 +8,8 @@ import {
} from "@budibase/types"
import { TestConfiguration } from "../../../../../tests"
mocks.licenses.useScimIntegration()
function createScimCreateUserRequest(userData?: {
externalId?: string
email?: string
@ -152,6 +155,25 @@ describe("/api/global/scim/v2/users", () => {
totalResults: userCount,
})
})
it("can filter by user name", async () => {
// '/api/global/scim/v2/Users?filter=userName+eq+%2212e18327-eee2-4a12-961e-bceff00f6b92%22'
const userToFetch = _.sample(users)
const response = await getScimUsers({
params: {
filter: `userName+eq+%22${userToFetch?.userName}%22`,
},
})
expect(response).toEqual({
Resources: [userToFetch],
itemsPerPage: 20,
schemas: ["urn:ietf:params:scim:api:messages:2.0:ListResponse"],
startIndex: 1,
totalResults: 1,
})
})
})
})

View file

@ -49,7 +49,11 @@ export class ScimUsersAPI extends TestAPI {
get = async (
requestSettings?: Partial<RequestSettings> & {
params?: { startIndex?: number; pageSize?: number }
params?: {
startIndex?: number
pageSize?: number
filter?: string
}
}
) => {
let url = `/api/global/scim/v2/users?`
@ -60,6 +64,9 @@ export class ScimUsersAPI extends TestAPI {
if (params?.startIndex) {
url += `startIndex=${params.startIndex}&`
}
if (params?.filter) {
url += `filter=${params.filter}&`
}
const res = await this.#createRequest(url, "get", requestSettings)
return res.body as ScimUserListResponse
}

View file

@ -1606,6 +1606,11 @@
dependencies:
"@types/koa" "*"
"@types/lodash@^4.14.191":
version "4.14.191"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.191.tgz#09511e7f7cba275acd8b419ddac8da9a6a79e2fa"
integrity sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ==
"@types/mime@^1":
version "1.3.2"
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.2.tgz#93e25bf9ee75fe0fd80b594bc4feb0e862111b5a"