From 3c702637f6a178f5b297a689b15d1f207d38d2fa Mon Sep 17 00:00:00 2001 From: Kyle Sullivan <141261s@acadiau.ca> Date: Tue, 31 May 2022 16:55:13 -0300 Subject: [PATCH 1/5] Fix domain removal --- api/src/domain/mutations/remove-domain.js | 252 +++++++++------------- 1 file changed, 103 insertions(+), 149 deletions(-) diff --git a/api/src/domain/mutations/remove-domain.js b/api/src/domain/mutations/remove-domain.js index cad09a50f6..842dd97878 100644 --- a/api/src/domain/mutations/remove-domain.js +++ b/api/src/domain/mutations/remove-domain.js @@ -71,7 +71,7 @@ export const removeDomain = new mutationWithClientMutationId({ // Check to see if org exists if (typeof org === 'undefined') { console.warn( - `User: ${userKey} attempted to remove ${domain.slug} in org: ${orgId} however there is no organization associated with that id.`, + `User: ${userKey} attempted to remove ${domain.domain} in org: ${orgId} however there is no organization associated with that id.`, ) return { _type: 'error', @@ -88,7 +88,7 @@ export const removeDomain = new mutationWithClientMutationId({ // Check to see if domain belongs to verified check org if (org.verified && permission !== 'super_admin') { console.warn( - `User: ${userKey} attempted to remove ${domain.slug} in ${org.slug} but does not have permission to remove a domain from a verified check org.`, + `User: ${userKey} attempted to remove ${domain.domain} in ${org.slug} but does not have permission to remove a domain from a verified check org.`, ) return { _type: 'error', @@ -101,7 +101,7 @@ export const removeDomain = new mutationWithClientMutationId({ if (permission !== 'super_admin' && permission !== 'admin') { console.warn( - `User: ${userKey} attempted to remove ${domain.slug} in ${org.slug} however they do not have permission in that org.`, + `User: ${userKey} attempted to remove ${domain.domain} in ${org.slug} however they do not have permission in that org.`, ) return { _type: 'error', @@ -121,7 +121,7 @@ export const removeDomain = new mutationWithClientMutationId({ ` } catch (err) { console.error( - `Database error occurred for user: ${userKey}, when counting domain claims for domain: ${domain.slug}, error: ${err}`, + `Database error occurred for user: ${userKey}, when counting domain claims for domain: ${domain.domain}, error: ${err}`, ) throw new Error(i18n._(t`Unable to remove domain. Please try again.`)) } @@ -135,7 +135,7 @@ export const removeDomain = new mutationWithClientMutationId({ ` } catch (err) { console.error( - `Database error occurred for user: ${userKey}, when counting ownership claims for domain: ${domain.slug}, error: ${err}`, + `Database error occurred for user: ${userKey}, when counting ownership claims for domain: ${domain.domain}, error: ${err}`, ) throw new Error(i18n._(t`Unable to remove domain. Please try again.`)) } @@ -168,7 +168,7 @@ export const removeDomain = new mutationWithClientMutationId({ ) } catch (err) { console.error( - `Trx step error occurred when removing dmarc summary data for user: ${userKey} while attempting to remove domain: ${domain.slug}, error: ${err}`, + `Trx step error occurred when removing dmarc summary data for user: ${userKey} while attempting to remove domain: ${domain.domain}, error: ${err}`, ) throw new Error(i18n._(t`Unable to remove domain. Please try again.`)) } @@ -187,7 +187,7 @@ export const removeDomain = new mutationWithClientMutationId({ ) } catch (err) { console.error( - `Trx step error occurred when removing ownership data for user: ${userKey} while attempting to remove domain: ${domain.slug}, error: ${err}`, + `Trx step error occurred when removing ownership data for user: ${userKey} while attempting to remove domain: ${domain.domain}, error: ${err}`, ) throw new Error(i18n._(t`Unable to remove domain. Please try again.`)) } @@ -195,164 +195,118 @@ export const removeDomain = new mutationWithClientMutationId({ if (countCursor.count <= 1) { // Remove scan data + try { + // Remove DKIM data await trx.step(async () => { await query` - WITH claims, dkim, domains, domainsDKIM, organizations, dkimToDkimResults, dkimResults - LET domainEdges = (FOR v, e IN 1..1 OUTBOUND ${org._id} claims RETURN { edgeKey: e._key, domainId: e._to }) - FOR domainEdge in domainEdges - LET dkimEdges = (FOR v, e IN 1..1 OUTBOUND domainEdge.domainId domainsDKIM RETURN { edgeKey: e._key, dkimId: e._to }) - FOR dkimEdge IN dkimEdges - LET dkimResultEdges = (FOR v, e IN 1..1 OUTBOUND dkimEdge.dkimId dkimToDkimResults RETURN { edgeKey: e._key, dkimResultId: e._to }) - LET removeDkimResultEdges = ( - FOR dkimResultEdge IN dkimResultEdges - REMOVE dkimResultEdge.edgeKey IN dkimToDkimResults - OPTIONS { waitForSync: true } - ) - LET removeDkimResult = ( - FOR dkimResultEdge IN dkimResultEdges - LET key = PARSE_IDENTIFIER(dkimResultEdge.dkimResultId).key - REMOVE key IN dkimResults - OPTIONS { waitForSync: true } - ) - RETURN true - ` + WITH dkim, dkimResults + FOR dkimV, domainsDkimEdge IN 1..1 OUTBOUND ${domain._id} domainsDKIM + FOR dkimResult, dkimToDkimResultsEdge In 1..1 OUTBOUND dkimV._id dkimToDkimResults + REMOVE dkimResult IN dkimResults + REMOVE dkimToDkimResultsEdge IN dkimToDkimResults + OPTIONS { waitForSync: true } + REMOVE dkimV IN dkim + REMOVE domainsDkimEdge IN domainsDKIM + OPTIONS { waitForSync: true } + ` }) - await Promise.all([ - trx.step(async () => { - await query` - WITH claims, dkim, domains, domainsDKIM, organizations - LET domainEdges = (FOR v, e IN 1..1 INBOUND ${domain._id} claims RETURN { edgeKey: e._key, domainId: e._to }) - FOR domainEdge in domainEdges - LET dkimEdges = (FOR v, e IN 1..1 OUTBOUND domainEdge.domainId domainsDKIM RETURN { edgeKey: e._key, dkimId: e._to }) - LET removeDkimEdges = ( - FOR dkimEdge IN dkimEdges - REMOVE dkimEdge.edgeKey IN domainsDKIM - OPTIONS { waitForSync: true } - ) - LET removeDkim = ( - FOR dkimEdge IN dkimEdges - LET key = PARSE_IDENTIFIER(dkimEdge.dkimId).key - REMOVE key IN dkim - OPTIONS { waitForSync: true } - ) - RETURN true - ` - }), - trx.step(async () => { - await query` - WITH claims, dmarc, domains, domainsDMARC, organizations - LET domainEdges = (FOR v, e IN 1..1 INBOUND ${domain._id} claims RETURN { edgeKey: e._key, domainId: e._to }) - FOR domainEdge in domainEdges - LET dmarcEdges = (FOR v, e IN 1..1 OUTBOUND domainEdge.domainId domainsDMARC RETURN { edgeKey: e._key, dmarcId: e._to }) - LET removeDmarcEdges = ( - FOR dmarcEdge IN dmarcEdges - REMOVE dmarcEdge.edgeKey IN domainsDMARC - OPTIONS { waitForSync: true } - ) - LET removeDmarc = ( - FOR dmarcEdge IN dmarcEdges - LET key = PARSE_IDENTIFIER(dmarcEdge.dmarcId).key - REMOVE key IN dmarc - OPTIONS { waitForSync: true } - ) - RETURN true - ` - }), - trx.step(async () => { - await query` - WITH claims, domains, domainsSPF, organizations, spf - LET domainEdges = (FOR v, e IN 1..1 INBOUND ${domain._id} claims RETURN { edgeKey: e._key, domainId: e._to }) - FOR domainEdge in domainEdges - LET spfEdges = (FOR v, e IN 1..1 OUTBOUND domainEdge.domainId domainsSPF RETURN { edgeKey: e._key, spfId: e._to }) - LET removeSpfEdges = ( - FOR spfEdge IN spfEdges - REMOVE spfEdge.edgeKey IN domainsSPF - OPTIONS { waitForSync: true } - ) - LET removeSpf = ( - FOR spfEdge IN spfEdges - LET key = PARSE_IDENTIFIER(spfEdge.spfId).key - REMOVE key IN spf - OPTIONS { waitForSync: true } - ) - RETURN true - ` - }), - trx.step(async () => { - await query` - WITH claims, domains, domainsHTTPS, https, organizations - LET domainEdges = (FOR v, e IN 1..1 INBOUND ${domain._id} claims RETURN { edgeKey: e._key, domainId: e._to }) - FOR domainEdge in domainEdges - LET httpsEdges = (FOR v, e IN 1..1 OUTBOUND domainEdge.domainId domainsHTTPS RETURN { edgeKey: e._key, httpsId: e._to }) - LET removeHttpsEdges = ( - FOR httpsEdge IN httpsEdges - REMOVE httpsEdge.edgeKey IN domainsHTTPS - OPTIONS { waitForSync: true } - ) - LET removeHttps = ( - FOR httpsEdge IN httpsEdges - LET key = PARSE_IDENTIFIER(httpsEdge.httpsId).key - REMOVE key IN https - OPTIONS { waitForSync: true } - ) - RETURN true - ` - }), - trx.step(async () => { - await query` - WITH claims, domains, domainsSSL, organizations, ssl - LET domainEdges = (FOR v, e IN 1..1 INBOUND ${domain._id} claims RETURN { edgeKey: e._key, domainId: e._to }) - FOR domainEdge in domainEdges - LET sslEdges = (FOR v, e IN 1..1 OUTBOUND domainEdge.domainId domainsSSL RETURN { edgeKey: e._key, sslId: e._to}) - LET removeSslEdges = ( - FOR sslEdge IN sslEdges - REMOVE sslEdge.edgeKey IN domainsSSL - OPTIONS { waitForSync: true } - ) - LET removeSsl = ( - FOR sslEdge IN sslEdges - LET key = PARSE_IDENTIFIER(sslEdge.sslId).key - REMOVE key IN ssl - OPTIONS { waitForSync: true } - ) - RETURN true - ` - }), - ]) } catch (err) { console.error( - `Trx step error occurred while user: ${userKey} attempted to remove scan data for ${domain.slug} in org: ${org.slug}, error: ${err}`, + `Trx step error occurred while user: ${userKey} attempted to remove DKIM data for ${domain.domain} in org: ${org.slug}, error: ${err}`, ) throw new Error(i18n._(t`Unable to remove domain. Please try again.`)) } - // Remove domain try { + // Remove DMARC data await trx.step(async () => { await query` - WITH claims, domains, organizations - LET domainEdges = (FOR v, e IN 1..1 INBOUND ${domain._id} claims RETURN { edgeKey: e._key, domainId: e._to }) - LET removeDomainEdges = ( - FOR domainEdge in domainEdges - REMOVE domainEdge.edgeKey IN claims - OPTIONS { waitForSync: true } - ) - LET removeDomain = ( - FOR domainEdge in domainEdges - LET key = PARSE_IDENTIFIER(domainEdge.domainId).key - REMOVE key IN domains - OPTIONS { waitForSync: true } - ) - RETURN true + WITH dmarc + FOR dmarcV, domainsDmarcEdge IN 1..1 OUTBOUND ${domain._id} domainsDMARC + REMOVE dmarcV IN dmarc + REMOVE domainsDmarcEdge IN domainsDMARC + OPTIONS { waitForSync: true } + ` + }) + } catch (err) { + console.error( + `Trx step error occurred while user: ${userKey} attempted to remove DMARC data for ${domain.domain} in org: ${org.slug}, error: ${err}`, + ) + throw new Error(i18n._(t`Unable to remove domain. Please try again.`)) + } + + try { + // Remove HTTPS data + await trx.step(async () => { + await query` + WITH https + FOR httpsV, domainsHttpsEdge IN 1..1 OUTBOUND ${domain._id} domainsHTTPS + REMOVE httpsV IN https + REMOVE domainsHttpsEdge IN domainsHTTPS + OPTIONS { waitForSync: true } ` }) } catch (err) { console.error( - `Trx step error occurred while user: ${userKey} attempted to remove ${domain.slug} in org: ${org.slug}, error: ${err}`, + `Trx step error occurred while user: ${userKey} attempted to remove HTTPS data for ${domain.domain} in org: ${org.slug}, error: ${err}`, ) throw new Error(i18n._(t`Unable to remove domain. Please try again.`)) } + + try { + // Remove SPF data + await trx.step(async () => { + await query` + WITH spf + FOR spfV, domainsSpfEdge IN 1..1 OUTBOUND ${domain._id} domainsSPF + REMOVE spfV IN spf + REMOVE domainsSpfEdge IN domainsSPF + OPTIONS { waitForSync: true } + ` + }) + } catch (err) { + console.error( + `Trx step error occurred while user: ${userKey} attempted to remove SPF data for ${domain.domain} in org: ${org.slug}, error: ${err}`, + ) + throw new Error(i18n._(t`Unable to remove domain. Please try again.`)) + } + + try { + // Remove SSL data + await trx.step(async () => { + await query` + WITH ssl + FOR sslV, domainsSslEdge IN 1..1 OUTBOUND ${domain._id} domainsSSL + REMOVE sslV IN ssl + REMOVE domainsSslEdge IN domainsSSL + OPTIONS { waitForSync: true } + ` + }) + } catch (err) { + console.error( + `Trx step error occurred while user: ${userKey} attempted to remove SSL data for ${domain.domain} in org: ${org.slug}, error: ${err}`, + ) + throw new Error(i18n._(t`Unable to remove domain. Please try again.`)) + } + + try { + // Remove domain + await trx.step(async () => { + await query` + FOR claim IN claims + FILTER claim._to == ${domain._id} + REMOVE claim IN claims + REMOVE ${domain} IN domains + ` + }) + } catch (err) { + console.error( + `Trx step error occurred while user: ${userKey} attempted to remove domain for ${domain.domain} in org: ${org.slug}, error: ${err}`, + ) + throw new Error(i18n._(t`Unable to remove domain. Please try again.`)) + } + } else { try { await trx.step(async () => { @@ -372,7 +326,7 @@ export const removeDomain = new mutationWithClientMutationId({ }) } catch (err) { console.error( - `Trx step error occurred while user: ${userKey} attempted to remove claim for ${domain.slug} in org: ${org.slug}, error: ${err}`, + `Trx step error occurred while user: ${userKey} attempted to remove claim for ${domain.domain} in org: ${org.slug}, error: ${err}`, ) throw new Error(i18n._(t`Unable to remove domain. Please try again.`)) } @@ -383,18 +337,18 @@ export const removeDomain = new mutationWithClientMutationId({ await trx.commit() } catch (err) { console.error( - `Trx commit error occurred while user: ${userKey} attempted to remove ${domain.slug} in org: ${org.slug}, error: ${err}`, + `Trx commit error occurred while user: ${userKey} attempted to remove ${domain.domain} in org: ${org.slug}, error: ${err}`, ) throw new Error(i18n._(t`Unable to remove domain. Please try again.`)) } console.info( - `User: ${userKey} successfully removed domain: ${domain.slug} from org: ${org.slug}.`, + `User: ${userKey} successfully removed domain: ${domain.domain} from org: ${org.slug}.`, ) return { _type: 'result', status: i18n._( - t`Successfully removed domain: ${domain.slug} from ${org.slug}.`, + t`Successfully removed domain: ${domain.domain} from ${org.slug}.`, ), domain, } From 6824b9c5f3aff411351b8e6b68b4b360007ce96d Mon Sep 17 00:00:00 2001 From: Kyle Sullivan <141261s@acadiau.ca> Date: Wed, 1 Jun 2022 09:28:21 -0300 Subject: [PATCH 2/5] Use real domain instead of slug --- .../mutations/__tests__/remove-domain.test.js | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/api/src/domain/mutations/__tests__/remove-domain.test.js b/api/src/domain/mutations/__tests__/remove-domain.test.js index 2a2425c0b3..4242258ae6 100644 --- a/api/src/domain/mutations/__tests__/remove-domain.test.js +++ b/api/src/domain/mutations/__tests__/remove-domain.test.js @@ -297,7 +297,7 @@ describe('removing a domain', () => { data: { removeDomain: { result: { - status: `Successfully removed domain: test-gc-ca from communications-security-establishment.`, + status: `Successfully removed domain: test.gc.ca from communications-security-establishment.`, domain: { domain: 'test.gc.ca', }, @@ -308,7 +308,7 @@ describe('removing a domain', () => { expect(response).toEqual(expectedResponse) expect(consoleOutput).toEqual([ - `User: ${user._key} successfully removed domain: test-gc-ca from org: communications-security-establishment.`, + `User: ${user._key} successfully removed domain: test.gc.ca from org: communications-security-establishment.`, ]) }) }) @@ -386,7 +386,7 @@ describe('removing a domain', () => { removeDomain: { result: { status: - 'A réussi à supprimer le domaine : test-gc-ca de communications-security-establishment.', + 'A réussi à supprimer le domaine : test.gc.ca de communications-security-establishment.', domain: { domain: 'test.gc.ca', }, @@ -397,7 +397,7 @@ describe('removing a domain', () => { expect(response).toEqual(expectedResponse) expect(consoleOutput).toEqual([ - `User: ${user._key} successfully removed domain: test-gc-ca from org: communications-security-establishment.`, + `User: ${user._key} successfully removed domain: test.gc.ca from org: communications-security-establishment.`, ]) }) }) @@ -810,7 +810,7 @@ describe('removing a domain', () => { data: { removeDomain: { result: { - status: `Successfully removed domain: test-gc-ca from communications-security-establishment.`, + status: `Successfully removed domain: test.gc.ca from communications-security-establishment.`, domain: { domain: 'test.gc.ca', }, @@ -821,7 +821,7 @@ describe('removing a domain', () => { expect(response).toEqual(expectedResponse) expect(consoleOutput).toEqual([ - `User: ${user._key} successfully removed domain: test-gc-ca from org: communications-security-establishment.`, + `User: ${user._key} successfully removed domain: test.gc.ca from org: communications-security-establishment.`, ]) }) }) @@ -899,7 +899,7 @@ describe('removing a domain', () => { removeDomain: { result: { status: - 'A réussi à supprimer le domaine : test-gc-ca de communications-security-establishment.', + 'A réussi à supprimer le domaine : test.gc.ca de communications-security-establishment.', domain: { domain: 'test.gc.ca', }, @@ -910,7 +910,7 @@ describe('removing a domain', () => { expect(response).toEqual(expectedResponse) expect(consoleOutput).toEqual([ - `User: ${user._key} successfully removed domain: test-gc-ca from org: communications-security-establishment.`, + `User: ${user._key} successfully removed domain: test.gc.ca from org: communications-security-establishment.`, ]) }) }) @@ -1300,7 +1300,7 @@ describe('removing a domain', () => { data: { removeDomain: { result: { - status: `Successfully removed domain: test-gc-ca from treasury-board-secretariat.`, + status: `Successfully removed domain: test.gc.ca from treasury-board-secretariat.`, domain: { domain: 'test.gc.ca', }, @@ -1311,7 +1311,7 @@ describe('removing a domain', () => { expect(response).toEqual(expectedResponse) expect(consoleOutput).toEqual([ - `User: ${user._key} successfully removed domain: test-gc-ca from org: treasury-board-secretariat.`, + `User: ${user._key} successfully removed domain: test.gc.ca from org: treasury-board-secretariat.`, ]) }) }) @@ -1389,7 +1389,7 @@ describe('removing a domain', () => { removeDomain: { result: { status: - 'A réussi à supprimer le domaine : test-gc-ca de treasury-board-secretariat.', + 'A réussi à supprimer le domaine : test.gc.ca de treasury-board-secretariat.', domain: { domain: 'test.gc.ca', }, @@ -1400,7 +1400,7 @@ describe('removing a domain', () => { expect(response).toEqual(expectedResponse) expect(consoleOutput).toEqual([ - `User: ${user._key} successfully removed domain: test-gc-ca from org: treasury-board-secretariat.`, + `User: ${user._key} successfully removed domain: test.gc.ca from org: treasury-board-secretariat.`, ]) }) }) @@ -1818,7 +1818,7 @@ describe('removing a domain', () => { data: { removeDomain: { result: { - status: `Successfully removed domain: test-gc-ca from treasury-board-secretariat.`, + status: `Successfully removed domain: test.gc.ca from treasury-board-secretariat.`, domain: { domain: 'test.gc.ca', }, @@ -1829,7 +1829,7 @@ describe('removing a domain', () => { expect(response).toEqual(expectedResponse) expect(consoleOutput).toEqual([ - `User: ${user._key} successfully removed domain: test-gc-ca from org: treasury-board-secretariat.`, + `User: ${user._key} successfully removed domain: test.gc.ca from org: treasury-board-secretariat.`, ]) }) }) @@ -1907,7 +1907,7 @@ describe('removing a domain', () => { removeDomain: { result: { status: - 'A réussi à supprimer le domaine : test-gc-ca de treasury-board-secretariat.', + 'A réussi à supprimer le domaine : test.gc.ca de treasury-board-secretariat.', domain: { domain: 'test.gc.ca', }, @@ -1918,7 +1918,7 @@ describe('removing a domain', () => { expect(response).toEqual(expectedResponse) expect(consoleOutput).toEqual([ - `User: ${user._key} successfully removed domain: test-gc-ca from org: treasury-board-secretariat.`, + `User: ${user._key} successfully removed domain: test.gc.ca from org: treasury-board-secretariat.`, ]) }) }) @@ -2452,7 +2452,7 @@ describe('removing a domain', () => { data: { removeDomain: { result: { - status: `Successfully removed domain: test-gc-ca from treasury-board-secretariat.`, + status: `Successfully removed domain: test.gc.ca from treasury-board-secretariat.`, domain: { domain: 'test.gc.ca', }, @@ -2463,7 +2463,7 @@ describe('removing a domain', () => { expect(response).toEqual(expectedResponse) expect(consoleOutput).toEqual([ - `User: ${user._key} successfully removed domain: test-gc-ca from org: treasury-board-secretariat.`, + `User: ${user._key} successfully removed domain: test.gc.ca from org: treasury-board-secretariat.`, ]) }) }) @@ -2541,7 +2541,7 @@ describe('removing a domain', () => { removeDomain: { result: { status: - 'A réussi à supprimer le domaine : test-gc-ca de treasury-board-secretariat.', + 'A réussi à supprimer le domaine : test.gc.ca de treasury-board-secretariat.', domain: { domain: 'test.gc.ca', }, @@ -2552,7 +2552,7 @@ describe('removing a domain', () => { expect(response).toEqual(expectedResponse) expect(consoleOutput).toEqual([ - `User: ${user._key} successfully removed domain: test-gc-ca from org: treasury-board-secretariat.`, + `User: ${user._key} successfully removed domain: test.gc.ca from org: treasury-board-secretariat.`, ]) }) }) @@ -2936,7 +2936,7 @@ describe('removing a domain', () => { data: { removeDomain: { result: { - status: `Successfully removed domain: test-gc-ca from treasury-board-secretariat.`, + status: `Successfully removed domain: test.gc.ca from treasury-board-secretariat.`, domain: { domain: 'test.gc.ca', }, @@ -2947,7 +2947,7 @@ describe('removing a domain', () => { expect(response).toEqual(expectedResponse) expect(consoleOutput).toEqual([ - `User: ${user._key} successfully removed domain: test-gc-ca from org: treasury-board-secretariat.`, + `User: ${user._key} successfully removed domain: test.gc.ca from org: treasury-board-secretariat.`, ]) }) }) @@ -3025,7 +3025,7 @@ describe('removing a domain', () => { removeDomain: { result: { status: - 'A réussi à supprimer le domaine : test-gc-ca de treasury-board-secretariat.', + 'A réussi à supprimer le domaine : test.gc.ca de treasury-board-secretariat.', domain: { domain: 'test.gc.ca', }, @@ -3036,7 +3036,7 @@ describe('removing a domain', () => { expect(response).toEqual(expectedResponse) expect(consoleOutput).toEqual([ - `User: ${user._key} successfully removed domain: test-gc-ca from org: treasury-board-secretariat.`, + `User: ${user._key} successfully removed domain: test.gc.ca from org: treasury-board-secretariat.`, ]) }) }) From 6428864ef837fd2f3861eb20bc4055b71daacfef Mon Sep 17 00:00:00 2001 From: Kyle Sullivan <141261s@acadiau.ca> Date: Wed, 1 Jun 2022 09:34:25 -0300 Subject: [PATCH 3/5] Use domain name instead of slug --- .../mutations/__tests__/remove-domain.test.js | 104 +++++++++--------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/api/src/domain/mutations/__tests__/remove-domain.test.js b/api/src/domain/mutations/__tests__/remove-domain.test.js index 4242258ae6..123d37ca6e 100644 --- a/api/src/domain/mutations/__tests__/remove-domain.test.js +++ b/api/src/domain/mutations/__tests__/remove-domain.test.js @@ -3583,7 +3583,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -3610,7 +3610,7 @@ describe('removing a domain', () => { expect(response).toEqual(error) expect(consoleOutput).toEqual([ - `User: 123 attempted to remove domain-gc-ca in temp-org but does not have permission to remove a domain from a verified check org.`, + `User: 123 attempted to remove domain.gc.ca in temp-org but does not have permission to remove a domain from a verified check org.`, ]) }) }) @@ -3658,7 +3658,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -3685,7 +3685,7 @@ describe('removing a domain', () => { expect(response).toEqual(error) expect(consoleOutput).toEqual([ - `User: 123 attempted to remove domain-gc-ca in temp-org but does not have permission to remove a domain from a verified check org.`, + `User: 123 attempted to remove domain.gc.ca in temp-org but does not have permission to remove a domain from a verified check org.`, ]) }) }) @@ -3733,7 +3733,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -3760,7 +3760,7 @@ describe('removing a domain', () => { expect(response).toEqual(error) expect(consoleOutput).toEqual([ - `User: 123 attempted to remove domain-gc-ca in temp-org but does not have permission to remove a domain from a verified check org.`, + `User: 123 attempted to remove domain.gc.ca in temp-org but does not have permission to remove a domain from a verified check org.`, ]) }) }) @@ -3810,7 +3810,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -3837,7 +3837,7 @@ describe('removing a domain', () => { expect(response).toEqual(error) expect(consoleOutput).toEqual([ - `User: 123 attempted to remove domain-gc-ca in temp-org however they do not have permission in that org.`, + `User: 123 attempted to remove domain.gc.ca in temp-org however they do not have permission in that org.`, ]) }) }) @@ -3885,7 +3885,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -3912,7 +3912,7 @@ describe('removing a domain', () => { expect(response).toEqual(error) expect(consoleOutput).toEqual([ - `User: 123 attempted to remove domain-gc-ca in temp-org however they do not have permission in that org.`, + `User: 123 attempted to remove domain.gc.ca in temp-org however they do not have permission in that org.`, ]) }) }) @@ -3962,7 +3962,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -3981,7 +3981,7 @@ describe('removing a domain', () => { expect(response.errors).toEqual(error) expect(consoleOutput).toEqual([ - `Database error occurred for user: 123, when counting domain claims for domain: domain-gc-ca, error: Error: database error`, + `Database error occurred for user: 123, when counting domain claims for domain: domain.gc.ca, error: Error: database error`, ]) }) }) @@ -4032,7 +4032,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -4051,7 +4051,7 @@ describe('removing a domain', () => { expect(response.errors).toEqual(error) expect(consoleOutput).toEqual([ - `Database error occurred for user: 123, when counting ownership claims for domain: domain-gc-ca, error: Error: database error`, + `Database error occurred for user: 123, when counting ownership claims for domain: domain.gc.ca, error: Error: database error`, ]) }) }) @@ -4106,7 +4106,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -4125,7 +4125,7 @@ describe('removing a domain', () => { expect(response.errors).toEqual(error) expect(consoleOutput).toEqual([ - `Trx step error occurred when removing dmarc summary data for user: 123 while attempting to remove domain: domain-gc-ca, error: Error: trx step error`, + `Trx step error occurred when removing dmarc summary data for user: 123 while attempting to remove domain: domain.gc.ca, error: Error: trx step error`, ]) }) }) @@ -4180,7 +4180,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -4199,7 +4199,7 @@ describe('removing a domain', () => { expect(response.errors).toEqual(error) expect(consoleOutput).toEqual([ - `Trx step error occurred when removing ownership data for user: 123 while attempting to remove domain: domain-gc-ca, error: Error: trx step error`, + `Trx step error occurred when removing ownership data for user: 123 while attempting to remove domain: domain.gc.ca, error: Error: trx step error`, ]) }) }) @@ -4259,7 +4259,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -4278,7 +4278,7 @@ describe('removing a domain', () => { expect(response.errors).toEqual(error) expect(consoleOutput).toEqual([ - `Trx step error occurred while user: 123 attempted to remove scan data for domain-gc-ca in org: temp-org, error: Error: Transaction error occurred.`, + `Trx step error occurred while user: 123 attempted to remove scan data for domain.gc.ca in org: temp-org, error: Error: Transaction error occurred.`, ]) }) }) @@ -4341,7 +4341,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -4360,7 +4360,7 @@ describe('removing a domain', () => { expect(response.errors).toEqual(error) expect(consoleOutput).toEqual([ - `Trx step error occurred while user: 123 attempted to remove domain-gc-ca in org: temp-org, error: Error: Step error`, + `Trx step error occurred while user: 123 attempted to remove domain.gc.ca in org: temp-org, error: Error: Step error`, ]) }) }) @@ -4418,7 +4418,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -4437,7 +4437,7 @@ describe('removing a domain', () => { expect(response.errors).toEqual(error) expect(consoleOutput).toEqual([ - `Trx step error occurred while user: 123 attempted to remove claim for domain-gc-ca in org: temp-org, error: Error: Step error`, + `Trx step error occurred while user: 123 attempted to remove claim for domain.gc.ca in org: temp-org, error: Error: Step error`, ]) }) }) @@ -4494,7 +4494,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -4513,7 +4513,7 @@ describe('removing a domain', () => { expect(response.errors).toEqual(error) expect(consoleOutput).toEqual([ - `Trx commit error occurred while user: 123 attempted to remove domain-gc-ca in org: temp-org, error: Error: Transaction error occurred.`, + `Trx commit error occurred while user: 123 attempted to remove domain.gc.ca in org: temp-org, error: Error: Transaction error occurred.`, ]) }) }) @@ -4717,7 +4717,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -4744,7 +4744,7 @@ describe('removing a domain', () => { expect(response).toEqual(error) expect(consoleOutput).toEqual([ - `User: 123 attempted to remove domain-gc-ca in temp-org but does not have permission to remove a domain from a verified check org.`, + `User: 123 attempted to remove domain.gc.ca in temp-org but does not have permission to remove a domain from a verified check org.`, ]) }) }) @@ -4792,7 +4792,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -4819,7 +4819,7 @@ describe('removing a domain', () => { expect(response).toEqual(error) expect(consoleOutput).toEqual([ - `User: 123 attempted to remove domain-gc-ca in temp-org but does not have permission to remove a domain from a verified check org.`, + `User: 123 attempted to remove domain.gc.ca in temp-org but does not have permission to remove a domain from a verified check org.`, ]) }) }) @@ -4867,7 +4867,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -4894,7 +4894,7 @@ describe('removing a domain', () => { expect(response).toEqual(error) expect(consoleOutput).toEqual([ - `User: 123 attempted to remove domain-gc-ca in temp-org but does not have permission to remove a domain from a verified check org.`, + `User: 123 attempted to remove domain.gc.ca in temp-org but does not have permission to remove a domain from a verified check org.`, ]) }) }) @@ -4944,7 +4944,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -4971,7 +4971,7 @@ describe('removing a domain', () => { expect(response).toEqual(error) expect(consoleOutput).toEqual([ - `User: 123 attempted to remove domain-gc-ca in temp-org however they do not have permission in that org.`, + `User: 123 attempted to remove domain.gc.ca in temp-org however they do not have permission in that org.`, ]) }) }) @@ -5019,7 +5019,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -5046,7 +5046,7 @@ describe('removing a domain', () => { expect(response).toEqual(error) expect(consoleOutput).toEqual([ - `User: 123 attempted to remove domain-gc-ca in temp-org however they do not have permission in that org.`, + `User: 123 attempted to remove domain.gc.ca in temp-org however they do not have permission in that org.`, ]) }) }) @@ -5096,7 +5096,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -5117,7 +5117,7 @@ describe('removing a domain', () => { expect(response.errors).toEqual(error) expect(consoleOutput).toEqual([ - `Database error occurred for user: 123, when counting domain claims for domain: domain-gc-ca, error: Error: database error`, + `Database error occurred for user: 123, when counting domain claims for domain: domain.gc.ca, error: Error: database error`, ]) }) }) @@ -5168,7 +5168,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -5189,7 +5189,7 @@ describe('removing a domain', () => { expect(response.errors).toEqual(error) expect(consoleOutput).toEqual([ - `Database error occurred for user: 123, when counting ownership claims for domain: domain-gc-ca, error: Error: database error`, + `Database error occurred for user: 123, when counting ownership claims for domain: domain.gc.ca, error: Error: database error`, ]) }) }) @@ -5244,7 +5244,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -5265,7 +5265,7 @@ describe('removing a domain', () => { expect(response.errors).toEqual(error) expect(consoleOutput).toEqual([ - `Trx step error occurred when removing dmarc summary data for user: 123 while attempting to remove domain: domain-gc-ca, error: Error: trx step error`, + `Trx step error occurred when removing dmarc summary data for user: 123 while attempting to remove domain: domain.gc.ca, error: Error: trx step error`, ]) }) }) @@ -5320,7 +5320,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -5341,7 +5341,7 @@ describe('removing a domain', () => { expect(response.errors).toEqual(error) expect(consoleOutput).toEqual([ - `Trx step error occurred when removing ownership data for user: 123 while attempting to remove domain: domain-gc-ca, error: Error: trx step error`, + `Trx step error occurred when removing ownership data for user: 123 while attempting to remove domain: domain.gc.ca, error: Error: trx step error`, ]) }) }) @@ -5401,7 +5401,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -5422,7 +5422,7 @@ describe('removing a domain', () => { expect(response.errors).toEqual(error) expect(consoleOutput).toEqual([ - `Trx step error occurred while user: 123 attempted to remove scan data for domain-gc-ca in org: temp-org, error: Error: Transaction error occurred.`, + `Trx step error occurred while user: 123 attempted to remove scan data for domain.gc.ca in org: temp-org, error: Error: Transaction error occurred.`, ]) }) }) @@ -5485,7 +5485,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -5506,7 +5506,7 @@ describe('removing a domain', () => { expect(response.errors).toEqual(error) expect(consoleOutput).toEqual([ - `Trx step error occurred while user: 123 attempted to remove domain-gc-ca in org: temp-org, error: Error: Step error`, + `Trx step error occurred while user: 123 attempted to remove domain.gc.ca in org: temp-org, error: Error: Step error`, ]) }) }) @@ -5564,7 +5564,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -5585,7 +5585,7 @@ describe('removing a domain', () => { expect(response.errors).toEqual(error) expect(consoleOutput).toEqual([ - `Trx step error occurred while user: 123 attempted to remove claim for domain-gc-ca in org: temp-org, error: Error: Step error`, + `Trx step error occurred while user: 123 attempted to remove claim for domain.gc.ca in org: temp-org, error: Error: Step error`, ]) }) }) @@ -5642,7 +5642,7 @@ describe('removing a domain', () => { loaders: { loadDomainByKey: { load: jest.fn().mockReturnValue({ - slug: 'domain-gc-ca', + domain: 'domain.gc.ca', }), }, loadOrgByKey: { @@ -5663,7 +5663,7 @@ describe('removing a domain', () => { expect(response.errors).toEqual(error) expect(consoleOutput).toEqual([ - `Trx commit error occurred while user: 123 attempted to remove domain-gc-ca in org: temp-org, error: Error: Transaction error occurred.`, + `Trx commit error occurred while user: 123 attempted to remove domain.gc.ca in org: temp-org, error: Error: Transaction error occurred.`, ]) }) }) From e67770e56bbc55a4bb572ca1e2d8d6c5bce89a04 Mon Sep 17 00:00:00 2001 From: Kyle Sullivan <141261s@acadiau.ca> Date: Wed, 1 Jun 2022 09:50:24 -0300 Subject: [PATCH 4/5] Fix mocked transactions --- .../domain/mutations/__tests__/remove-domain.test.js | 10 ++++------ api/src/domain/mutations/remove-domain.js | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/api/src/domain/mutations/__tests__/remove-domain.test.js b/api/src/domain/mutations/__tests__/remove-domain.test.js index 123d37ca6e..556ae200cc 100644 --- a/api/src/domain/mutations/__tests__/remove-domain.test.js +++ b/api/src/domain/mutations/__tests__/remove-domain.test.js @@ -4278,7 +4278,7 @@ describe('removing a domain', () => { expect(response.errors).toEqual(error) expect(consoleOutput).toEqual([ - `Trx step error occurred while user: 123 attempted to remove scan data for domain.gc.ca in org: temp-org, error: Error: Transaction error occurred.`, + `Trx step error occurred while user: 123 attempted to remove DKIM data for domain.gc.ca in org: temp-org, error: Error: Transaction error occurred.`, ]) }) }) @@ -4295,7 +4295,6 @@ describe('removing a domain', () => { .mockReturnValueOnce() .mockReturnValueOnce() .mockReturnValueOnce() - .mockReturnValueOnce() .mockRejectedValue(new Error('Step error')), }) @@ -4360,7 +4359,7 @@ describe('removing a domain', () => { expect(response.errors).toEqual(error) expect(consoleOutput).toEqual([ - `Trx step error occurred while user: 123 attempted to remove domain.gc.ca in org: temp-org, error: Error: Step error`, + `Trx step error occurred while user: 123 attempted to remove domain domain.gc.ca in org: temp-org, error: Error: Step error`, ]) }) }) @@ -5422,7 +5421,7 @@ describe('removing a domain', () => { expect(response.errors).toEqual(error) expect(consoleOutput).toEqual([ - `Trx step error occurred while user: 123 attempted to remove scan data for domain.gc.ca in org: temp-org, error: Error: Transaction error occurred.`, + `Trx step error occurred while user: 123 attempted to remove DKIM data for domain.gc.ca in org: temp-org, error: Error: Transaction error occurred.`, ]) }) }) @@ -5439,7 +5438,6 @@ describe('removing a domain', () => { .mockReturnValueOnce() .mockReturnValueOnce() .mockReturnValueOnce() - .mockReturnValueOnce() .mockRejectedValue(new Error('Step error')), }) @@ -5506,7 +5504,7 @@ describe('removing a domain', () => { expect(response.errors).toEqual(error) expect(consoleOutput).toEqual([ - `Trx step error occurred while user: 123 attempted to remove domain.gc.ca in org: temp-org, error: Error: Step error`, + `Trx step error occurred while user: 123 attempted to remove domain domain.gc.ca in org: temp-org, error: Error: Step error`, ]) }) }) diff --git a/api/src/domain/mutations/remove-domain.js b/api/src/domain/mutations/remove-domain.js index 842dd97878..8705c567df 100644 --- a/api/src/domain/mutations/remove-domain.js +++ b/api/src/domain/mutations/remove-domain.js @@ -302,7 +302,7 @@ export const removeDomain = new mutationWithClientMutationId({ }) } catch (err) { console.error( - `Trx step error occurred while user: ${userKey} attempted to remove domain for ${domain.domain} in org: ${org.slug}, error: ${err}`, + `Trx step error occurred while user: ${userKey} attempted to remove domain ${domain.domain} in org: ${org.slug}, error: ${err}`, ) throw new Error(i18n._(t`Unable to remove domain. Please try again.`)) } From cb74465e46154575ca3e0e92ae9376815094d31f Mon Sep 17 00:00:00 2001 From: Kyle Sullivan <141261s@acadiau.ca> Date: Wed, 1 Jun 2022 16:35:32 -0300 Subject: [PATCH 5/5] Unskip tests --- api/src/domain/mutations/__tests__/remove-domain.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/domain/mutations/__tests__/remove-domain.test.js b/api/src/domain/mutations/__tests__/remove-domain.test.js index 556ae200cc..51bdb07316 100644 --- a/api/src/domain/mutations/__tests__/remove-domain.test.js +++ b/api/src/domain/mutations/__tests__/remove-domain.test.js @@ -1467,7 +1467,7 @@ describe('removing a domain', () => { const domainCheck = await domainCursor.next() expect(domainCheck).toEqual(undefined) }) - it.skip('removes all scan data', async () => { + it('removes all scan data', async () => { await graphql( schema, ` @@ -1985,7 +1985,7 @@ describe('removing a domain', () => { const domainCheck = await domainCursor.next() expect(domainCheck).toEqual(undefined) }) - it.skip('removes all scan data', async () => { + it('removes all scan data', async () => { await graphql( schema, ` @@ -3103,7 +3103,7 @@ describe('removing a domain', () => { const domainCheck = await domainCursor.next() expect(domainCheck).toEqual(undefined) }) - it.skip('removes all scan data', async () => { + it('removes all scan data', async () => { await graphql( schema, `