Skip to content

Commit

Permalink
Merge pull request #7 from mzedel/men-7458
Browse files Browse the repository at this point in the history
MEN-7458 - fix: prevented commercial client components are only selected when plan/ addon accessible
  • Loading branch information
mzedel authored Sep 4, 2024
2 parents a93f5e1 + 81e0b73 commit 73c282e
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import {
getIsEnterprise,
getIsPreview,
getOnboardingState,
getOrganization
getOrganization,
getTenantCapabilities
} from '../../../selectors';
import { HELPTOOLTIPS, MenderHelpTooltip } from '../../helptips/helptooltips';
import CopyCode from '../copy-code';
Expand Down Expand Up @@ -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(() => {
Expand All @@ -205,8 +207,9 @@ export const PhysicalDeviceOnboarding = ({ progress }) => {
return (
<ComponentToShow
advanceOnboarding={step => dispatch(advanceOnboarding(step))}
hasExternalIntegration={hasExternalIntegration}
hasConvertedImage={hasConvertedImage}
hasExternalIntegration={hasExternalIntegration}
hasMonitor={hasMonitor}
integrationProvider={integrationProvider}
ipAddress={ipAddress}
isEnterprise={isEnterprise}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/js/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
30 changes: 26 additions & 4 deletions frontend/src/js/helpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -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"
Expand Down

0 comments on commit 73c282e

Please sign in to comment.