Skip to content

Commit

Permalink
Merge pull request #7256 from TheThingsNetwork/merge/redesign-managed…
Browse files Browse the repository at this point in the history
…-gateway

Merge managed gateway work into redesign
  • Loading branch information
kschiffer authored Aug 20, 2024
2 parents 6b7cded + d49a51a commit 9843f67
Show file tree
Hide file tree
Showing 88 changed files with 4,943 additions and 212 deletions.
6 changes: 3 additions & 3 deletions config/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3934,16 +3934,16 @@
},
"error:pkg/deviceclaimingserver/gateways/ttgc:dial_gateway_server": {
"translations": {
"en": "dial Gateway Gerver"
"en": "dial Gateway Gerver `{address}`"
},
"description": {
"package": "pkg/deviceclaimingserver/gateways/ttgc",
"file": "root_ca.go"
}
},
"error:pkg/deviceclaimingserver/gateways/ttgc:gateway_server_tls": {
"error:pkg/deviceclaimingserver/gateways/ttgc:verify_gateway_server_tls": {
"translations": {
"en": "establish TLS connection with Gateway Server"
"en": "verify TLS server certificate of Gateway Server `{address}`"
},
"description": {
"package": "pkg/deviceclaimingserver/gateways/ttgc",
Expand Down
97 changes: 93 additions & 4 deletions cypress/e2e/console/gateways/create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('Gateway create', () => {
cy.findByTestId('error-notification').should('not.exist')
})

it('displays claiming gateway form', () => {
it('displays claiming non-managed gateway form', () => {
const gateway = {
frequency_plan: 'EU_863_870',
eui: '58A0CBFFFE000001',
Expand All @@ -107,12 +107,13 @@ describe('Gateway create', () => {
cy.intercept('POST', '/api/v3/gcls/claim/info', {
body: {
supports_claiming: true,
is_managed: false,
},
})

cy.findByLabelText('Gateway EUI').type(gateway.eui)
cy.findByRole('button', { name: 'Confirm' }).click()
cy.findByTestId('notification').should('exist')
cy.findByTestId('notification').should('not.exist')
cy.findByLabelText('Claim authentication code').type('12345')
cy.findByLabelText('Gateway ID').type(`eui-${gateway.eui}`)
cy.findByText('Frequency plan')
Expand All @@ -122,7 +123,7 @@ describe('Gateway create', () => {
.selectOption(gateway.frequency_plan)
})

it('succeeds claiming gateway', () => {
it('succeeds claiming non-managed gateway', () => {
const gateway = {
frequency_plan: 'EU_863_870',
eui: generateHexValue(16),
Expand All @@ -141,10 +142,11 @@ describe('Gateway create', () => {
target_frequency_plan_id: gateway.frequency_plan,
target_gateway_server_address: window.location.hostname,
}
cy.intercept('GET', '/api/v3/gateways/*', { statusCode: 200 })
cy.intercept('GET', '/api/v3/gateways/!*', { statusCode: 200 })
cy.intercept('POST', '/api/v3/gcls/claim/info', {
body: {
supports_claiming: true,
is_managed: false,
},
})

Expand All @@ -158,6 +160,7 @@ describe('Gateway create', () => {

cy.findByLabelText('Gateway EUI').type(gateway.eui)
cy.findByRole('button', { name: 'Confirm' }).click()
cy.findByTestId('notification').should('not.exist')
cy.findByLabelText('Frequency plan').selectOption(gateway.frequency_plan)
cy.findByLabelText('Gateway ID').type(`eui-${gateway.eui}`)
cy.findByLabelText('Claim authentication code').type('12345')
Expand All @@ -171,6 +174,92 @@ describe('Gateway create', () => {
)
})

it('displays claiming managed gateway form', () => {
const gateway = {
frequency_plan: 'EU_863_870',
eui: '58A0CBFFFE000001',
}

cy.intercept('POST', '/api/v3/gcls/claim/info', {
body: {
supports_claiming: true,
is_managed: true,
},
})

cy.findByLabelText('Gateway EUI').type(gateway.eui)
cy.findByRole('button', { name: 'Confirm' }).click()
cy.findByTestId('notification').should('be.visible')
cy.findByLabelText('Claim authentication code').type('12345')
cy.findByLabelText('Gateway ID').type(`eui-${gateway.eui}`)
cy.findByText('Frequency plan')
.parents('div[data-test-id="form-field"]')
.find('input')
.first()
.selectOption(gateway.frequency_plan)
})

it('succeeds claiming managed gateway', () => {
const gateway = {
frequency_plan: 'EU_863_870',
eui: generateHexValue(16),
}
const expectedRequest = {
collaborator: {
user_ids: {
user_id: user.ids.user_id,
},
},
authenticated_identifiers: {
gateway_eui: gateway.eui.toUpperCase(),
authentication_code: 'MTIzNDU=',
},
target_gateway_id: `eui-${gateway.eui}`,
target_frequency_plan_id: gateway.frequency_plan,
target_gateway_server_address: window.location.hostname,
}
cy.intercept('GET', '/api/v3/gateways/*', { statusCode: 200 })
cy.intercept('POST', '/api/v3/gcls/claim/info', {
body: {
supports_claiming: true,
is_managed: true,
},
})

cy.intercept('POST', '/api/v3/gcls/claim', {
statusCode: 201,
body: {
gateway_id: `eui-${gateway.eui}`,
eui: gateway.eui,
},
}).as('claim-request')

cy.findByLabelText('Gateway EUI').type(gateway.eui)
cy.findByRole('button', { name: 'Confirm' }).click()
cy.findByTestId('notification').should('be.visible')
cy.findByLabelText('Frequency plan').selectOption(gateway.frequency_plan)
cy.findByLabelText('Gateway ID').type(`eui-${gateway.eui}`)
cy.findByLabelText('Claim authentication code').type('12345')
cy.findByRole('button', { name: 'Claim gateway' }).click()
cy.wait('@claim-request').its('request.body').should('deep.equal', expectedRequest)
cy.findByTestId('error-notification').should('not.exist')

cy.location('pathname').should(
'eq',
`${Cypress.config('consoleRootPath')}/gateways/eui-${gateway.eui}/managed-gateway/connection-settings`,
)

cy.intercept('GET', `/api/v3/gcs/gateways/managed/eui-${gateway.eui}*`, {
statusCode: 200,
body: {
ids: {
gateway_id: `eui-${gateway.eui}`,
eui: gateway.eui,
},
},
})
})

it('succeeds adding gateway without frequency plan and without EUI', () => {
const gateway = {
gateway_id: 'gateway-without-fp-eui',
Expand Down
Loading

0 comments on commit 9843f67

Please sign in to comment.