-
Notifications
You must be signed in to change notification settings - Fork 1
703 lines (591 loc) · 26 KB
/
integration-test.yml
File metadata and controls
703 lines (591 loc) · 26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
name: Integration Test
on:
workflow_dispatch:
inputs:
os:
description: "Platform to test"
required: true
type: choice
options:
- all
- windows-latest
- ubuntu-latest
- macos-latest
jobs:
build:
permissions:
contents: read
uses: ./.github/workflows/build.yml
with:
os_list: "${{ inputs.os == 'all' && '[''windows-latest'',''ubuntu-latest'',''macos-latest'']' || format('[{0}{1}{0}]', '''', inputs.os) }}"
cache: true
test-ubuntu-latest:
permissions:
contents: read
needs: build
if: inputs.os == 'ubuntu-latest' || inputs.os == 'all'
runs-on: ubuntu-latest
steps:
- name: Download compiled binary
uses: actions/download-artifact@v8
with:
name: ubuntu-latest
path: ./dist
- name: Make binary executable
run: chmod +x ./dist/rewst_agent_config.linux.bin
- name: Install agent
id: install_agent
shell: bash
run: |
sudo ./dist/rewst_agent_config.linux.bin --config-url ${{ vars.IT_CONFIG_URL }} --config-secret ${{ secrets.IT_CONFIG_SECRET }} --org-id ${{ vars.IT_ORG_ID }}
echo "service=rewst_remote_agent_${{ vars.IT_ORG_ID }}" >> $GITHUB_OUTPUT
- name: Check service
shell: bash
run: |
systemctl status ${{ steps.install_agent.outputs.service }}
- name: Get device id
id: get_device_id
shell: bash
run: |
echo "value=$(cat /etc/rewst_remote_agent/${{ vars.IT_ORG_ID }}/config.json | jq -r '.device_id')" >> "$GITHUB_OUTPUT"
- name: Validate config.json fields
shell: bash
run: |
config="/etc/rewst_remote_agent/${{ vars.IT_ORG_ID }}/config.json"
failed=false
for field in device_id rewst_org_id rewst_engine_host shared_access_key azure_iot_hub_host; do
val=$(jq -r ".$field" "$config")
if [ -z "$val" ] || [ "$val" = "null" ]; then
echo "ERROR: Config field '$field' is missing or empty"
failed=true
else
echo "OK: $field = $val"
fi
done
org_id=$(jq -r '.rewst_org_id' "$config")
if [ "$org_id" != "${{ vars.IT_ORG_ID }}" ]; then
echo "ERROR: rewst_org_id '$org_id' does not match expected '${{ vars.IT_ORG_ID }}'"
failed=true
fi
if [ "$failed" = true ]; then exit 1; fi
echo "All config.json fields validated"
- name: Send test command
shell: bash
run: |
curl --location '${{ vars.IT_SEND_COMMAND_TRIGGER_URL }}' \
--form 'device_id="${{ steps.get_device_id.outputs.value }}"' \
--form 'commands="echo \"hello world\""'
- name: Check logs
shell: bash
run: |
logFile="/etc/rewst_remote_agent/${{ vars.IT_ORG_ID }}/rewst_agent.log"
logContent=$(cat "$logFile")
echo "$logContent"
for pattern in "Command completed" "Sending postback" "Postback sent"; do
if ! echo "$logContent" | grep -qF "$pattern"; then
echo "ERROR: Expected log line not found: $pattern"
exit 1
fi
done
echo "All expected log lines found"
- name: Send failing command
shell: bash
run: |
curl --location '${{ vars.IT_SEND_COMMAND_TRIGGER_URL }}' \
--form 'device_id="${{ steps.get_device_id.outputs.value }}"' \
--form 'commands="exit 1"'
- name: Check logs for error handling
shell: bash
run: |
sleep 15
logFile="/etc/rewst_remote_agent/${{ vars.IT_ORG_ID }}/rewst_agent.log"
logContent=$(cat "$logFile")
echo "$logContent"
if ! echo "$logContent" | grep -qF "Command failed"; then
echo "ERROR: Expected 'Command failed' not found in logs"
exit 1
fi
echo "Error handling verified: failing command error was captured"
- name: Update logging level to debug
shell: bash
run: |
sudo ./dist/rewst_agent_config.linux.bin --update --org-id ${{ vars.IT_ORG_ID }} --logging-level debug
echo "Logging level successfully updated to debug"
- name: Send test command
shell: bash
run: |
curl --location '${{ vars.IT_SEND_COMMAND_TRIGGER_URL }}' \
--form 'device_id="${{ steps.get_device_id.outputs.value }}"' \
--form 'commands="echo \"hello world\""'
- name: Check logs for debug level
shell: bash
run: |
logFile="/etc/rewst_remote_agent/${{ vars.IT_ORG_ID }}/rewst_agent.log"
logContent=$(cat "$logFile")
echo "$logContent"
if ! echo "$logContent" | grep -qF "DEBUG"; then
echo "ERROR: Expected log line not found: DEBUG"
exit 1
fi
echo "All expected log lines found"
- name: Stop service
shell: bash
run: |
sudo systemctl stop ${{ steps.install_agent.outputs.service }}
- name: Delete log file
shell: bash
run: |
sudo rm -f "/etc/rewst_remote_agent/${{ vars.IT_ORG_ID }}/rewst_agent.log"
- name: Update agent
shell: bash
run: |
sudo ./dist/rewst_agent_config.linux.bin --update --org-id ${{ vars.IT_ORG_ID }} --no-auto-updates
- name: Check logs for no auto updater
shell: bash
run: |
logFile="/etc/rewst_remote_agent/${{ vars.IT_ORG_ID }}/rewst_agent.log"
for i in $(seq 1 30); do
[ -f "$logFile" ] && break
echo "Waiting for log file to be created... ($i/30)"
sleep 1
done
logContent=$(cat "$logFile")
echo "$logContent"
if echo "$logContent" | grep -qF "Starting auto updater"; then
echo "ERROR: Unexpected log line found: Starting auto updater"
exit 1
fi
echo "Confirmed: no 'Starting auto updater' log line found"
- name: Update agent with syslog
shell: bash
run: |
sudo ./dist/rewst_agent_config.linux.bin --update --org-id ${{ vars.IT_ORG_ID }} --syslog
- name: Send test command
shell: bash
run: |
curl --location '${{ vars.IT_SEND_COMMAND_TRIGGER_URL }}' \
--form 'device_id="${{ steps.get_device_id.outputs.value }}"' \
--form 'commands="echo \"hello world\""'
- name: Check syslog for command completed
shell: bash
run: |
sleep 15
entries=$(journalctl -t "rewst_remote_agent_${{ vars.IT_ORG_ID }}" --no-pager 2>/dev/null || sudo grep "rewst_remote_agent_${{ vars.IT_ORG_ID }}" /var/log/syslog 2>/dev/null || sudo grep "rewst_remote_agent_${{ vars.IT_ORG_ID }}" /var/log/messages 2>/dev/null || true)
echo "$entries"
if ! echo "$entries" | grep -qF "Command completed"; then
echo "ERROR: Expected 'Command completed' entry not found in syslog"
exit 1
fi
echo "Found 'Command completed' in syslog"
- name: Uninstall agent
shell: bash
run: |
sudo ./dist/rewst_agent_config.linux.bin --uninstall --org-id ${{ vars.IT_ORG_ID }}
- name: Check deleted directories
shell: pwsh
run: |
if (Test-Path -Path "/etc/rewst_remote_agent/${{ vars.IT_ORG_ID }}") { exit 1 }
if (Test-Path -Path "/usr/local/bin/rewst_remote_agent/${{ vars.IT_ORG_ID }}") { exit 1 }
if (Test-Path -Path "/tmp/rewst_remote_agent/scripts/${{ vars.IT_ORG_ID }}") { exit 1 }
echo "All directories have been deleted"
test-windows-latest:
permissions:
contents: read
needs: build
if: inputs.os == 'windows-latest' || inputs.os == 'all'
runs-on: windows-latest
steps:
- name: Download compiled binary
uses: actions/download-artifact@v8
with:
name: windows-latest
path: ./dist
- name: Install agent
id: install_agent
shell: pwsh
run: |
./dist/rewst_agent_config.win.exe --config-url ${{ vars.IT_CONFIG_URL }} --config-secret ${{ secrets.IT_CONFIG_SECRET }} --org-id ${{ vars.IT_ORG_ID }}
Write-Output "service=RewstRemoteAgent_${{ vars.IT_ORG_ID }}" >> $env:GITHUB_OUTPUT
- name: Check service
shell: pwsh
run: |
sc.exe query ${{ steps.install_agent.outputs.service }}
- name: Get device id
id: get_device_id
shell: pwsh
run: |
(Get-Content C:\ProgramData\RewstRemoteAgent\${{ vars.IT_ORG_ID }}\config.json | ConvertFrom-Json).device_id | % { "value=$_" } >> $env:GITHUB_OUTPUT
- name: Validate config.json fields
shell: pwsh
run: |
$config = Get-Content C:\ProgramData\RewstRemoteAgent\${{ vars.IT_ORG_ID }}\config.json | ConvertFrom-Json
$requiredFields = @(
@{ Name = "device_id"; Value = $config.device_id },
@{ Name = "rewst_org_id"; Value = $config.rewst_org_id },
@{ Name = "rewst_engine_host"; Value = $config.rewst_engine_host },
@{ Name = "shared_access_key"; Value = $config.shared_access_key },
@{ Name = "azure_iot_hub_host"; Value = $config.azure_iot_hub_host }
)
$failed = $false
foreach ($field in $requiredFields) {
if ([string]::IsNullOrWhiteSpace($field.Value)) {
Write-Error "Config field '$($field.Name)' is missing or empty"
$failed = $true
} else {
Write-Output "OK: $($field.Name) = $($field.Value)"
}
}
if ($config.rewst_org_id -ne "${{ vars.IT_ORG_ID }}") {
Write-Error "rewst_org_id '$($config.rewst_org_id)' does not match expected '${{ vars.IT_ORG_ID }}'"
$failed = $true
}
if ($failed) { exit 1 }
Write-Output "All config.json fields validated"
- name: Send test command
shell: pwsh
run: |
curl --location '${{ vars.IT_SEND_COMMAND_TRIGGER_URL }}' `
--form 'device_id="${{ steps.get_device_id.outputs.value }}"' `
--form 'commands="[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$PS_Results = New-Object -TypeName psobject
# Start of typed powershell
$PS_Results | Add-Member -MemberType NoteProperty -Name \"error\" -Value \"\"
$PS_Results | Add-Member -MemberType NoteProperty -Name \"output\" -Value \"hello world`n\"
# Post results back to Rewst
$postData = $PS_Results | ConvertTo-Json
Invoke-RestMethod -Method \"Post\" -Uri $post_url -Body $postData -ContentType \"application/json\""'
- name: Check logs
shell: pwsh
run: |
$logFile = "C:\ProgramData\RewstRemoteAgent\${{ vars.IT_ORG_ID }}\rewst_agent.log"
$logContent = Get-Content $logFile -Raw
Write-Output $logContent
$expectedPatterns = @(
"Command completed",
"Sending postback",
"Postback already sent"
)
foreach ($pattern in $expectedPatterns) {
if ($logContent -notmatch [regex]::Escape($pattern)) {
Write-Error "Expected log line not found: $pattern"
exit 1
}
}
Write-Output "All expected log lines found"
- name: Send failing command
shell: pwsh
run: |
curl --location '${{ vars.IT_SEND_COMMAND_TRIGGER_URL }}' `
--form 'device_id="${{ steps.get_device_id.outputs.value }}"' `
--form 'commands="[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$PS_Results = New-Object -TypeName psobject
# Start of typed powershell
throw \"this is a test error\"
# Post results back to Rewst
$postData = $PS_Results | ConvertTo-Json
Invoke-RestMethod -Method \"Post\" -Uri $post_url -Body $postData -ContentType \"application/json\""'
- name: Check logs for error handling
shell: pwsh
run: |
Start-Sleep -Seconds 15
$logFile = "C:\ProgramData\RewstRemoteAgent\${{ vars.IT_ORG_ID }}\rewst_agent.log"
$logContent = Get-Content $logFile -Raw
Write-Output $logContent
if ($logContent -notmatch "Command failed") {
Write-Error "Expected error message 'Command failed' not found in logs"
exit 1
}
Write-Output "Error handling verified: failing command error was captured"
- name: Update logging level to debug
shell: pwsh
run: |
./dist/rewst_agent_config.win.exe --update --org-id ${{ vars.IT_ORG_ID }} --logging-level debug
Write-Output "Logging level successfully updated to debug"
- name: Send test command
shell: pwsh
run: |
curl --location '${{ vars.IT_SEND_COMMAND_TRIGGER_URL }}' `
--form 'device_id="${{ steps.get_device_id.outputs.value }}"' `
--form 'commands="[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$PS_Results = New-Object -TypeName psobject
# Start of typed powershell
$PS_Results | Add-Member -MemberType NoteProperty -Name \"error\" -Value \"\"
$PS_Results | Add-Member -MemberType NoteProperty -Name \"output\" -Value \"hello world`n\"
# Post results back to Rewst
$postData = $PS_Results | ConvertTo-Json
Invoke-RestMethod -Method \"Post\" -Uri $post_url -Body $postData -ContentType \"application/json\""'
- name: Check logs
shell: pwsh
run: |
$logFile = "C:\ProgramData\RewstRemoteAgent\${{ vars.IT_ORG_ID }}\rewst_agent.log"
$logContent = Get-Content $logFile -Raw
Write-Output $logContent
if ($logContent -notmatch [regex]::Escape("DEBUG")) {
Write-Error "Expected log line not found: DEBUG"
}
Write-Output "All expected log lines found"
- name: Stop service
shell: pwsh
run: |
sc.exe stop ${{ steps.install_agent.outputs.service }}
- name: Delete log file
shell: pwsh
run: |
Remove-Item -Force "C:\ProgramData\RewstRemoteAgent\${{ vars.IT_ORG_ID }}\rewst_agent.log"
- name: Update agent
shell: pwsh
run: |
./dist/rewst_agent_config.win.exe --update --org-id ${{ vars.IT_ORG_ID }} --no-auto-updates --disable-agent-postback
- name: Check logs for no auto updater
shell: pwsh
run: |
$logFile = "C:\ProgramData\RewstRemoteAgent\${{ vars.IT_ORG_ID }}\rewst_agent.log"
for ($i = 1; $i -le 30; $i++) {
if (Test-Path $logFile) { break }
Write-Output "Waiting for log file to be created... ($i/30)"
Start-Sleep -Seconds 1
}
$logContent = Get-Content $logFile -Raw
Write-Output $logContent
if ($logContent -match [regex]::Escape("Starting auto updater")) {
Write-Error "Unexpected log line found: Starting auto updater"
exit 1
}
Write-Output "Confirmed: no 'Starting auto updater' log line found"
- name: Send test command
shell: pwsh
run: |
curl --location '${{ vars.IT_SEND_COMMAND_TRIGGER_URL }}' `
--form 'device_id="${{ steps.get_device_id.outputs.value }}"' `
--form 'commands="[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$PS_Results = New-Object -TypeName psobject
# Start of typed powershell
$PS_Results | Add-Member -MemberType NoteProperty -Name \"error\" -Value \"\"
$PS_Results | Add-Member -MemberType NoteProperty -Name \"output\" -Value \"hello world`n\"
# Post results back to Rewst
$postData = $PS_Results | ConvertTo-Json
Invoke-RestMethod -Method \"Post\" -Uri $post_url -Body $postData -ContentType \"application/json\""'
- name: Check logs for command received
shell: pwsh
run: |
$logFile = "C:\ProgramData\RewstRemoteAgent\${{ vars.IT_ORG_ID }}\rewst_agent.log"
$logContent = Get-Content $logFile -Raw
Write-Output $logContent
if ($logContent -notmatch [regex]::Escape("Command completed")) {
Write-Error "Expected log line not found: Command completed"
exit 1
}
if ($logContent -match [regex]::Escape("Postback already sent")) {
Write-Error "Unexpected log line found: Postback already sent"
exit 1
}
Write-Output "All log checks passed"
- name: Update agent with syslog
shell: pwsh
run: |
./dist/rewst_agent_config.win.exe --update --org-id ${{ vars.IT_ORG_ID }} --syslog
- name: Send test command
shell: pwsh
run: |
curl --location '${{ vars.IT_SEND_COMMAND_TRIGGER_URL }}' `
--form 'device_id="${{ steps.get_device_id.outputs.value }}"' `
--form 'commands="[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$PS_Results = New-Object -TypeName psobject
# Start of typed powershell
$PS_Results | Add-Member -MemberType NoteProperty -Name \"error\" -Value \"\"
$PS_Results | Add-Member -MemberType NoteProperty -Name \"output\" -Value \"hello world`n\"
# Post results back to Rewst
$postData = $PS_Results | ConvertTo-Json
Invoke-RestMethod -Method \"Post\" -Uri $post_url -Body $postData -ContentType \"application/json\""'
- name: Check Windows Event Log for command completed
shell: pwsh
run: |
$events = Get-WinEvent -LogName Application -FilterXPath "*[System[Provider[@Name='RewstRemoteAgent_${{ vars.IT_ORG_ID }}']]]"
Write-Output "Found $($events.Count) event(s)"
$events | ForEach-Object { Write-Output $_.Message }
$matched = $events | Where-Object { $_.Message -match "Command completed" }
if (-not $matched) {
Write-Error "Expected 'Command completed' entry not found in Windows Event Log"
exit 1
}
Write-Output "Found 'Command completed' in Windows Event Log"
- name: Uninstall agent
shell: pwsh
run: |
./dist/rewst_agent_config.win.exe --uninstall --org-id ${{ vars.IT_ORG_ID }}
- name: Check deleted directories
shell: pwsh
run: |
if (Test-Path -Path "C:\ProgramData\RewstRemoteAgent\${{ vars.IT_ORG_ID }}") { exit 1 }
if (Test-Path -Path "C:\Program Files\RewstRemoteAgent\${{ vars.IT_ORG_ID }}") { exit 1 }
if (Test-Path -Path "C:\RewstRemoteAgent\scripts\${{ vars.IT_ORG_ID }}") { exit 1 }
echo "All directories have been deleted"
test-macos-latest:
permissions:
contents: read
needs: build
if: inputs.os == 'macos-latest' || inputs.os == 'all'
runs-on: macos-latest
steps:
- name: Download compiled binary
uses: actions/download-artifact@v8
with:
name: macos-latest
path: ./dist
- name: Make binary executable
run: chmod +x ./dist/rewst_agent_config.mac-os.bin
- name: Install agent
id: install_agent
shell: bash
run: |
sudo ./dist/rewst_agent_config.mac-os.bin --config-url ${{ vars.IT_CONFIG_URL }} --config-secret ${{ secrets.IT_CONFIG_SECRET }} --org-id ${{ vars.IT_ORG_ID }}
echo "service=io.rewst.remote_agent_${{ vars.IT_ORG_ID }}" >> $GITHUB_OUTPUT
- name: Check service
shell: bash
run: |
sudo launchctl print system/${{ steps.install_agent.outputs.service }}
- name: Get device id
id: get_device_id
shell: bash
run: |
echo "value=$(cat "/Library/Application Support/rewst_remote_agent/${{ vars.IT_ORG_ID }}/config.json" | jq -r '.device_id')" >> "$GITHUB_OUTPUT"
- name: Validate config.json fields
shell: bash
run: |
config="/Library/Application Support/rewst_remote_agent/${{ vars.IT_ORG_ID }}/config.json"
failed=false
for field in device_id rewst_org_id rewst_engine_host shared_access_key azure_iot_hub_host; do
val=$(jq -r ".$field" "$config")
if [ -z "$val" ] || [ "$val" = "null" ]; then
echo "ERROR: Config field '$field' is missing or empty"
failed=true
else
echo "OK: $field = $val"
fi
done
org_id=$(jq -r '.rewst_org_id' "$config")
if [ "$org_id" != "${{ vars.IT_ORG_ID }}" ]; then
echo "ERROR: rewst_org_id '$org_id' does not match expected '${{ vars.IT_ORG_ID }}'"
failed=true
fi
if [ "$failed" = true ]; then exit 1; fi
echo "All config.json fields validated"
- name: Send test command
shell: bash
run: |
curl --location '${{ vars.IT_SEND_COMMAND_TRIGGER_URL }}' \
--form 'device_id="${{ steps.get_device_id.outputs.value }}"' \
--form 'commands="echo \"hello world\""'
- name: Check logs
shell: bash
run: |
logFile="/Library/Application Support/rewst_remote_agent/${{ vars.IT_ORG_ID }}/rewst_agent.log"
logContent=$(cat "$logFile")
echo "$logContent"
for pattern in "Command completed" "Sending postback" "Postback sent"; do
if ! echo "$logContent" | grep -qF "$pattern"; then
echo "ERROR: Expected log line not found: $pattern"
exit 1
fi
done
echo "All expected log lines found"
- name: Send failing command
shell: bash
run: |
curl --location '${{ vars.IT_SEND_COMMAND_TRIGGER_URL }}' \
--form 'device_id="${{ steps.get_device_id.outputs.value }}"' \
--form 'commands="exit 1"'
- name: Check logs for error handling
shell: bash
run: |
sleep 15
logFile="/Library/Application Support/rewst_remote_agent/${{ vars.IT_ORG_ID }}/rewst_agent.log"
logContent=$(cat "$logFile")
echo "$logContent"
if ! echo "$logContent" | grep -qF "Command failed"; then
echo "ERROR: Expected 'Command failed' not found in logs"
exit 1
fi
echo "Error handling verified: failing command error was captured"
- name: Update logging level to debug
shell: bash
run: |
sudo ./dist/rewst_agent_config.mac-os.bin --update --org-id ${{ vars.IT_ORG_ID }} --logging-level debug
echo "Logging level successfully updated to debug"
- name: Send test command
shell: bash
run: |
curl --location '${{ vars.IT_SEND_COMMAND_TRIGGER_URL }}' \
--form 'device_id="${{ steps.get_device_id.outputs.value }}"' \
--form 'commands="echo \"hello world\""'
- name: Check logs for debug level
shell: bash
run: |
logFile="/Library/Application Support/rewst_remote_agent/${{ vars.IT_ORG_ID }}/rewst_agent.log"
logContent=$(cat "$logFile")
echo "$logContent"
if ! echo "$logContent" | grep -qF "DEBUG"; then
echo "ERROR: Expected log line not found: DEBUG"
exit 1
fi
echo "All expected log lines found"
- name: Stop service
shell: bash
run: |
sudo launchctl stop system/${{ steps.install_agent.outputs.service }} || true
- name: Delete log file
shell: bash
run: |
sudo rm -f "/Library/Application Support/rewst_remote_agent/${{ vars.IT_ORG_ID }}/rewst_agent.log"
- name: Update agent
shell: bash
run: |
sudo ./dist/rewst_agent_config.mac-os.bin --update --org-id ${{ vars.IT_ORG_ID }} --no-auto-updates
- name: Check logs for no auto updater
shell: bash
run: |
logFile="/Library/Application Support/rewst_remote_agent/${{ vars.IT_ORG_ID }}/rewst_agent.log"
for i in $(seq 1 30); do
[ -f "$logFile" ] && break
echo "Waiting for log file to be created... ($i/30)"
sleep 1
done
logContent=$(cat "$logFile")
echo "$logContent"
if echo "$logContent" | grep -qF "Starting auto updater"; then
echo "ERROR: Unexpected log line found: Starting auto updater"
exit 1
fi
echo "Confirmed: no 'Starting auto updater' log line found"
- name: Update agent with syslog
shell: bash
run: |
sudo ./dist/rewst_agent_config.mac-os.bin --update --org-id ${{ vars.IT_ORG_ID }} --syslog
- name: Send test command
shell: bash
run: |
curl --location '${{ vars.IT_SEND_COMMAND_TRIGGER_URL }}' \
--form 'device_id="${{ steps.get_device_id.outputs.value }}"' \
--form 'commands="echo \"hello world\""'
- name: Check syslog for command completed
shell: bash
run: |
sleep 15
entries=$(log show --predicate 'processImagePath contains "logger"' --info --last 5m 2>/dev/null || true)
echo "$entries"
if ! echo "$entries" | grep -qF "Command completed"; then
echo "ERROR: Expected 'Command completed' entry not found in syslog"
exit 1
fi
echo "Found 'Command completed' in syslog"
- name: Uninstall agent
shell: bash
run: |
sudo ./dist/rewst_agent_config.mac-os.bin --uninstall --org-id ${{ vars.IT_ORG_ID }}
- name: Check deleted directories
shell: pwsh
run: |
if (Test-Path -Path "/Library/Application Support/rewst_remote_agent/${{ vars.IT_ORG_ID }}") { exit 1 }
if (Test-Path -Path "/usr/local/bin/rewst_remote_agent/${{ vars.IT_ORG_ID }}") { exit 1 }
if (Test-Path -Path "$env:TMPDIR/rewst_remote_agent/scripts/${{ vars.IT_ORG_ID }}") { exit 1 }
echo "All directories have been deleted"