diff --git a/frontend/src/js/components/common/dialogs/physicaldeviceonboarding.js b/frontend/src/js/components/common/dialogs/physicaldeviceonboarding.js index 8e9ea18d..1edab511 100644 --- a/frontend/src/js/components/common/dialogs/physicaldeviceonboarding.js +++ b/frontend/src/js/components/common/dialogs/physicaldeviceonboarding.js @@ -30,7 +30,8 @@ import { getIsEnterprise, getIsPreview, getOnboardingState, - getOrganization + getOrganization, + getTenantCapabilities } from '../../../selectors'; import { HELPTOOLTIPS, MenderHelpTooltip } from '../../helptips/helptooltips'; import CopyCode from '../copy-code'; @@ -183,6 +184,7 @@ export const PhysicalDeviceOnboarding = ({ progress }) => { const { tenant_token: tenantToken } = useSelector(getOrganization); const { Integration: version } = useSelector(getFullVersionInformation); const { token } = useSelector(getCurrentSession); + const { hasMonitor } = useSelector(getTenantCapabilities); const dispatch = useDispatch(); useEffect(() => { @@ -205,8 +207,9 @@ export const PhysicalDeviceOnboarding = ({ progress }) => { return ( dispatch(advanceOnboarding(step))} - hasExternalIntegration={hasExternalIntegration} hasConvertedImage={hasConvertedImage} + hasExternalIntegration={hasExternalIntegration} + hasMonitor={hasMonitor} integrationProvider={integrationProvider} ipAddress={ipAddress} isEnterprise={isEnterprise} diff --git a/frontend/src/js/components/common/dialogs/physicaldeviceonboarding.test.js b/frontend/src/js/components/common/dialogs/physicaldeviceonboarding.test.js index 0965b905..69b1770e 100644 --- a/frontend/src/js/components/common/dialogs/physicaldeviceonboarding.test.js +++ b/frontend/src/js/components/common/dialogs/physicaldeviceonboarding.test.js @@ -47,6 +47,7 @@ describe('PhysicalDeviceOnboarding Component', () => { hasConvertedImage={true} integrationProvider={EXTERNAL_PROVIDER['iot-hub'].provider} hasExternalIntegration={index % 2} + hasMonitor ipAddress="test.address" isEnterprise={false} isHosted={true} diff --git a/frontend/src/js/helpers.js b/frontend/src/js/helpers.js index 6c55d053..2a7868cc 100644 --- a/frontend/src/js/helpers.js +++ b/frontend/src/js/helpers.js @@ -424,10 +424,11 @@ export const standardizePhases = phases => return standardizedPhase; }); -const getInstallScriptArgs = ({ isHosted, isPreRelease }) => { +const getInstallScriptArgs = ({ isHosted, isPreRelease, hasMonitor }) => { let installScriptArgs = '--demo'; installScriptArgs = isPreRelease ? `${installScriptArgs} -c experimental` : installScriptArgs; - installScriptArgs = isHosted ? `${installScriptArgs} --commercial --jwt-token $JWT_TOKEN` : installScriptArgs; + installScriptArgs = isHosted && hasMonitor ? `${installScriptArgs} --commercial` : installScriptArgs; + installScriptArgs = isHosted ? `${installScriptArgs} --jwt-token $JWT_TOKEN` : installScriptArgs; return installScriptArgs; }; diff --git a/frontend/src/js/helpers.test.js b/frontend/src/js/helpers.test.js index 5dcce25e..2aa9a719 100644 --- a/frontend/src/js/helpers.test.js +++ b/frontend/src/js/helpers.test.js @@ -148,13 +148,34 @@ describe('getDebConfigurationCode function', () => { afterEach(postTestCleanUp); it('should contain sane information for hosted calls', async () => { - code = getDebConfigurationCode({ isHosted: true, isOnboarding: true, tenantToken: 'token', token: 'omnomnom', deviceType: 'raspberrypi3' }); + code = getDebConfigurationCode({ + deviceType: 'raspberrypi3', + hasMonitor: true, + isHosted: true, + isOnboarding: true, + tenantToken: 'token', + token: 'omnomnom' + }); expect(code).toMatch( `JWT_TOKEN="omnomnom" TENANT_TOKEN="token" wget -O- https://get.mender.io | sudo bash -s -- --demo --commercial --jwt-token $JWT_TOKEN --force-mender-client4 -- --quiet --device-type "raspberrypi3" --tenant-token $TENANT_TOKEN --demo --server-url https://hosted.mender.io --server-cert=""` ); }); + it('should contain sane information for hosted calls by users without monitor access', async () => { + code = getDebConfigurationCode({ + deviceType: 'raspberrypi3', + isHosted: true, + isOnboarding: true, + tenantToken: 'token', + token: 'omnomnom' + }); + expect(code).toMatch( + `JWT_TOKEN="omnomnom" +TENANT_TOKEN="token" +wget -O- https://get.mender.io | sudo bash -s -- --demo --jwt-token $JWT_TOKEN --force-mender-client4 -- --quiet --device-type "raspberrypi3" --tenant-token $TENANT_TOKEN --demo --server-url https://hosted.mender.io --server-cert=""` + ); + }); }); describe('configuring devices for staging.hosted.mender', () => { beforeEach(() => { @@ -167,12 +188,13 @@ wget -O- https://get.mender.io | sudo bash -s -- --demo --commercial --jwt-token it('should contain sane information for staging preview calls', async () => { code = getDebConfigurationCode({ + deviceType: 'raspberrypi3', + hasMonitor: true, isHosted: true, isOnboarding: true, + isPreRelease: true, tenantToken: 'token', - token: 'omnomnom', - deviceType: 'raspberrypi3', - isPreRelease: true + token: 'omnomnom' }); expect(code).toMatch( `JWT_TOKEN="omnomnom"