1111// ISOLATE guard below acts as a safety net.
1212// ---------------------------------------------------------------------------
1313
14- import { AMTInfo , execConfig , buildOutput , execWithRetry } from './activation.spec'
14+ import {
15+ AMTInfo ,
16+ execConfig ,
17+ buildOutput ,
18+ execWithRetry ,
19+ buildInfoCommand ,
20+ buildActivateCommand ,
21+ buildDeactivateCommand ,
22+ getAmtInfo ,
23+ getAmtVersion ,
24+ notActivatedControlModes
25+ } from './activation.spec'
1526
1627if ( Cypress . env ( 'ISOLATE' ) . charAt ( 0 ) . toLowerCase ( ) !== 'y' ) {
1728 {
@@ -25,72 +36,52 @@ if (Cypress.env('ISOLATE').charAt(0).toLowerCase() !== 'y') {
2536 const parts : string [ ] = profileName ? profileName . split ( '-' ) : [ ]
2637 const isAdminControlModeProfile = parts . length > 0 && parts [ 0 ] === 'acmactivate'
2738 const isWin = Cypress . platform === 'win32'
28- let majorVersion = ''
2939
30- // Default: use Docker (Linux/Mac); Windows overrides below use rpc.exe directly
31- let infoCommand = `docker run --rm --network host --device=/dev/mei0 ${ rpcDockerImage } amtinfo --json`
40+ // Default: use Docker (Linux/Mac); Windows overrides handled internally by the builders.
41+ const infoCommand = buildInfoCommand ( { isWin , rpcDockerImage } )
3242 let activateCommand = ''
3343 let deactivateCommand = ''
34-
35- const buildActivateCommand = ( useFlag : boolean , flag = '' ) => {
36- const flagPart = useFlag ? ` ${ flag } ` : ''
37- if ( isWin ) {
38- return `rpc.exe activate -u wss://${ fqdn } /activate -v -n${ flagPart } --profile ${ profileName } --json`
39- }
40- return `docker run --rm --network host --device=/dev/mei0 ${ rpcDockerImage } activate -u wss://${ fqdn } /activate -v -n${ flagPart } --profile ${ profileName } --json`
41- }
42-
43- const buildDeactivateCommand = ( ) => {
44- if ( isWin ) {
45- return `rpc.exe deactivate -u wss://${ fqdn } /activate -v -n -f --json --password ${ password } `
46- }
47- return `docker run --rm --network host --device=/dev/mei0 ${ rpcDockerImage } deactivate -u wss://${ fqdn } /activate -v -n -f --json --password ${ password } `
48- }
49-
50- const updateCommandsForVersion = ( version : string ) : void => {
51- if ( parseInt ( version ) <= 18 ) {
52- cy . log ( `AMT version ${ version } detected (<= 18), using -tls-tunnel flag for activate` )
53- activateCommand = buildActivateCommand ( true , '-tls-tunnel' )
54- } else {
55- cy . log ( `AMT version ${ version } detected (> 18), no extra flag needed` )
56- activateCommand = buildActivateCommand ( false )
57- }
58- deactivateCommand = buildDeactivateCommand ( )
59- }
60-
61- if ( isWin ) {
62- infoCommand = 'rpc.exe amtinfo --json'
63- }
64-
65- // Set initial commands without flag (will be updated based on AMT version)
66- activateCommand = buildActivateCommand ( false )
67- deactivateCommand = buildDeactivateCommand ( )
44+ let amtVersion = ''
45+
46+ before ( ( ) => {
47+ getAmtInfo ( infoCommand ) . then ( ( info ) => {
48+ amtVersion = getAmtVersion ( info )
49+ activateCommand = buildActivateCommand ( {
50+ isWin,
51+ rpcDockerImage,
52+ amtVersion,
53+ fqdn,
54+ profileName
55+ } )
56+ deactivateCommand = buildDeactivateCommand ( {
57+ isWin,
58+ rpcDockerImage,
59+ password,
60+ amtVersion,
61+ fqdn
62+ } )
63+ } )
64+ } )
6865
6966 describe ( 'Device Activation - Cloud' , ( ) => {
7067 context ( 'TC_ACTIVATION_DEVICE_ACTIVATE_AND_DEACTIVATE' , ( ) => {
7168 beforeEach ( ( ) => {
7269 cy . setup ( )
73- cy . exec ( infoCommand , execConfig ) . then ( ( result ) => {
74- const { stdout, stderr, combined } = buildOutput ( result )
75- cy . log ( combined )
76- const source = stdout . length > 0 ? stdout : stderr
77- amtInfo = JSON . parse ( source )
78- const versions : string [ ] = amtInfo . amt . split ( '.' )
79- majorVersion = versions . length > 1 ? versions [ 0 ] : '0'
80- updateCommandsForVersion ( majorVersion )
70+ getAmtInfo ( infoCommand ) . then ( ( info ) => {
71+ amtInfo = info
8172 } )
8273 cy . wait ( 1000 )
8374 } )
8475
8576 it ( 'Should Activate Device' , ( ) => {
86- expect ( amtInfo . controlMode ) . to . contain ( 'pre-provisioning state' )
77+ expect ( amtInfo . controlMode ) . to . be . oneOf ( notActivatedControlModes )
8778
8879 execWithRetry ( activateCommand , execConfig ) . then ( ( result ) => {
8980 const { stdout, stderr, combined } = buildOutput ( result )
9081 cy . log ( combined )
9182 const primaryOutput = stdout . length > 0 ? stdout : stderr
9283
93- if ( parseInt ( majorVersion ) < 12 && parseInt ( amtInfo . buildNumber ) < 3000 ) {
84+ if ( parseInt ( amtVersion ) < 12 && parseInt ( amtInfo . buildNumber ) < 3000 ) {
9485 expect ( combined ) . to . contain (
9586 'Only version 10.0.47 with build greater than 3000 can be remotely configured'
9687 )
@@ -106,7 +97,7 @@ if (Cypress.env('ISOLATE').charAt(0).toLowerCase() !== 'y') {
10697
10798 if ( parts [ 2 ] === 'CIRA' ) {
10899 expect ( combined ) . to . match ( / C I R A : C o n f i g u r e d / i)
109- } else if ( parseInt ( majorVersion ) >= 19 ) {
100+ } else if ( parseInt ( amtVersion ) >= 19 ) {
110101 expect ( combined ) . to . match ( / T L S : A l r e a d y C o n f i g u r e d / i)
111102 } else {
112103 expect ( combined ) . to . match ( / T L S : C o n f i g u r e d / i)
@@ -131,10 +122,7 @@ if (Cypress.env('ISOLATE').charAt(0).toLowerCase() !== 'y') {
131122 cy . wait ( 120000 )
132123
133124 // Re-query amtinfo after activation to get the updated IP address
134- cy . exec ( infoCommand , execConfig ) . then ( ( postActivationResult ) => {
135- const { stdout, stderr } = buildOutput ( postActivationResult )
136- const source = stdout . length > 0 ? stdout : stderr
137- const postActivationInfo : AMTInfo = JSON . parse ( source )
125+ getAmtInfo ( infoCommand ) . then ( ( postActivationInfo ) => {
138126 cy . log ( `Post-activation wired IP: ${ postActivationInfo . wiredAdapter ?. ipAddress } ` )
139127 cy . log ( `Post-activation wireless IP: ${ postActivationInfo . wirelessAdapter ?. ipAddress } ` )
140128
@@ -154,7 +142,7 @@ if (Cypress.env('ISOLATE').charAt(0).toLowerCase() !== 'y') {
154142 cy . get ( '[data-cy="serialNumber"]' ) . should ( 'not.be.empty' )
155143 cy . get ( '[data-cy="provisioningMode"]' ) . should ( 'not.be.empty' )
156144
157- if ( parseInt ( majorVersion ) < 11 ) {
145+ if ( parseInt ( amtVersion ) < 11 ) {
158146 cy . get ( '[data-cy="biosManufacturer"]' ) . should ( 'not.be.empty' )
159147 cy . get ( '[data-cy="biosVersion"]' ) . should ( 'not.be.empty' )
160148 cy . get ( '[data-cy="biosReleaseData"]' ) . should ( 'not.be.empty' )
@@ -171,7 +159,7 @@ if (Cypress.env('ISOLATE').charAt(0).toLowerCase() !== 'y') {
171159 } )
172160
173161 it ( 'should NOT deactivate device - invalid password' , ( ) => {
174- if ( amtInfo . controlMode !== 'pre-provisioning state' ) {
162+ if ( ! notActivatedControlModes . includes ( amtInfo . controlMode ) ) {
175163 const invalidCommand =
176164 deactivateCommand . slice ( 0 , deactivateCommand . indexOf ( '--password' ) ) + '--password invalidpassword'
177165 execWithRetry ( invalidCommand , execConfig ) . then ( ( result ) => {
@@ -183,7 +171,7 @@ if (Cypress.env('ISOLATE').charAt(0).toLowerCase() !== 'y') {
183171 } )
184172
185173 it ( 'should deactivate device' , ( ) => {
186- if ( amtInfo . controlMode !== 'pre-provisioning state' ) {
174+ if ( ! notActivatedControlModes . includes ( amtInfo . controlMode ) ) {
187175 execWithRetry ( deactivateCommand , execConfig ) . then ( ( result ) => {
188176 const { combined } = buildOutput ( result )
189177 cy . log ( combined )
@@ -196,17 +184,6 @@ if (Cypress.env('ISOLATE').charAt(0).toLowerCase() !== 'y') {
196184 } )
197185
198186 context ( 'Negative Activation Test' , ( ) => {
199- beforeEach ( ( ) => {
200- cy . exec ( infoCommand , execConfig ) . then ( ( result ) => {
201- const { stdout, stderr } = buildOutput ( result )
202- const source = stdout . length > 0 ? stdout : stderr
203- const info = JSON . parse ( source )
204- const versions : string [ ] = info . amt . split ( '.' )
205- const version = versions . length > 1 ? versions [ 0 ] : '0'
206- updateCommandsForVersion ( version )
207- } )
208- } )
209-
210187 if ( isAdminControlModeProfile ) {
211188 it ( 'Should NOT activate ACM when domain suffix is not registered in RPS' , ( ) => {
212189 activateCommand += ' -d dontmatch.com'
0 commit comments