Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment #1477

Merged
merged 98 commits into from
May 11, 2024
Merged
Changes from 1 commit
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
0a8cea6
refactor(uuid): Prepare uuid query to support other types as well
kulla May 3, 2024
f3615ef
test: Make MSW to bypass to DB-Layer
kulla May 3, 2024
268244c
refactor: Move taxonomy to uuid query
kulla May 3, 2024
c5c839b
refactor(taxonomy): Add SQl for TaxonomySetNameAndDescription
kulla May 3, 2024
f4728db
Fix lint errors
kulla May 3, 2024
f23036e
fix(taxonomy): Add event when setting name and description
kulla May 4, 2024
47c8137
chore: Enable source-maps in "yarn start"
kulla May 4, 2024
61c624f
refactor(database): Add fetchOptional() + better transaction handling
kulla May 4, 2024
fee05ba
refactor(taxonomy): Move SQL for creating taxonomies
kulla May 4, 2024
40109e9
fix(database): Use proper rollback()
kulla May 4, 2024
104c634
test(database): Close DB after tests
kulla May 4, 2024
9c9ed50
Merge branch 'staging' into DJ9dI-kulla-2024-05-03-18-35
kulla May 4, 2024
9521598
Fix lint errors
kulla May 4, 2024
88bd9cf
fix(subject): Use fetchOptional()
kulla May 4, 2024
436f95f
chore(github): Test metadata endpoint extra
kulla May 4, 2024
de1e29f
refactor(taxonomy): Add SQL for sort taxonomies
kulla May 4, 2024
cd279a7
refactor(taxonomy): Add SQL to taxonomy.deleteEntityLink()
kulla May 4, 2024
8cd2efc
refactor(taxonomy): Move SQL into taxonomy.createEntityLinks()
kulla May 4, 2024
fbcd5c1
refactor(uuid): Replace UuidSetState with SQL
kulla May 4, 2024
f093e43
Fix lint errors
kulla May 4, 2024
7a4186f
test: Move taxonomyTermQuery to __utils__
kulla May 5, 2024
fc9fe5f
Merge branch 'staging' into DJ9dI-kulla-2024-05-03-18-35
AndreasHuber May 6, 2024
d68bced
fix(uuid resolver): restore rename accidentally undone during merge
AndreasHuber May 6, 2024
ed4d47a
fix(uuid resolver): add missing comma in SQL query
AndreasHuber May 6, 2024
da85ce2
style(uuid resolver): format SQL query
AndreasHuber May 6, 2024
a5d5a1c
style(uuid resolver): format SQL query
AndreasHuber May 6, 2024
095030d
refactor(resolveUuidFromDatabase): define BaseUser
AndreasHuber May 6, 2024
53fdd54
refactor(resolveUuidFromDatabase): add LEFT JOINs for user to SQL query
AndreasHuber May 6, 2024
9183a59
refactor(resolveUuidFromDatabase): add SELECTs for user to SQL query
AndreasHuber May 6, 2024
d8b8410
refactor(resolveUuidFromDatabase): add case BaseUser.is(baseUuid)
AndreasHuber May 6, 2024
f4c08a3
Merge branch 'staging' into make-resolveUuidFromDatabase-also-return-…
AndreasHuber May 6, 2024
f487e56
fix(resolveUuidFromDatabase): add missing commas to SQL query
AndreasHuber May 6, 2024
be0e1ae
Merge branch 'staging' into DJ9dI-kulla-2024-05-03-18-35
hugotiburtino May 6, 2024
d6e42b7
Merge branch 'DJ9dI-kulla-2024-05-03-18-35' into w2UlG-kulla-2024-05-…
hugotiburtino May 6, 2024
dab7c05
Merge pull request #1458 from serlo/w2UlG-kulla-2024-05-03-22-58
hugotiburtino May 6, 2024
accfd36
Merge pull request #1460 from serlo/fxHiA-kulla-2024-05-04-07-19
hugotiburtino May 6, 2024
50ce5eb
Merge pull request #1466 from serlo/pMtgC-kulla-2024-05-04-18-06
hugotiburtino May 6, 2024
c9f96de
Merge pull request #1465 from serlo/D15TX-kulla-2024-05-04-16-38
hugotiburtino May 6, 2024
b61a44d
Merge pull request #1467 from serlo/jlnRa-kulla-2024-05-04-18-51
hugotiburtino May 6, 2024
d123bda
Merge pull request #1470 from serlo/t0Jjl-kulla-2024-05-05-14-53
hugotiburtino May 6, 2024
81c0509
Merge pull request #1456 from serlo/DJ9dI-kulla-2024-05-03-18-35
hugotiburtino May 6, 2024
614711c
Merge pull request #1468 from serlo/wSiDw-kulla-2024-05-04-19-58
hugotiburtino May 6, 2024
8fb67ef
chore: move emptySubjects to fixtures
elbotho May 6, 2024
03712bc
Merge pull request #1478 from serlo/move-to-fixture
elbotho May 6, 2024
57f79ab
chore(cache): Add myself to allowed users
May 7, 2024
b9eb9cd
chore(resolveUuidFromDatabase): find arguments to return
AndreasHuber May 7, 2024
424350a
chore(resolveUuidFromDatabase): cleanup
AndreasHuber May 7, 2024
dbadb59
Merge pull request #1479 from serlo/chore/add-mikey-to-allowed-users
AndreasHuber May 7, 2024
246e21b
Merge branch 'staging' into make-resolveUuidFromDatabase-also-return-…
AndreasHuber May 7, 2024
fbd2ccc
chore: fix lint errors with imports
AndreasHuber May 7, 2024
d9202ab
fix(resolveUuidFromDatabase): add proper alias property
AndreasHuber May 7, 2024
9787a3b
chore(resolveUuidFromDatabase): remove unused property
AndreasHuber May 7, 2024
d5cc3f3
refactor(setEmail): migrate SQL from database-layer to resolver
AndreasHuber May 7, 2024
2fef783
test(setEmail): remove tests testing case of database-layer error res…
AndreasHuber May 7, 2024
1a6d690
test(setEmail): remove from serlo model
AndreasHuber May 7, 2024
693f4e5
refactor(setEmail): do not remove cache entry as mail is not in cache
AndreasHuber May 7, 2024
98905ac
fix(bull-arena): Make it an external dependency
kulla May 7, 2024
182ed10
Merge pull request #1481 from serlo/bgeqS-kulla-2024-05-07-19-02
kulla May 7, 2024
c0070b6
Merge pull request #1476 from serlo/make-resolveUuidFromDatabase-also…
hugotiburtino May 7, 2024
ced7326
chore(vidis): add container for local test to vidis
hugotiburtino May 7, 2024
933c190
doc(readme): remove not so important info
hugotiburtino May 7, 2024
8661c1d
fix(swr-queue): Add needed context variables for value updates
kulla May 8, 2024
a4cab5f
Merge pull request #1484 from serlo/1483-error-cannot-read-properties…
hugotiburtino May 8, 2024
31ec0a7
Merge pull request #1480 from serlo/migrate-set-email
hugotiburtino May 8, 2024
1fcbbc5
refactor(setEmail): remove from database-layer.ts
AndreasHuber May 8, 2024
b2bca1c
test(setEmail): remove mock
AndreasHuber May 8, 2024
2722ce9
Merge pull request #1485 from serlo/migrate-set-email
hugotiburtino May 8, 2024
068d452
refactor(deleteRegularUser): remove from serlo model
AndreasHuber May 8, 2024
21c8a6e
refactor(deleteRegularUser): remove from database-layer.ts
AndreasHuber May 8, 2024
b0e3d18
refactor(deleteRegularUser): move SQL to resolver
AndreasHuber May 8, 2024
56b9a59
test(setEmail): Test that email has been changed
kulla May 8, 2024
8b7f663
Merge pull request #1487 from serlo/60z8H-kulla-2024-05-08-11-10
kulla May 8, 2024
72fc01e
refactor(subject): Shorten code to query subjects
kulla May 8, 2024
a30dcd5
test(deleteRegularUser): remove mocks and tests for database-layer fa…
AndreasHuber May 8, 2024
4c3792b
Merge pull request #1486 from serlo/BDkOQ-kulla-2024-05-08-11-05
kulla May 8, 2024
a98c652
fix(deleteRegularUser): await promise
AndreasHuber May 8, 2024
24339cc
test(deleteRegularUser): remove unused imports
AndreasHuber May 8, 2024
3dc7e6d
test(deleteRegularUser): format
AndreasHuber May 8, 2024
72f9856
fix(deleteRegularUser): await promise
AndreasHuber May 8, 2024
b369ce7
feat(kratos): extend SLO to provider vidis
hugotiburtino May 8, 2024
56b3deb
fix(deleteRegularUser): use transaction
AndreasHuber May 8, 2024
fa602ee
refactor(deleteRegularUser): revert to id instead of user.id
AndreasHuber May 8, 2024
080e47b
feature(deleteRegularUser): only commit database transaction if remov…
AndreasHuber May 8, 2024
f1d8456
doc(readme): minor change
hugotiburtino May 8, 2024
9d6ed5b
Merge pull request #1482 from serlo/vidis
hugotiburtino May 8, 2024
2c70a57
chore(deps): bump semver from 7.0.0 to 7.6.1
dependabot[bot] May 8, 2024
faa6db0
Merge pull request #1490 from serlo/dependabot/npm_and_yarn/semver-7.6.1
kulla May 8, 2024
1540366
chore(kratos): upgrade image
hugotiburtino May 8, 2024
3e1509e
chore: Set default cache type to "redis" for "yarn start"
kulla May 9, 2024
6da0145
test(subject): Add `subjectQuery`
kulla May 9, 2024
7992233
Merge pull request #1493 from serlo/uJbfv-kulla-2024-05-09-18-00
kulla May 9, 2024
42fa576
Merge pull request #1492 from serlo/mG0Ls-kulla-2024-05-09-17-53
hugotiburtino May 9, 2024
ef63299
test(deleteRegularUser): put test back that might still make sense an…
AndreasHuber May 10, 2024
2af8933
Merge pull request #1491 from serlo/kratos-upgrade
kulla May 10, 2024
5b9c319
test(deleteRegularUser): comment test step that cannot work while the…
AndreasHuber May 10, 2024
7e3069a
feature(deleteRegularUser): await completion of all mutations instead…
AndreasHuber May 10, 2024
4dcdf56
refactor(user): minor wording change at error msg
hugotiburtino May 11, 2024
6f1a9f8
Merge pull request #1488 from serlo/migrate-delete-regular-user
hugotiburtino May 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test(deleteRegularUser): remove mocks and tests for database-layer fa…
…ilure
AndreasHuber committed May 8, 2024
commit a30dcd57761d41085e47f4926d8d23e2f20582de
59 changes: 12 additions & 47 deletions __tests__/schema/user/delete-regular-users.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import gql from 'graphql-tag'
import { HttpResponse } from 'msw'

