@@ -53,7 +53,7 @@ func testHostScriptResult(t *testing.T, ds *Datastore) {
53
53
ctx := context .Background ()
54
54
55
55
// no script saved yet
56
- pending , err := ds .ListPendingHostScriptExecutions (ctx , 1 )
56
+ pending , err := ds .ListPendingHostScriptExecutions (ctx , 1 , false )
57
57
require .NoError (t , err )
58
58
require .Empty (t , pending )
59
59
@@ -83,11 +83,16 @@ func testHostScriptResult(t *testing.T, ds *Datastore) {
83
83
require .True (t , createdScript .SyncRequest )
84
84
85
85
// the script execution is now listed as pending for this host
86
- pending , err = ds .ListPendingHostScriptExecutions (ctx , 1 )
86
+ pending , err = ds .ListPendingHostScriptExecutions (ctx , 1 , false )
87
87
require .NoError (t , err )
88
88
require .Len (t , pending , 1 )
89
89
require .Equal (t , createdScript .ID , pending [0 ].ID )
90
90
91
+ // the script execution isn't visible when looking at internal-only scripts
92
+ pending , err = ds .ListPendingHostScriptExecutions (ctx , 1 , true )
93
+ require .NoError (t , err )
94
+ require .Empty (t , pending )
95
+
91
96
// record a result for this execution
92
97
hsr , action , err := ds .SetHostScriptExecutionResult (ctx , & fleet.HostScriptResultPayload {
93
98
HostID : 1 ,
@@ -114,7 +119,7 @@ func testHostScriptResult(t *testing.T, ds *Datastore) {
114
119
require .Nil (t , hsr )
115
120
116
121
// it is not pending anymore
117
- pending , err = ds .ListPendingHostScriptExecutions (ctx , 1 )
122
+ pending , err = ds .ListPendingHostScriptExecutions (ctx , 1 , false )
118
123
require .NoError (t , err )
119
124
require .Empty (t , pending )
120
125
@@ -202,7 +207,7 @@ func testHostScriptResult(t *testing.T, ds *Datastore) {
202
207
require .False (t , createdScript .SyncRequest )
203
208
204
209
// the script execution is now listed as pending for this host
205
- pending , err = ds .ListPendingHostScriptExecutions (ctx , 1 )
210
+ pending , err = ds .ListPendingHostScriptExecutions (ctx , 1 , false )
206
211
require .NoError (t , err )
207
212
require .Len (t , pending , 1 )
208
213
require .Equal (t , createdScript .ID , pending [0 ].ID )
@@ -215,7 +220,7 @@ func testHostScriptResult(t *testing.T, ds *Datastore) {
215
220
})
216
221
217
222
// the script execution still shows as pending
218
- pending , err = ds .ListPendingHostScriptExecutions (ctx , 1 )
223
+ pending , err = ds .ListPendingHostScriptExecutions (ctx , 1 , false )
219
224
require .NoError (t , err )
220
225
require .Len (t , pending , 1 )
221
226
require .Equal (t , createdScript .ID , pending [0 ].ID )
@@ -228,7 +233,7 @@ func testHostScriptResult(t *testing.T, ds *Datastore) {
228
233
})
229
234
230
235
// the script is not pending anymore
231
- pending , err = ds .ListPendingHostScriptExecutions (ctx , 1 )
236
+ pending , err = ds .ListPendingHostScriptExecutions (ctx , 1 , false )
232
237
require .NoError (t , err )
233
238
require .Empty (t , pending , 0 )
234
239
@@ -657,14 +662,14 @@ VALUES
657
662
658
663
t .Run ("script deletion cancels pending script runs" , func (t * testing.T ) {
659
664
insertResults (t , 43 , scripts [3 ], now .Add (- 2 * time .Minute ), "execution-4-4" , nil )
660
- pending , err := ds .ListPendingHostScriptExecutions (ctx , 43 )
665
+ pending , err := ds .ListPendingHostScriptExecutions (ctx , 43 , false )
661
666
require .NoError (t , err )
662
667
require .Len (t , pending , 1 )
663
668
664
669
err = ds .DeleteScript (ctx , scripts [3 ].ID )
665
670
require .NoError (t , err )
666
671
667
- pending , err = ds .ListPendingHostScriptExecutions (ctx , 43 )
672
+ pending , err = ds .ListPendingHostScriptExecutions (ctx , 43 , false )
668
673
require .NoError (t , err )
669
674
require .Len (t , pending , 0 )
670
675
})
@@ -821,10 +826,10 @@ VALUES
821
826
// add pending scripts on team and no-team and confirm they're shown as pending
822
827
insertResults (t , 44 , n1WithTeamID , now .Add (- 2 * time .Minute ), "execution-n1t1-1" , nil )
823
828
insertResults (t , 45 , n1WithNoTeamId , now .Add (- 2 * time .Minute ), "execution-n1nt1-1" , nil )
824
- pending , err := ds .ListPendingHostScriptExecutions (ctx , 44 )
829
+ pending , err := ds .ListPendingHostScriptExecutions (ctx , 44 , false )
825
830
require .NoError (t , err )
826
831
require .Len (t , pending , 1 )
827
- pending , err = ds .ListPendingHostScriptExecutions (ctx , 45 )
832
+ pending , err = ds .ListPendingHostScriptExecutions (ctx , 45 , false )
828
833
require .NoError (t , err )
829
834
require .Len (t , pending , 1 )
830
835
@@ -842,10 +847,10 @@ VALUES
842
847
require .Equal (t , n1WithNoTeamId , * noTeamPolicy .ScriptID )
843
848
844
849
// team script should no longer be pending, no-team script should still be pending
845
- pending , err = ds .ListPendingHostScriptExecutions (ctx , 44 )
850
+ pending , err = ds .ListPendingHostScriptExecutions (ctx , 44 , false )
846
851
require .NoError (t , err )
847
852
require .Len (t , pending , 0 )
848
- pending , err = ds .ListPendingHostScriptExecutions (ctx , 45 )
853
+ pending , err = ds .ListPendingHostScriptExecutions (ctx , 45 , false )
849
854
require .NoError (t , err )
850
855
require .Len (t , pending , 1 )
851
856
@@ -869,15 +874,15 @@ VALUES
869
874
require .Nil (t , noTeamPolicy .ScriptID )
870
875
871
876
// no-team script should no longer be pending
872
- pending , err = ds .ListPendingHostScriptExecutions (ctx , 45 )
877
+ pending , err = ds .ListPendingHostScriptExecutions (ctx , 45 , false )
873
878
require .NoError (t , err )
874
879
require .Len (t , pending , 0 )
875
880
}
876
881
877
882
func testLockHostViaScript (t * testing.T , ds * Datastore ) {
878
883
ctx := context .Background ()
879
884
// no script saved yet
880
- pending , err := ds .ListPendingHostScriptExecutions (ctx , 1 )
885
+ pending , err := ds .ListPendingHostScriptExecutions (ctx , 1 , false )
881
886
require .NoError (t , err )
882
887
require .Empty (t , pending )
883
888
@@ -930,7 +935,7 @@ func testLockHostViaScript(t *testing.T, ds *Datastore) {
930
935
func testUnlockHostViaScript (t * testing.T , ds * Datastore ) {
931
936
ctx := context .Background ()
932
937
// no script saved yet
933
- pending , err := ds .ListPendingHostScriptExecutions (ctx , 1 )
938
+ pending , err := ds .ListPendingHostScriptExecutions (ctx , 1 , false )
934
939
require .NoError (t , err )
935
940
require .Empty (t , pending )
936
941
@@ -1468,14 +1473,14 @@ func testDeletePendingHostScriptExecutionsForPolicy(t *testing.T, ds *Datastore)
1468
1473
})
1469
1474
require .NoError (t , err )
1470
1475
1471
- pending , err := ds .ListPendingHostScriptExecutions (ctx , 1 )
1476
+ pending , err := ds .ListPendingHostScriptExecutions (ctx , 1 , false )
1472
1477
require .NoError (t , err )
1473
1478
require .Equal (t , 1 , len (pending ))
1474
1479
1475
1480
err = ds .deletePendingHostScriptExecutionsForPolicy (ctx , & team1 .ID , p1 .ID )
1476
1481
require .NoError (t , err )
1477
1482
1478
- pending , err = ds .ListPendingHostScriptExecutions (ctx , 1 )
1483
+ pending , err = ds .ListPendingHostScriptExecutions (ctx , 1 , false )
1479
1484
require .NoError (t , err )
1480
1485
require .Equal (t , 0 , len (pending ))
1481
1486
@@ -1490,14 +1495,14 @@ func testDeletePendingHostScriptExecutionsForPolicy(t *testing.T, ds *Datastore)
1490
1495
})
1491
1496
require .NoError (t , err )
1492
1497
1493
- pending , err = ds .ListPendingHostScriptExecutions (ctx , 1 )
1498
+ pending , err = ds .ListPendingHostScriptExecutions (ctx , 1 , false )
1494
1499
require .NoError (t , err )
1495
1500
require .Equal (t , 1 , len (pending ))
1496
1501
1497
1502
err = ds .deletePendingHostScriptExecutionsForPolicy (ctx , & team1 .ID , p1 .ID )
1498
1503
require .NoError (t , err )
1499
1504
1500
- pending , err = ds .ListPendingHostScriptExecutions (ctx , 1 )
1505
+ pending , err = ds .ListPendingHostScriptExecutions (ctx , 1 , false )
1501
1506
require .NoError (t , err )
1502
1507
require .Equal (t , 1 , len (pending ))
1503
1508
0 commit comments