mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
more tests for transactions and finding users by different identifiers
This commit is contained in:
parent
2e865c6744
commit
1fbebddd71
@ -7,7 +7,7 @@ module.exports = {
|
|||||||
collectCoverageFrom: ['src/**/*.ts', '!**/node_modules/**', '!src/seeds/**', '!build/**'],
|
collectCoverageFrom: ['src/**/*.ts', '!**/node_modules/**', '!src/seeds/**', '!build/**'],
|
||||||
coverageThreshold: {
|
coverageThreshold: {
|
||||||
global: {
|
global: {
|
||||||
lines: 86,
|
lines: 89,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
setupFiles: ['<rootDir>/test/testSetup.ts'],
|
setupFiles: ['<rootDir>/test/testSetup.ts'],
|
||||||
|
|||||||
@ -2358,15 +2358,21 @@ describe('UserResolver', () => {
|
|||||||
mutation: login,
|
mutation: login,
|
||||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||||
})
|
})
|
||||||
|
await mutate({
|
||||||
|
mutation: updateUserInfos,
|
||||||
|
variables: {
|
||||||
|
alias: 'bibi',
|
||||||
|
},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('identifier is no gradido ID and no email', () => {
|
describe('identifier is no gradido ID, no email and no alias', () => {
|
||||||
it('throws and logs "Unknown identifier type" error', async () => {
|
it('throws and logs "Unknown identifier type" error', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
query({
|
query({
|
||||||
query: userQuery,
|
query: userQuery,
|
||||||
variables: {
|
variables: {
|
||||||
identifier: 'identifier',
|
identifier: 'identifier_is_no_valid_alias!',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
@ -2374,7 +2380,10 @@ describe('UserResolver', () => {
|
|||||||
errors: [new GraphQLError('Unknown identifier type')],
|
errors: [new GraphQLError('Unknown identifier type')],
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
expect(logger.error).toBeCalledWith('Unknown identifier type', 'identifier')
|
expect(logger.error).toBeCalledWith(
|
||||||
|
'Unknown identifier type',
|
||||||
|
'identifier_is_no_valid_alias!',
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -2441,6 +2450,29 @@ describe('UserResolver', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('identifier is found via alias', () => {
|
||||||
|
it('returns user', async () => {
|
||||||
|
await expect(
|
||||||
|
query({
|
||||||
|
query: userQuery,
|
||||||
|
variables: {
|
||||||
|
identifier: 'bibi',
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
).resolves.toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
data: {
|
||||||
|
user: {
|
||||||
|
firstName: 'Bibi',
|
||||||
|
lastName: 'Bloxberg',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
errors: undefined,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,8 @@ import { User as DbUser } from '@entity/User'
|
|||||||
|
|
||||||
import { LogError } from '@/server/LogError'
|
import { LogError } from '@/server/LogError'
|
||||||
|
|
||||||
export const validAliasRegex = /^(?=.{3,20}$)[a-zA-Z0-9]+(?:[_-][a-zA-Z0-9])*$/
|
// eslint-disable-next-line security/detect-unsafe-regex
|
||||||
|
export const validAliasRegex = /^(?=.{3,20}$)[a-zA-Z0-9]+(?:[_-][a-zA-Z0-9]+?)*$/
|
||||||
|
|
||||||
const reservedAlias = [
|
const reservedAlias = [
|
||||||
'admin',
|
'admin',
|
||||||
|
|||||||
@ -141,7 +141,7 @@ export const loadAllRules = (i18nCallback, apollo) => {
|
|||||||
|
|
||||||
extend('usernameUnique', {
|
extend('usernameUnique', {
|
||||||
validate(value) {
|
validate(value) {
|
||||||
if (value.match(/^(?=.{3,20}$)[a-zA-Z0-9]+(?:[_-][a-zA-Z0-9])*$/)) {
|
if (value.match(/^(?=.{3,20}$)[a-zA-Z0-9]+(?:[_-][a-zA-Z0-9]+?)*$/)) {
|
||||||
return apollo
|
return apollo
|
||||||
.query({
|
.query({
|
||||||
query: checkUsername,
|
query: checkUsername,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user