Check failure on line 2 in __tests__/schema/user/delete-regular-users.ts

GitHub Actions / eslint

'HttpResponse' is defined but never used
import * as R from 'ramda'

import { user as baseUser } from '../../../__fixtures__'
import { Client, given, nextUuid, Query } from '../../__utils__'
import { createFakeIdentity, Client, given, nextUuid, Query } from '../../__utils__'

Check failure on line 6 in __tests__/schema/user/delete-regular-users.ts

GitHub Actions / eslint

'createFakeIdentity' is defined but never used

Check failure on line 6 in __tests__/schema/user/delete-regular-users.ts

GitHub Actions / eslint

'given' is defined but never used

let client: Client
let mutation: Query
@@ -27,42 +27,9 @@
`,
})
.withInput(R.pick(['id', 'username'], user))

given('UserDeleteRegularUsersMutation').isDefinedBy(async ({ request }) => {
const body = await request.json()
const { userId } = body.payload

given('UuidQuery').withPayload({ id: userId }).returnsNotFound()

return HttpResponse.json({ success: true })
})

given('UuidQuery').for(user)
})

test('runs successfully when mutation could be successfully executed', async () => {
expect(global.kratos.identities).toHaveLength(1)

await mutation.shouldReturnData({
user: { deleteRegularUser: { success: true } },
})
expect(global.kratos.identities).toHaveLength(0)
})

test('fails when mutation failes', async () => {
given('UserDeleteRegularUsersMutation').returns({
success: false,
reason: 'failure',
})
expect(global.kratos.identities).toHaveLength(1)

await mutation.shouldReturnData({
user: { deleteRegularUser: { success: false } },
})
expect(global.kratos.identities).toHaveLength(1)
})

test('fails when username does not match user', async () => {
test('fails if username does not match user', async () => {
await mutation
.withInput({ users: [{ id: user.id, username: 'something' }] })
.shouldFailWithError('BAD_USER_INPUT')
@@ -88,29 +55,27 @@
await uuidQuery.shouldReturnData({ uuid: null })
})

test('fails when one of the given bot ids is not a user', async () => {
test('fails if one of the given bot ids is not a user', async () => {
await mutation
.withInput({ userIds: [noUserId] })
.shouldFailWithError('BAD_USER_INPUT')
})

test('fails when user is not authenticated', async () => {
await mutation.forUnauthenticatedUser().shouldFailWithError('UNAUTHENTICATED')
test('fails if you try to delete user Deleted', async () => {
await mutation
.withInput({ userIds: 4 })
.shouldFailWithError('BAD_USER_INPUT')
})

test('fails when user does not have role "sysadmin"', async () => {
await mutation.forLoginUser('de_admin').shouldFailWithError('FORBIDDEN')
test('fails if user is not authenticated', async () => {
await mutation.forUnauthenticatedUser().shouldFailWithError('UNAUTHENTICATED')
})

test('fails when database layer has an internal error', async () => {
given('UserDeleteRegularUsersMutation').hasInternalServerError()

await mutation.shouldFailWithError('INTERNAL_SERVER_ERROR')

expect(global.kratos.identities).toHaveLength(1)
test('fails if user does not have role "sysadmin"', async () => {
await mutation.forLoginUser('de_admin').shouldFailWithError('FORBIDDEN')
})

test('fails when kratos has an error', async () => {
test('fails if kratos has an error', async () => {
global.kratos.admin.deleteIdentity = () => {
throw new Error('Error in kratos')
}

Unchanged files with check annotations Beta

)
}
database.mutate("UPDATE comment SET author_id = ? WHERE author_id = ?", [idUserDeleted, id])

Check failure on line 424 in packages/server/src/schema/uuid/user/resolvers.ts

GitHub Actions / eslint

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
database.mutate("UPDATE entity_revision SET author_id = ? WHERE author_id = ?", [idUserDeleted, id])

Check failure on line 425 in packages/server/src/schema/uuid/user/resolvers.ts

GitHub Actions / eslint

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
database.mutate("UPDATE event_log SET actor_id = ? WHERE actor_id = ?", [idUserDeleted, id])

Check failure on line 426 in packages/server/src/schema/uuid/user/resolvers.ts

GitHub Actions / eslint

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
database.mutate("UPDATE page_revision SET author_id = ? WHERE author_id = ?", [idUserDeleted, id])

Check failure on line 427 in packages/server/src/schema/uuid/user/resolvers.ts

GitHub Actions / eslint

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
database.mutate("DELETE FROM notification WHERE user_id = ?", [id])

Check failure on line 428 in packages/server/src/schema/uuid/user/resolvers.ts

GitHub Actions / eslint

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
database.mutate("DELETE FROM role_user WHERE user_id = ?", [id])

Check failure on line 429 in packages/server/src/schema/uuid/user/resolvers.ts

GitHub Actions / eslint

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
database.mutate("DELETE FROM subscription WHERE user_id = ?", [id])

Check failure on line 430 in packages/server/src/schema/uuid/user/resolvers.ts

GitHub Actions / eslint

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
database.mutate("DELETE FROM subscription WHERE uuid_id = ?", [id])
database.mutate("DELETE FROM uuid WHERE id = ? and discriminator = 'user'", [id])