Test filtering by user name
This commit is contained in:
parent
a91e4b4da1
commit
ad2a23d113
|
@ -54,7 +54,7 @@ export interface User extends Document {
|
||||||
userGroups?: string[]
|
userGroups?: string[]
|
||||||
onboardedAt?: string
|
onboardedAt?: string
|
||||||
scimInfo?: {
|
scimInfo?: {
|
||||||
username: string
|
userName: string
|
||||||
externalId: string
|
externalId: string
|
||||||
isSync: boolean
|
isSync: boolean
|
||||||
firstSync: number
|
firstSync: number
|
||||||
|
|
|
@ -79,6 +79,7 @@
|
||||||
"@types/jsonwebtoken": "8.5.1",
|
"@types/jsonwebtoken": "8.5.1",
|
||||||
"@types/koa": "2.13.4",
|
"@types/koa": "2.13.4",
|
||||||
"@types/koa__router": "8.0.8",
|
"@types/koa__router": "8.0.8",
|
||||||
|
"@types/lodash": "^4.14.191",
|
||||||
"@types/node": "14.18.20",
|
"@types/node": "14.18.20",
|
||||||
"@types/node-fetch": "2.6.1",
|
"@types/node-fetch": "2.6.1",
|
||||||
"@types/pouchdb": "6.4.0",
|
"@types/pouchdb": "6.4.0",
|
||||||
|
@ -89,6 +90,7 @@
|
||||||
"copyfiles": "2.4.1",
|
"copyfiles": "2.4.1",
|
||||||
"eslint": "6.8.0",
|
"eslint": "6.8.0",
|
||||||
"jest": "28.1.1",
|
"jest": "28.1.1",
|
||||||
|
"lodash": "4.17.21",
|
||||||
"nodemon": "2.0.15",
|
"nodemon": "2.0.15",
|
||||||
"pouchdb-adapter-memory": "7.2.2",
|
"pouchdb-adapter-memory": "7.2.2",
|
||||||
"prettier": "2.3.1",
|
"prettier": "2.3.1",
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import tk from "timekeeper"
|
import tk from "timekeeper"
|
||||||
|
import _ from "lodash"
|
||||||
import { mocks, structures } from "@budibase/backend-core/tests"
|
import { mocks, structures } from "@budibase/backend-core/tests"
|
||||||
import {
|
import {
|
||||||
ScimCreateUserRequest,
|
ScimCreateUserRequest,
|
||||||
|
@ -7,6 +8,8 @@ import {
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { TestConfiguration } from "../../../../../tests"
|
import { TestConfiguration } from "../../../../../tests"
|
||||||
|
|
||||||
|
mocks.licenses.useScimIntegration()
|
||||||
|
|
||||||
function createScimCreateUserRequest(userData?: {
|
function createScimCreateUserRequest(userData?: {
|
||||||
externalId?: string
|
externalId?: string
|
||||||
email?: string
|
email?: string
|
||||||
|
@ -152,6 +155,25 @@ describe("/api/global/scim/v2/users", () => {
|
||||||
totalResults: userCount,
|
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,
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,11 @@ export class ScimUsersAPI extends TestAPI {
|
||||||
|
|
||||||
get = async (
|
get = async (
|
||||||
requestSettings?: Partial<RequestSettings> & {
|
requestSettings?: Partial<RequestSettings> & {
|
||||||
params?: { startIndex?: number; pageSize?: number }
|
params?: {
|
||||||
|
startIndex?: number
|
||||||
|
pageSize?: number
|
||||||
|
filter?: string
|
||||||
|
}
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
let url = `/api/global/scim/v2/users?`
|
let url = `/api/global/scim/v2/users?`
|
||||||
|
@ -60,6 +64,9 @@ export class ScimUsersAPI extends TestAPI {
|
||||||
if (params?.startIndex) {
|
if (params?.startIndex) {
|
||||||
url += `startIndex=${params.startIndex}&`
|
url += `startIndex=${params.startIndex}&`
|
||||||
}
|
}
|
||||||
|
if (params?.filter) {
|
||||||
|
url += `filter=${params.filter}&`
|
||||||
|
}
|
||||||
const res = await this.#createRequest(url, "get", requestSettings)
|
const res = await this.#createRequest(url, "get", requestSettings)
|
||||||
return res.body as ScimUserListResponse
|
return res.body as ScimUserListResponse
|
||||||
}
|
}
|
||||||
|
|
|
@ -1606,6 +1606,11 @@
|
||||||
dependencies:
|
dependencies:
|
||||||
"@types/koa" "*"
|
"@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":
|
"@types/mime@^1":
|
||||||
version "1.3.2"
|
version "1.3.2"
|
||||||
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.2.tgz#93e25bf9ee75fe0fd80b594bc4feb0e862111b5a"
|
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.2.tgz#93e25bf9ee75fe0fd80b594bc4feb0e862111b5a"
|
||||||
|
|
Loading…
Reference in New Issue