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

Remove ability to modify domain name #5711

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
49 changes: 29 additions & 20 deletions api/src/domain/mutations/__tests__/update-domain.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ describe('updating a domain', () => {
_to: domain._id,
_from: org._id,
tags: [],
assetState: 'monitor-only',
})
})
afterEach(async () => {
Expand All @@ -142,7 +143,7 @@ describe('updating a domain', () => {
input: {
domainId: "${toGlobalId('domain', domain._key)}"
orgId: "${toGlobalId('organization', org._key)}"
domain: "test.canada.ca"
assetState: APPROVED
}
) {
result {
Expand All @@ -151,6 +152,7 @@ describe('updating a domain', () => {
domain
lastRan
selectors
assetState
}
}
}
Expand Down Expand Up @@ -200,9 +202,10 @@ describe('updating a domain', () => {
updateDomain: {
result: {
id: toGlobalId('domain', domain._key),
domain: 'test.canada.ca',
domain: 'test.gc.ca',
lastRan: null,
selectors: ['selector1', 'selector2'],
assetState: 'APPROVED',
},
},
},
Expand Down Expand Up @@ -231,7 +234,7 @@ describe('updating a domain', () => {
input: {
domainId: "${toGlobalId('domain', domain._key)}"
orgId: "${toGlobalId('organization', org._key)}"
domain: "test.canada.ca"
assetState: APPROVED
}
) {
result {
Expand All @@ -240,6 +243,7 @@ describe('updating a domain', () => {
domain
lastRan
selectors
assetState
}
}
}
Expand Down Expand Up @@ -289,9 +293,10 @@ describe('updating a domain', () => {
updateDomain: {
result: {
id: toGlobalId('domain', domain._key),
domain: 'test.canada.ca',
domain: 'test.gc.ca',
lastRan: null,
selectors: ['selector1', 'selector2'],
assetState: 'APPROVED',
},
},
},
Expand Down Expand Up @@ -320,7 +325,7 @@ describe('updating a domain', () => {
input: {
domainId: "${toGlobalId('domain', domain._key)}"
orgId: "${toGlobalId('organization', org._key)}"
domain: "test.canada.ca"
assetState: APPROVED
}
) {
result {
Expand All @@ -329,6 +334,7 @@ describe('updating a domain', () => {
domain
lastRan
selectors
assetState
}
}
}
Expand Down Expand Up @@ -378,9 +384,10 @@ describe('updating a domain', () => {
updateDomain: {
result: {
id: toGlobalId('domain', domain._key),
domain: 'test.canada.ca',
domain: 'test.gc.ca',
lastRan: null,
selectors: ['selector1', 'selector2'],
assetState: 'APPROVED',
},
},
},
Expand Down Expand Up @@ -419,7 +426,7 @@ describe('updating a domain', () => {
input: {
domainId: "${toGlobalId('domain', 1)}"
orgId: "${toGlobalId('organization', 1)}"
domain: "test.canada.ca"
assetState: APPROVED
}
) {
result {
Expand All @@ -428,6 +435,7 @@ describe('updating a domain', () => {
domain
lastRan
selectors
assetState
}
... on DomainError {
code
Expand Down Expand Up @@ -500,7 +508,7 @@ describe('updating a domain', () => {
input: {
domainId: "${toGlobalId('domain', 123)}"
orgId: "${toGlobalId('organization', 1)}"
domain: "test.canada.ca"
assetState: APPROVED
}
) {
result {
Expand All @@ -509,6 +517,7 @@ describe('updating a domain', () => {
domain
lastRan
selectors
assetState
}
... on DomainError {
code
Expand Down Expand Up @@ -581,7 +590,7 @@ describe('updating a domain', () => {
input: {
domainId: "${toGlobalId('domain', 123)}"
orgId: "${toGlobalId('organization', 123)}"
domain: "test.canada.ca"
assetState: APPROVED
}
) {
result {
Expand Down Expand Up @@ -663,7 +672,7 @@ describe('updating a domain', () => {
input: {
domainId: "${toGlobalId('domain', 123)}"
orgId: "${toGlobalId('organization', 123)}"
domain: "test.canada.ca"
assetState: APPROVED
}
) {
result {
Expand Down Expand Up @@ -745,7 +754,7 @@ describe('updating a domain', () => {
input: {
domainId: "${toGlobalId('domain', 123)}"
orgId: "${toGlobalId('organization', 123)}"
domain: "test.canada.ca"
assetState: APPROVED
}
) {
result {
Expand Down Expand Up @@ -819,7 +828,7 @@ describe('updating a domain', () => {
input: {
domainId: "${toGlobalId('domain', 123)}"
orgId: "${toGlobalId('organization', 123)}"
domain: "test.canada.ca"
assetState: APPROVED
}
) {
result {
Expand Down Expand Up @@ -894,7 +903,7 @@ describe('updating a domain', () => {
input: {
domainId: "${toGlobalId('domain', 123)}"
orgId: "${toGlobalId('organization', 123)}"
domain: "test.canada.ca"
assetState: APPROVED
}
) {
result {
Expand Down Expand Up @@ -987,7 +996,7 @@ describe('updating a domain', () => {
input: {
domainId: "${toGlobalId('domain', 1)}"
orgId: "${toGlobalId('organization', 1)}"
domain: "test.canada.ca"
assetState: APPROVED
}
) {
result {
Expand Down Expand Up @@ -1068,7 +1077,7 @@ describe('updating a domain', () => {
input: {
domainId: "${toGlobalId('domain', 123)}"
orgId: "${toGlobalId('organization', 1)}"
domain: "test.canada.ca"
assetState: APPROVED
}
) {
result {
Expand Down Expand Up @@ -1149,7 +1158,7 @@ describe('updating a domain', () => {
input: {
domainId: "${toGlobalId('domain', 123)}"
orgId: "${toGlobalId('organization', 123)}"
domain: "test.canada.ca"
assetState: APPROVED
}
) {
result {
Expand Down Expand Up @@ -1231,7 +1240,7 @@ describe('updating a domain', () => {
input: {
domainId: "${toGlobalId('domain', 123)}"
orgId: "${toGlobalId('organization', 123)}"
domain: "test.canada.ca"
assetState: APPROVED
}
) {
result {
Expand Down Expand Up @@ -1313,7 +1322,7 @@ describe('updating a domain', () => {
input: {
domainId: "${toGlobalId('domain', 123)}"
orgId: "${toGlobalId('organization', 123)}"
domain: "test.canada.ca"
assetState: APPROVED
}
) {
result {
Expand Down Expand Up @@ -1387,7 +1396,7 @@ describe('updating a domain', () => {
input: {
domainId: "${toGlobalId('domain', 123)}"
orgId: "${toGlobalId('organization', 123)}"
domain: "test.canada.ca"
assetState: APPROVED
}
) {
result {
Expand Down Expand Up @@ -1462,7 +1471,7 @@ describe('updating a domain', () => {
input: {
domainId: "${toGlobalId('domain', 123)}"
orgId: "${toGlobalId('organization', 123)}"
domain: "test.canada.ca"
assetState: APPROVED
}
) {
result {
Expand Down
16 changes: 0 additions & 16 deletions api/src/domain/mutations/update-domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { mutationWithClientMutationId, fromGlobalId } from 'graphql-relay'
import { t } from '@lingui/macro'

import { updateDomainUnion } from '../unions'
import { Domain } from '../../scalars'
import { logActivity } from '../../audit-logs/mutations/log-activity'
import { inputTag } from '../inputs/domain-tag'
import { AssetStateEnums } from '../../enums'
Expand All @@ -20,10 +19,6 @@ export const updateDomain = new mutationWithClientMutationId({
type: new GraphQLNonNull(GraphQLID),
description: 'The global ID of the organization used for permission checks.',
},
domain: {
type: Domain,
description: 'The new url of the of the old domain.',
},
tags: {
description: 'List of labelled tags users have applied to the domain.',
type: new GraphQLList(inputTag),
Expand Down Expand Up @@ -70,7 +65,6 @@ export const updateDomain = new mutationWithClientMutationId({

const { id: domainId } = fromGlobalId(cleanseInput(args.domainId))
const { id: orgId } = fromGlobalId(cleanseInput(args.orgId))
const updatedDomain = cleanseInput(args.domain)

let tags
if (typeof args.tags !== 'undefined') {
Expand Down Expand Up @@ -167,8 +161,6 @@ export const updateDomain = new mutationWithClientMutationId({

// Update domain
const domainToInsert = {
domain: updatedDomain.toLowerCase() || domain.domain.toLowerCase(),
lastRan: domain.lastRan,
archived: typeof archived !== 'undefined' ? archived : domain?.archived,
ignoreRua: typeof args.ignoreRua !== 'undefined' ? args.ignoreRua : domain?.ignoreRua,
}
Expand Down Expand Up @@ -250,14 +242,6 @@ export const updateDomain = new mutationWithClientMutationId({
console.info(`User: ${userKey} successfully updated domain: ${domainId}.`)

const updatedProperties = []
if (domainToInsert.domain.toLowerCase() !== domain.domain.toLowerCase()) {
updatedProperties.push({
name: 'domain',
oldValue: domain.domain,
newValue: domainToInsert.domain,
})
}

if (typeof assetState !== 'undefined') {
updatedProperties.push({
name: 'assetState',
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/admin/AdminDomainModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ export function AdminDomainModal({ isOpen, onClose, validationSchema, orgId, ...
variables: {
domainId: editingDomainId,
orgId: orgId,
domain: values.domainUrl.trim(),
tags: values.tags,
archived: values.archiveDomain,
assetState: values.assetState,
Expand Down Expand Up @@ -235,7 +234,14 @@ export function AdminDomainModal({ isOpen, onClose, validationSchema, orgId, ...
<ModalCloseButton />
<ModalBody>
<Stack spacing={4} p={25}>
<DomainField name="domainUrl" label={t`New Domain URL:`} placeholder={t`New Domain URL`} />
{mutation === 'create' ? (
<DomainField name="domainUrl" label={t`New Domain URL:`} placeholder={t`New Domain URL`} />
) : (
<Box>
<Text fontWeight="bold">Domain:</Text>
<Text flexWrap="wrap">{editingDomainUrl}</Text>
</Box>
)}
<FieldArray
name="tags"
render={(arrayHelpers) => (
Expand Down
13 changes: 2 additions & 11 deletions frontend/src/admin/__tests__/AdminDomains.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ describe('<AdminDomains />', () => {
})

describe('editing a domain', () => {
it('successfully edits domain URL', async () => {
it('successfully edits domain details', async () => {
const mocks = [
{
request: {
Expand All @@ -495,9 +495,7 @@ describe('<AdminDomains />', () => {
variables: {
domainId: 'testid2=',
orgId: 'testid=',
domain: 'test.domain.ca',
tags: [],

archived: false,
assetState: 'MONITOR_ONLY',
},
Expand All @@ -516,7 +514,7 @@ describe('<AdminDomains />', () => {
},
]

const { getByText, findByTestId, getByLabelText, queryByText, findByRole } = render(
const { getByText, findByTestId, queryByText, findByRole } = render(
<MockedProvider mocks={mocks} cache={createCache()}>
<UserVarProvider
userVar={makeVar({
Expand Down Expand Up @@ -546,13 +544,6 @@ describe('<AdminDomains />', () => {

await waitFor(() => expect(getByText(/Edit Domain Details/i)).toBeInTheDocument())

const editDomainInput = getByLabelText(/Domain URL:/)
fireEvent.change(editDomainInput, {
target: {
value: 'test.domain.ca',
},
})

const assetStateSelect = await findByRole('combobox', { name: /Asset State/ })

fireEvent.change(assetStateSelect, {
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/graphql/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ export const UPDATE_DOMAIN = gql`
mutation UpdateDomain(
$domainId: ID!
$orgId: ID!
$domain: DomainScalar
$tags: [InputTag]
$archived: Boolean
$assetState: AssetStateEnums
Expand All @@ -273,7 +272,6 @@ export const UPDATE_DOMAIN = gql`
input: {
domainId: $domainId
orgId: $orgId
domain: $domain
tags: $tags
archived: $archived
assetState: $assetState
Expand Down
Loading