Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions api-js/src/__tests__/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,14 @@ describe('parse server', () => {
)
.post('/graphql')
.set('Accept', 'application/json')
.send({ query: '{findVerifiedDomains (first: 5) { edges { node { id }}}}' })
.send({
query: '{findVerifiedDomains (first: 5) { edges { node { id }}}}',
})

expect(response.status).toEqual(400)
expect(response.text).toEqual(expect.stringContaining('exceeds maximum operation depth'))
expect(response.text).toEqual(
expect.stringContaining('exceeds maximum operation depth'),
)
})
})
})
Expand Down
24 changes: 12 additions & 12 deletions api-js/src/auth/__tests__/check-domain-permission.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ describe('given the check domain permission function', () => {
await testCheckDomainPermission({ domainId: domain._id })
} catch (err) {
expect(err).toEqual(
new Error('Permission check error. Unable to request domain information.'),
new Error(
'Permission check error. Unable to request domain information.',
),
)
expect(consoleOutput).toEqual([
`Database error when retrieving super admin claims for user: ${user._id} and domain: ${domain._id}: Error: Database error occurred.`,
Expand All @@ -211,7 +213,9 @@ describe('given the check domain permission function', () => {
await testCheckDomainPermission({ domainId: domain._id })
} catch (err) {
expect(err).toEqual(
new Error('Permission check error. Unable to request domain information.'),
new Error(
'Permission check error. Unable to request domain information.',
),
)
expect(consoleOutput).toEqual([
`Database error when retrieving affiliated organization claims for user: ${user._id} and domain: ${domain._id}: Error: Database error occurred.`,
Expand Down Expand Up @@ -240,7 +244,9 @@ describe('given the check domain permission function', () => {
await testCheckDomainPermission({ domainId: domain._id })
} catch (err) {
expect(err).toEqual(
new Error('Permission check error. Unable to request domain information.'),
new Error(
'Permission check error. Unable to request domain information.',
),
)
expect(consoleOutput).toEqual([
`Cursor error when retrieving affiliated organization claims for user: ${user._id} and domain: ${domain._id}: Error: Cursor error occurred.`,
Expand Down Expand Up @@ -275,9 +281,7 @@ describe('given the check domain permission function', () => {
})
await testCheckDomainPermission({ domainId: domain._id })
} catch (err) {
expect(err).toEqual(
new Error('todo'),
)
expect(err).toEqual(new Error('todo'))
expect(consoleOutput).toEqual([
`Database error when retrieving super admin claims for user: ${user._id} and domain: ${domain._id}: Error: Database error occurred.`,
])
Expand All @@ -299,9 +303,7 @@ describe('given the check domain permission function', () => {
})
await testCheckDomainPermission({ domainId: domain._id })
} catch (err) {
expect(err).toEqual(
new Error('todo'),
)
expect(err).toEqual(new Error('todo'))
expect(consoleOutput).toEqual([
`Database error when retrieving affiliated organization claims for user: ${user._id} and domain: ${domain._id}: Error: Database error occurred.`,
])
Expand All @@ -328,9 +330,7 @@ describe('given the check domain permission function', () => {
})
await testCheckDomainPermission({ domainId: domain._id })
} catch (err) {
expect(err).toEqual(
new Error('todo'),
)
expect(err).toEqual(new Error('todo'))
expect(consoleOutput).toEqual([
`Cursor error when retrieving affiliated organization claims for user: ${user._id} and domain:${domain._id}: Error: Cursor error occurred.`,
])
Expand Down
6 changes: 5 additions & 1 deletion api-js/src/create-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ module.exports.createContext = ({ context, req: request, res: response }) => {
checkDomainOwnership: checkDomainOwnership({ i18n, userKey, query }),
checkDomainPermission: checkDomainPermission({ i18n, userKey, query }),
checkPermission: checkPermission({ i18n, userKey, query }),
checkUserIsAdminForUser: checkUserIsAdminForUser({ i18n, userKey, query }),
checkUserIsAdminForUser: checkUserIsAdminForUser({
i18n,
userKey,
query,
}),
tokenize,
userRequired: userRequired({
i18n,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,12 @@ describe('given the generateDetailTableFields function', () => {
const variables = {
first: 5,
}

const detailTableField = generateDetailTableFields({ subField, variables })


const detailTableField = generateDetailTableFields({
subField,
variables,
})

expect(detailTableField).toEqual({
edgeSelection: '',
pageInfoSelection: '',
Expand Down Expand Up @@ -154,9 +157,12 @@ describe('given the generateDetailTableFields function', () => {
const variables = {
last: 5,
}

const detailTableField = generateDetailTableFields({ subField, variables })


const detailTableField = generateDetailTableFields({
subField,
variables,
})

expect(detailTableField).toEqual({
edgeSelection: '',
pageInfoSelection: '',
Expand Down Expand Up @@ -185,9 +191,12 @@ describe('given the generateDetailTableFields function', () => {
const variables = {
before: 'SGVsbG8xMjM0',
}

const detailTableField = generateDetailTableFields({ subField, variables })


const detailTableField = generateDetailTableFields({
subField,
variables,
})

expect(detailTableField).toEqual({
edgeSelection: '',
pageInfoSelection: '',
Expand Down Expand Up @@ -216,9 +225,12 @@ describe('given the generateDetailTableFields function', () => {
const variables = {
after: 'SGVsbG8xMjM0',
}

const detailTableField = generateDetailTableFields({ subField, variables })


const detailTableField = generateDetailTableFields({
subField,
variables,
})

expect(detailTableField).toEqual({
edgeSelection: '',
pageInfoSelection: '',
Expand Down
10 changes: 6 additions & 4 deletions api-js/src/loaders/dmarc-report/generate-gql-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ const generateGqlQuery = ({ generateDetailTableFields }) => ({
if (arg.value.kind === 'Variable')
if (arg.value.name.value === 'month') {
queryArgs.push(
`${arg.name.value}: ${
String(info.variableValues[arg.value.name.value]).toUpperCase()
}`,
`${arg.name.value}: ${String(
info.variableValues[arg.value.name.value],
).toUpperCase()}`,
)
} else {
if (typeof info.variableValues[arg.value.name.value] === 'string') {
if (
typeof info.variableValues[arg.value.name.value] === 'string'
) {
queryArgs.push(
`${arg.name.value}: "${
info.variableValues[arg.value.name.value]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ const englishMessages = require('../../../locale/en/messages')
const frenchMessages = require('../../../locale/fr/messages')
const { makeMigrations } = require('../../../../migrations')
const { cleanseInput } = require('../../../validators')
const {
domainLoaderConnectionsByOrgId,
domainLoaderByKey,
} = require('../..')
const { domainLoaderConnectionsByOrgId, domainLoaderByKey } = require('../..')
const { toGlobalId } = require('graphql-relay')

describe('given the load domain connection using org id function', () => {
Expand All @@ -29,7 +26,7 @@ describe('given the load domain connection using org id function', () => {
let consoleOutput = []
const mockedError = (output) => consoleOutput.push(output)
const mockedWarn = (output) => consoleOutput.push(output)

beforeAll(async () => {
console.error = mockedError
console.warn = mockedWarn
Expand Down Expand Up @@ -393,14 +390,14 @@ describe('given the load domain connection using org id function', () => {
user._key,
cleanseInput,
)

const domainLoader = domainLoaderByKey(query)
const expectedDomains = await domainLoader.loadMany([
domainThree._key,
])

expectedDomains[0].id = expectedDomains[0]._key

const connectionArgs = {
first: 5,
}
Expand All @@ -409,7 +406,7 @@ describe('given the load domain connection using org id function', () => {
ownership: true,
...connectionArgs,
})

const expectedStructure = {
edges: [
{
Expand All @@ -427,7 +424,7 @@ describe('given the load domain connection using org id function', () => {
},
totalCount: 1,
}

expect(domains).toEqual(expectedStructure)
})
})
Expand All @@ -438,14 +435,14 @@ describe('given the load domain connection using org id function', () => {
user._key,
cleanseInput,
)

const domainLoader = domainLoaderByKey(query)
const expectedDomains = await domainLoader.loadMany([
domain._key,
domainTwo._key,
domainThree._key,
])

const connectionArgs = {
first: 5,
}
Expand All @@ -454,7 +451,7 @@ describe('given the load domain connection using org id function', () => {
ownership: false,
...connectionArgs,
})

const expectedStructure = {
edges: [
{
Expand Down Expand Up @@ -484,7 +481,7 @@ describe('given the load domain connection using org id function', () => {
},
totalCount: 3,
}

expect(domains).toEqual(expectedStructure)
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ const englishMessages = require('../../../locale/en/messages')
const frenchMessages = require('../../../locale/fr/messages')
const { makeMigrations } = require('../../../../migrations')
const { cleanseInput } = require('../../../validators')
const {
dkimLoaderConnectionsByDomainId,
dkimLoaderByKey,
} = require('../..')
const { dkimLoaderConnectionsByDomainId, dkimLoaderByKey } = require('../..')

describe('when given the load dkim connection function', () => {
let query, drop, truncate, migrate, collections, user, domain, i18n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ const englishMessages = require('../../../locale/en/messages')
const frenchMessages = require('../../../locale/fr/messages')
const { makeMigrations } = require('../../../../migrations')
const { cleanseInput } = require('../../../validators')
const {
dmarcLoaderConnectionsByDomainId,
dmarcLoaderByKey,
} = require('../..')
const { dmarcLoaderConnectionsByDomainId, dmarcLoaderByKey } = require('../..')

describe('when given the load dmarc connection function', () => {
let query, drop, truncate, migrate, collections, user, domain, i18n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ const englishMessages = require('../../../locale/en/messages')
const frenchMessages = require('../../../locale/fr/messages')
const { makeMigrations } = require('../../../../migrations')
const { cleanseInput } = require('../../../validators')
const {
orgLoaderConnectionArgsByDomainId,
orgLoaderByKey,
} = require('../..')
const { orgLoaderConnectionArgsByDomainId, orgLoaderByKey } = require('../..')

describe('given the load organizations connection function', () => {
let query,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ const englishMessages = require('../../../locale/en/messages')
const frenchMessages = require('../../../locale/fr/messages')
const { makeMigrations } = require('../../../../migrations')
const { cleanseInput } = require('../../../validators')
const {
verifiedDomainLoaderConnections,
domainLoaderByKey,
} = require('../..')
const { verifiedDomainLoaderConnections, domainLoaderByKey } = require('../..')
const { toGlobalId } = require('graphql-relay')

describe('given the load domain connection using org id function', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ const englishMessages = require('../../../locale/en/messages')
const frenchMessages = require('../../../locale/fr/messages')
const { makeMigrations } = require('../../../../migrations')
const { cleanseInput } = require('../../../validators')
const {
httpsLoaderConnectionsByDomainId,
httpsLoaderByKey,
} = require('../..')
const { httpsLoaderConnectionsByDomainId, httpsLoaderByKey } = require('../..')

describe('given the load https connection function', () => {
let query, drop, truncate, migrate, collections, user, domain, i18n
Expand Down
Loading