@contember/engine-server 1.2.0-alpha.1 → 1.2.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/tests/e2e/acl-condition-variable.test.d.ts +2 -0
- package/dist/tests/e2e/acl-condition-variable.test.d.ts.map +1 -0
- package/dist/tests/e2e/acl-condition-variable.test.js +77 -0
- package/dist/tests/e2e/acl-condition-variable.test.js.map +1 -0
- package/dist/tests/e2e/assume-membership.test.d.ts +2 -0
- package/dist/tests/e2e/assume-membership.test.d.ts.map +1 -0
- package/dist/tests/e2e/assume-membership.test.js +58 -0
- package/dist/tests/e2e/assume-membership.test.js.map +1 -0
- package/dist/tests/e2e/content-api-basic.test.d.ts +2 -0
- package/dist/tests/e2e/content-api-basic.test.d.ts.map +1 -0
- package/dist/tests/e2e/content-api-basic.test.js +50 -0
- package/dist/tests/e2e/content-api-basic.test.js.map +1 -0
- package/dist/tests/e2e/content-invalid-schema.test.d.ts +2 -0
- package/dist/tests/e2e/content-invalid-schema.test.d.ts.map +1 -0
- package/dist/tests/e2e/content-invalid-schema.test.js +29 -0
- package/dist/tests/e2e/content-invalid-schema.test.js.map +1 -0
- package/dist/tests/e2e/homepage.test.d.ts +2 -0
- package/dist/tests/e2e/homepage.test.d.ts.map +1 -0
- package/dist/tests/e2e/homepage.test.js +15 -0
- package/dist/tests/e2e/homepage.test.js.map +1 -0
- package/dist/tests/e2e/tenant-member-access.test.d.ts +2 -0
- package/dist/tests/e2e/tenant-member-access.test.d.ts.map +1 -0
- package/dist/tests/e2e/tenant-member-access.test.js +43 -0
- package/dist/tests/e2e/tenant-member-access.test.js.map +1 -0
- package/dist/tests/e2e/x-contember-ref.test.d.ts +2 -0
- package/dist/tests/e2e/x-contember-ref.test.d.ts.map +1 -0
- package/dist/tests/e2e/x-contember-ref.test.js +63 -0
- package/dist/tests/e2e/x-contember-ref.test.js.map +1 -0
- package/dist/tests/{e2e → src}/requests.d.ts +2 -1
- package/dist/tests/src/requests.d.ts.map +1 -0
- package/dist/tests/{e2e → src}/requests.js +4 -4
- package/dist/tests/{e2e → src}/requests.js.map +1 -1
- package/dist/tests/{e2e → src}/tester.d.ts +0 -0
- package/dist/tests/{e2e → src}/tester.d.ts.map +1 -1
- package/dist/tests/{e2e → src}/tester.js +0 -0
- package/dist/tests/{e2e → src}/tester.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/package.json +20 -20
- package/tests/e2e/acl-condition-variable.test.ts +74 -0
- package/tests/e2e/assume-membership.test.ts +64 -0
- package/tests/e2e/content-api-basic.test.ts +51 -0
- package/tests/e2e/content-invalid-schema.test.ts +31 -0
- package/tests/e2e/homepage.test.ts +10 -0
- package/tests/e2e/tenant-member-access.test.ts +51 -0
- package/tests/e2e/x-contember-ref.test.ts +71 -0
- package/tests/{e2e → src}/requests.ts +5 -4
- package/tests/{e2e → src}/tester.ts +0 -0
- package/dist/tests/e2e/http.test.d.ts +0 -2
- package/dist/tests/e2e/http.test.d.ts.map +0 -1
- package/dist/tests/e2e/http.test.js +0 -192
- package/dist/tests/e2e/http.test.js.map +0 -1
- package/dist/tests/e2e/requests.d.ts.map +0 -1
- package/tests/e2e/http.test.ts +0 -237
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { assert, test } from 'vitest'
|
|
2
|
+
import { createTester, gql } from '../src/tester'
|
|
3
|
+
import { createSchema, SchemaDefinition as def, AclDefinition as acl } from '@contember/schema-definition'
|
|
4
|
+
import { addProjectMember, signIn, signUp } from '../src/requests'
|
|
5
|
+
|
|
6
|
+
namespace ArticleModel {
|
|
7
|
+
export const readerRole = acl.createRole('reader')
|
|
8
|
+
export const subscriptionVariable = acl.createConditionVariable('subscription', readerRole)
|
|
9
|
+
|
|
10
|
+
@acl.allow(readerRole, {
|
|
11
|
+
read: true,
|
|
12
|
+
when: {
|
|
13
|
+
publishedAt: subscriptionVariable,
|
|
14
|
+
},
|
|
15
|
+
})
|
|
16
|
+
export class Article {
|
|
17
|
+
publishedAt = def.dateTimeColumn().notNull()
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
test('ACL: condition variable', async () => {
|
|
22
|
+
const tester = await createTester(createSchema(ArticleModel))
|
|
23
|
+
|
|
24
|
+
await tester(
|
|
25
|
+
gql`
|
|
26
|
+
mutation {
|
|
27
|
+
articleA: createArticle(data: { publishedAt: "2022-02-01" }) {
|
|
28
|
+
ok
|
|
29
|
+
}
|
|
30
|
+
articleB: createArticle(data: { publishedAt: "2021-12-01" }) {
|
|
31
|
+
ok
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
`,
|
|
35
|
+
)
|
|
36
|
+
.expect(response => {
|
|
37
|
+
assert.deepStrictEqual(response.body.data, {
|
|
38
|
+
articleA: {
|
|
39
|
+
ok: true,
|
|
40
|
+
},
|
|
41
|
+
articleB: {
|
|
42
|
+
ok: true,
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
.expect(200)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
const email = `john+${Date.now()}@doe.com`
|
|
50
|
+
const identityId = await signUp(email)
|
|
51
|
+
const authKey = await signIn(email)
|
|
52
|
+
await addProjectMember(identityId, tester.projectSlug, { role: 'reader', variables: [{ name: 'subscription', values: [JSON.stringify({ gte: '2022-01-01' })] }] })
|
|
53
|
+
|
|
54
|
+
await tester(
|
|
55
|
+
gql`
|
|
56
|
+
query {
|
|
57
|
+
listArticle {
|
|
58
|
+
publishedAt
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`,
|
|
62
|
+
{ authorizationToken: authKey },
|
|
63
|
+
)
|
|
64
|
+
.expect(response => {
|
|
65
|
+
assert.deepStrictEqual(response.body.data, {
|
|
66
|
+
listArticle: [
|
|
67
|
+
{
|
|
68
|
+
publishedAt: '2022-02-01T00:00:00.000Z',
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
.expect(200)
|
|
74
|
+
})
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { test } from 'vitest'
|
|
2
|
+
import { createTester, gql } from '../src/tester'
|
|
3
|
+
import { addProjectMember, signIn, signUp } from '../src/requests'
|
|
4
|
+
import { createSchema, SchemaDefinition as def } from '@contember/schema-definition'
|
|
5
|
+
|
|
6
|
+
namespace TagModel {
|
|
7
|
+
export class Tag {
|
|
8
|
+
label = def.stringColumn()
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
test('Content API: assume membership', async () => {
|
|
14
|
+
const tester = await createTester(createSchema(TagModel, schema => {
|
|
15
|
+
return {
|
|
16
|
+
...schema,
|
|
17
|
+
acl: {
|
|
18
|
+
roles: {
|
|
19
|
+
test: {
|
|
20
|
+
entities: {},
|
|
21
|
+
variables: {},
|
|
22
|
+
content: {
|
|
23
|
+
assumeMembership: {
|
|
24
|
+
admin: {},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
}
|
|
31
|
+
}))
|
|
32
|
+
|
|
33
|
+
const email = `john+${Date.now()}@doe.com`
|
|
34
|
+
const identityId = await signUp(email)
|
|
35
|
+
const authKey = await signIn(email)
|
|
36
|
+
await addProjectMember(identityId, tester.projectSlug, { role: 'test', variables: [] })
|
|
37
|
+
|
|
38
|
+
await tester(
|
|
39
|
+
gql`
|
|
40
|
+
query {
|
|
41
|
+
listTag {
|
|
42
|
+
id
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
`,
|
|
46
|
+
{ authorizationToken: authKey },
|
|
47
|
+
)
|
|
48
|
+
.expect(400)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
await tester(
|
|
52
|
+
gql`
|
|
53
|
+
query {
|
|
54
|
+
listTag {
|
|
55
|
+
id
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
`,
|
|
59
|
+
{ authorizationToken: authKey },
|
|
60
|
+
)
|
|
61
|
+
.set('X-Contember-assume-membership', JSON.stringify({ memberships: [{ role: 'admin', variables: [] }] }))
|
|
62
|
+
.expect({ data: { listTag: [] } })
|
|
63
|
+
.expect(200)
|
|
64
|
+
})
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { assert, test } from 'vitest'
|
|
2
|
+
import { createTester, gql } from '../src/tester'
|
|
3
|
+
import { createSchema, SchemaDefinition as def } from '@contember/schema-definition'
|
|
4
|
+
|
|
5
|
+
namespace TagModel {
|
|
6
|
+
export class Tag {
|
|
7
|
+
label = def.stringColumn()
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
test('Content API: create & read tag', async () => {
|
|
12
|
+
const tester = await createTester(createSchema(TagModel))
|
|
13
|
+
|
|
14
|
+
await tester(
|
|
15
|
+
gql`
|
|
16
|
+
mutation {
|
|
17
|
+
createTag(data: { label: "graphql" }) {
|
|
18
|
+
ok
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
`,
|
|
22
|
+
)
|
|
23
|
+
.expect(response => {
|
|
24
|
+
assert.deepStrictEqual(response.body.data, {
|
|
25
|
+
createTag: {
|
|
26
|
+
ok: true,
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
.expect(200)
|
|
31
|
+
|
|
32
|
+
await tester(
|
|
33
|
+
gql`
|
|
34
|
+
query {
|
|
35
|
+
listTag(filter: { label: { eq: "graphql" } }) {
|
|
36
|
+
label
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`,
|
|
40
|
+
)
|
|
41
|
+
.expect(response => {
|
|
42
|
+
assert.deepStrictEqual(response.body.data, {
|
|
43
|
+
listTag: [
|
|
44
|
+
{
|
|
45
|
+
label: 'graphql',
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
.expect(200)
|
|
51
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { assert, test } from 'vitest'
|
|
2
|
+
import { createSchema, SchemaDefinition as def } from '@contember/schema-definition'
|
|
3
|
+
import { createTester, gql } from '../src/tester'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
namespace TagModel {
|
|
7
|
+
export class Tag {
|
|
8
|
+
label = def.stringColumn()
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
test('Content API: invalid schema error', async () => {
|
|
13
|
+
const tester = await createTester(createSchema(TagModel))
|
|
14
|
+
|
|
15
|
+
await tester(
|
|
16
|
+
gql`
|
|
17
|
+
mutation {
|
|
18
|
+
createFoo(data: { label: "graphql" }) {
|
|
19
|
+
ok
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
`,
|
|
23
|
+
)
|
|
24
|
+
.expect(400)
|
|
25
|
+
.expect(response => {
|
|
26
|
+
assert.deepStrictEqual(
|
|
27
|
+
response.body.errors[0].message,
|
|
28
|
+
'Cannot query field "createFoo" on type "Mutation". Did you mean "createTag"?',
|
|
29
|
+
)
|
|
30
|
+
})
|
|
31
|
+
})
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { assert, test } from 'vitest'
|
|
2
|
+
import { createSchema, SchemaDefinition as def } from '@contember/schema-definition'
|
|
3
|
+
import { createTester, gql } from '../src/tester'
|
|
4
|
+
import { addProjectMember, signIn, signUp } from '../src/requests'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
namespace TagModel {
|
|
8
|
+
export class Tag {
|
|
9
|
+
label = def.stringColumn()
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
test('Tenant API: sign up, add to a project and check project access', async () => {
|
|
15
|
+
const tester = await createTester(createSchema(TagModel))
|
|
16
|
+
|
|
17
|
+
const email = `john+${Date.now()}@doe.com`
|
|
18
|
+
const identityId = await signUp(email)
|
|
19
|
+
const authKey = await signIn(email)
|
|
20
|
+
|
|
21
|
+
await tester(
|
|
22
|
+
gql`
|
|
23
|
+
query {
|
|
24
|
+
listTag {
|
|
25
|
+
id
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`,
|
|
29
|
+
{ authorizationToken: authKey },
|
|
30
|
+
)
|
|
31
|
+
.expect(404)
|
|
32
|
+
.expect({ errors: [{ message: `Project ${tester.projectSlug} NOT found`, code: 404 }] })
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
await addProjectMember(identityId, tester.projectSlug)
|
|
36
|
+
|
|
37
|
+
await tester(
|
|
38
|
+
gql`
|
|
39
|
+
query {
|
|
40
|
+
listTag {
|
|
41
|
+
id
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
`,
|
|
45
|
+
{ authorizationToken: authKey },
|
|
46
|
+
)
|
|
47
|
+
.expect(response => {
|
|
48
|
+
assert.deepStrictEqual(response.body.data, { listTag: [] })
|
|
49
|
+
})
|
|
50
|
+
.expect(200)
|
|
51
|
+
})
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { assert, test } from 'vitest'
|
|
2
|
+
import { createTester, gql } from '../src/tester'
|
|
3
|
+
import { createSchema, SchemaDefinition as def } from '@contember/schema-definition'
|
|
4
|
+
|
|
5
|
+
namespace TagModel {
|
|
6
|
+
export class Tag {
|
|
7
|
+
label = def.stringColumn()
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
test('Content API: X-Contember-Ref header', async () => {
|
|
13
|
+
|
|
14
|
+
const tester = await createTester(createSchema(TagModel))
|
|
15
|
+
|
|
16
|
+
await tester(
|
|
17
|
+
gql`
|
|
18
|
+
mutation {
|
|
19
|
+
createTag(data: { label: "typescript" }) {
|
|
20
|
+
ok
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`,
|
|
24
|
+
).expect(200)
|
|
25
|
+
|
|
26
|
+
const response = await tester(
|
|
27
|
+
gql`
|
|
28
|
+
query {
|
|
29
|
+
listTag(filter: { label: { eq: "typescript" } }) {
|
|
30
|
+
label
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
`,
|
|
34
|
+
)
|
|
35
|
+
.set('X-Contember-Ref', 'None')
|
|
36
|
+
.expect(response => {
|
|
37
|
+
assert.deepStrictEqual(response.body.data, {
|
|
38
|
+
listTag: [
|
|
39
|
+
{
|
|
40
|
+
label: 'typescript',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
})
|
|
44
|
+
})
|
|
45
|
+
.expect(200)
|
|
46
|
+
const eventKey = response.get('X-Contember-Ref')
|
|
47
|
+
await tester(
|
|
48
|
+
gql`
|
|
49
|
+
query {
|
|
50
|
+
listTag {
|
|
51
|
+
label
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
`,
|
|
55
|
+
)
|
|
56
|
+
.set('X-Contember-Ref', eventKey)
|
|
57
|
+
.expect(304)
|
|
58
|
+
|
|
59
|
+
// ignored for mutation
|
|
60
|
+
await tester(
|
|
61
|
+
gql`
|
|
62
|
+
mutation {
|
|
63
|
+
createTag(data: { label: "typescript" }) {
|
|
64
|
+
ok
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`,
|
|
68
|
+
)
|
|
69
|
+
.set('X-Contember-Ref', eventKey)
|
|
70
|
+
.expect(200)
|
|
71
|
+
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { executeGraphql, gql, loginToken } from './tester'
|
|
2
2
|
import { assert } from 'vitest'
|
|
3
|
+
import { Membership } from '@contember/engine-tenant-api'
|
|
3
4
|
|
|
4
5
|
export const signIn = async (email: string, password = '123456'): Promise<string> => {
|
|
5
6
|
const response = await executeGraphql(
|
|
@@ -50,18 +51,18 @@ export const signUp = async (email: string, password = '123456') => {
|
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
|
|
53
|
-
export const addProjectMember = async (identityId: string, projectSlug: string,
|
|
54
|
+
export const addProjectMember = async (identityId: string, projectSlug: string, membership: Membership = { role: 'admin', variables: [] }) => {
|
|
54
55
|
await executeGraphql(
|
|
55
56
|
'/tenant',
|
|
56
57
|
gql`
|
|
57
|
-
mutation ($identity: String!, $projectSlug: String!, $
|
|
58
|
-
addProjectMember(identityId: $identity, projectSlug: $projectSlug, memberships: [
|
|
58
|
+
mutation ($identity: String!, $projectSlug: String!, $membership: MembershipInput!) {
|
|
59
|
+
addProjectMember(identityId: $identity, projectSlug: $projectSlug, memberships: [$membership]) {
|
|
59
60
|
ok
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
`,
|
|
63
64
|
{
|
|
64
|
-
variables: { identity: identityId, projectSlug,
|
|
65
|
+
variables: { identity: identityId, projectSlug, membership },
|
|
65
66
|
},
|
|
66
67
|
)
|
|
67
68
|
.expect(200)
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http.test.d.ts","sourceRoot":"","sources":["../../../tests/e2e/http.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const supertest_1 = __importDefault(require("supertest"));
|
|
7
|
-
const vitest_1 = require("vitest");
|
|
8
|
-
const schema_definition_1 = require("@contember/schema-definition");
|
|
9
|
-
const tester_1 = require("./tester");
|
|
10
|
-
const requests_1 = require("./requests");
|
|
11
|
-
(0, vitest_1.test)('show homepage', async () => {
|
|
12
|
-
await (0, supertest_1.default)(tester_1.apiUrl)
|
|
13
|
-
.get('/')
|
|
14
|
-
.expect(200)
|
|
15
|
-
.expect('App is running');
|
|
16
|
-
});
|
|
17
|
-
var TagModel;
|
|
18
|
-
(function (TagModel) {
|
|
19
|
-
class Tag {
|
|
20
|
-
constructor() {
|
|
21
|
-
this.label = schema_definition_1.SchemaDefinition.stringColumn();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
TagModel.Tag = Tag;
|
|
25
|
-
})(TagModel || (TagModel = {}));
|
|
26
|
-
(0, vitest_1.test)('Content API: create & read tag', async () => {
|
|
27
|
-
const tester = await (0, tester_1.createTester)((0, schema_definition_1.createSchema)(TagModel));
|
|
28
|
-
await tester((0, tester_1.gql) `
|
|
29
|
-
mutation {
|
|
30
|
-
createTag(data: { label: "graphql" }) {
|
|
31
|
-
ok
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
`)
|
|
35
|
-
.expect(response => {
|
|
36
|
-
vitest_1.assert.deepStrictEqual(response.body.data, {
|
|
37
|
-
createTag: {
|
|
38
|
-
ok: true,
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
})
|
|
42
|
-
.expect(200);
|
|
43
|
-
await tester((0, tester_1.gql) `
|
|
44
|
-
query {
|
|
45
|
-
listTag(filter: { label: { eq: "graphql" } }) {
|
|
46
|
-
label
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
`)
|
|
50
|
-
.expect(response => {
|
|
51
|
-
vitest_1.assert.deepStrictEqual(response.body.data, {
|
|
52
|
-
listTag: [
|
|
53
|
-
{
|
|
54
|
-
label: 'graphql',
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
});
|
|
58
|
-
})
|
|
59
|
-
.expect(200);
|
|
60
|
-
});
|
|
61
|
-
(0, vitest_1.test)('Content API: X-Contember-Ref header', async () => {
|
|
62
|
-
const tester = await (0, tester_1.createTester)((0, schema_definition_1.createSchema)(TagModel));
|
|
63
|
-
await tester((0, tester_1.gql) `
|
|
64
|
-
mutation {
|
|
65
|
-
createTag(data: { label: "typescript" }) {
|
|
66
|
-
ok
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
`).expect(200);
|
|
70
|
-
const response = await tester((0, tester_1.gql) `
|
|
71
|
-
query {
|
|
72
|
-
listTag(filter: { label: { eq: "typescript" } }) {
|
|
73
|
-
label
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
`)
|
|
77
|
-
.set('X-Contember-Ref', 'None')
|
|
78
|
-
.expect(response => {
|
|
79
|
-
vitest_1.assert.deepStrictEqual(response.body.data, {
|
|
80
|
-
listTag: [
|
|
81
|
-
{
|
|
82
|
-
label: 'typescript',
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
});
|
|
86
|
-
})
|
|
87
|
-
.expect(200);
|
|
88
|
-
const eventKey = response.get('X-Contember-Ref');
|
|
89
|
-
await tester((0, tester_1.gql) `
|
|
90
|
-
query {
|
|
91
|
-
listTag {
|
|
92
|
-
label
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
`)
|
|
96
|
-
.set('X-Contember-Ref', eventKey)
|
|
97
|
-
.expect(304);
|
|
98
|
-
// ignored for mutation
|
|
99
|
-
await tester((0, tester_1.gql) `
|
|
100
|
-
mutation {
|
|
101
|
-
createTag(data: { label: "typescript" }) {
|
|
102
|
-
ok
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
`)
|
|
106
|
-
.set('X-Contember-Ref', eventKey)
|
|
107
|
-
.expect(200);
|
|
108
|
-
});
|
|
109
|
-
(0, vitest_1.test)('Content API: invalid schema error', async () => {
|
|
110
|
-
const tester = await (0, tester_1.createTester)((0, schema_definition_1.createSchema)(TagModel));
|
|
111
|
-
await tester((0, tester_1.gql) `
|
|
112
|
-
mutation {
|
|
113
|
-
createFoo(data: { label: "graphql" }) {
|
|
114
|
-
ok
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
`)
|
|
118
|
-
.expect(400)
|
|
119
|
-
.expect(response => {
|
|
120
|
-
vitest_1.assert.deepStrictEqual(response.body.errors[0].message, 'Cannot query field "createFoo" on type "Mutation". Did you mean "createTag"?');
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
(0, vitest_1.test)('Tenant API: sign up, add to a project and check project access', async () => {
|
|
124
|
-
const tester = await (0, tester_1.createTester)((0, schema_definition_1.createSchema)(TagModel));
|
|
125
|
-
const email = `john+${Date.now()}@doe.com`;
|
|
126
|
-
const identityId = await (0, requests_1.signUp)(email);
|
|
127
|
-
const authKey = await (0, requests_1.signIn)(email);
|
|
128
|
-
await tester((0, tester_1.gql) `
|
|
129
|
-
query {
|
|
130
|
-
listTag {
|
|
131
|
-
id
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
`, { authorizationToken: authKey })
|
|
135
|
-
.expect(404)
|
|
136
|
-
.expect({ errors: [{ message: `Project ${tester.projectSlug} NOT found`, code: 404 }] });
|
|
137
|
-
await (0, requests_1.addProjectMember)(identityId, tester.projectSlug);
|
|
138
|
-
await tester((0, tester_1.gql) `
|
|
139
|
-
query {
|
|
140
|
-
listTag {
|
|
141
|
-
id
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
`, { authorizationToken: authKey })
|
|
145
|
-
.expect(response => {
|
|
146
|
-
vitest_1.assert.deepStrictEqual(response.body.data, { listTag: [] });
|
|
147
|
-
})
|
|
148
|
-
.expect(200);
|
|
149
|
-
});
|
|
150
|
-
(0, vitest_1.test)('Content API: assume membership', async () => {
|
|
151
|
-
const tester = await (0, tester_1.createTester)((0, schema_definition_1.createSchema)(TagModel, schema => {
|
|
152
|
-
return {
|
|
153
|
-
...schema,
|
|
154
|
-
acl: {
|
|
155
|
-
roles: {
|
|
156
|
-
test: {
|
|
157
|
-
entities: {},
|
|
158
|
-
variables: {},
|
|
159
|
-
content: {
|
|
160
|
-
assumeMembership: {
|
|
161
|
-
admin: {},
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
}));
|
|
169
|
-
const email = `john+${Date.now()}@doe.com`;
|
|
170
|
-
const identityId = await (0, requests_1.signUp)(email);
|
|
171
|
-
const authKey = await (0, requests_1.signIn)(email);
|
|
172
|
-
await (0, requests_1.addProjectMember)(identityId, tester.projectSlug, 'test');
|
|
173
|
-
await tester((0, tester_1.gql) `
|
|
174
|
-
query {
|
|
175
|
-
listTag {
|
|
176
|
-
id
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
`, { authorizationToken: authKey })
|
|
180
|
-
.expect(400);
|
|
181
|
-
await tester((0, tester_1.gql) `
|
|
182
|
-
query {
|
|
183
|
-
listTag {
|
|
184
|
-
id
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
`, { authorizationToken: authKey })
|
|
188
|
-
.set('X-Contember-assume-membership', JSON.stringify({ memberships: [{ role: 'admin', variables: [] }] }))
|
|
189
|
-
.expect({ data: { listTag: [] } })
|
|
190
|
-
.expect(200);
|
|
191
|
-
});
|
|
192
|
-
//# sourceMappingURL=http.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http.test.js","sourceRoot":"","sources":["../../../tests/e2e/http.test.ts"],"names":[],"mappings":";;;;;AAAA,0DAAiC;AACjC,mCAAqC;AACrC,oEAAoF;AACpF,qCAAoD;AACpD,yCAA6D;AAG7D,IAAA,aAAI,EAAC,eAAe,EAAE,KAAK,IAAI,EAAE;IAChC,MAAM,IAAA,mBAAS,EAAC,eAAM,CAAC;SACrB,GAAG,CAAC,GAAG,CAAC;SACR,MAAM,CAAC,GAAG,CAAC;SACX,MAAM,CAAC,gBAAgB,CAAC,CAAA;AAC3B,CAAC,CAAC,CAAA;AAEF,IAAU,QAAQ,CAIjB;AAJD,WAAU,QAAQ;IACjB,MAAa,GAAG;QAAhB;YACC,UAAK,GAAG,oCAAG,CAAC,YAAY,EAAE,CAAA;QAC3B,CAAC;KAAA;IAFY,YAAG,MAEf,CAAA;AACF,CAAC,EAJS,QAAQ,KAAR,QAAQ,QAIjB;AAED,IAAA,aAAI,EAAC,gCAAgC,EAAE,KAAK,IAAI,EAAE;IACjD,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAY,EAAC,IAAA,gCAAY,EAAC,QA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