@@ -919,7 +919,21 @@ func testVPPTokensCRUD(t *testing.T, ds *Datastore) {
919
919
assert .Equal (t , team .ID , teamTok .Teams [0 ].ID )
920
920
assert .Equal (t , team .Name , teamTok .Teams [0 ].Name )
921
921
922
- // TODO make sure policies are unaffected
922
+ // make sure renewing a VPP token doesn't affect associated VPP install automations
923
+ t1app , err := ds .InsertVPPAppWithTeam (ctx , & fleet.VPPApp {
924
+ Name : "vpp1" , BundleIdentifier : "com.app.vpp1" ,
925
+ VPPAppTeam : fleet.VPPAppTeam {VPPAppID : fleet.VPPAppID {AdamID : "adam_vpp_app_1" , Platform : fleet .MacOSPlatform }},
926
+ }, & team .ID )
927
+ require .NoError (t , err )
928
+ t1meta , err := ds .GetVPPAppMetadataByTeamAndTitleID (ctx , & team .ID , t1app .TitleID )
929
+ require .NoError (t , err )
930
+
931
+ t1Policy , err := ds .NewTeamPolicy (ctx , team .ID , nil , fleet.PolicyPayload {
932
+ Name : "p1" ,
933
+ Query : "SELECT 1;" ,
934
+ VPPAppsTeamsID : & t1meta .VPPAppsTeamsID ,
935
+ })
936
+ require .NoError (t , err )
923
937
924
938
// Renew flow
925
939
upTok , err = ds .UpdateVPPToken (ctx , tokID , dataToken6 )
@@ -934,6 +948,10 @@ func testVPPTokensCRUD(t *testing.T, ds *Datastore) {
934
948
assert .Equal (t , team .ID , upTok .Teams [0 ].ID )
935
949
assert .Equal (t , team .Name , upTok .Teams [0 ].Name )
936
950
951
+ t1Policy , err = ds .Policy (ctx , t1Policy .ID )
952
+ require .NoError (t , err )
953
+ require .Equal (t , t1Policy .VPPAppsTeamsID , & t1meta .VPPAppsTeamsID )
954
+
937
955
tok , err = ds .GetVPPToken (ctx , tok .ID )
938
956
assert .NoError (t , err )
939
957
assert .Equal (t , tokID , tok .ID )
@@ -1112,16 +1130,16 @@ func testVPPTokensCRUD(t *testing.T, ds *Datastore) {
1112
1130
////
1113
1131
1114
1132
// make sure deleting a VPP token auto-clears associated VPP install automations
1115
- t1app , err : = ds .InsertVPPAppWithTeam (ctx , & fleet.VPPApp {
1133
+ t1app , err = ds .InsertVPPAppWithTeam (ctx , & fleet.VPPApp {
1116
1134
Name : "vpp1" , BundleIdentifier : "com.app.vpp1" ,
1117
1135
VPPAppTeam : fleet.VPPAppTeam {VPPAppID : fleet.VPPAppID {AdamID : "adam_vpp_app_1" , Platform : fleet .MacOSPlatform }},
1118
1136
}, & team .ID )
1119
1137
require .NoError (t , err )
1120
- t1meta , err : = ds .GetVPPAppMetadataByTeamAndTitleID (ctx , & team .ID , t1app .TitleID )
1138
+ t1meta , err = ds .GetVPPAppMetadataByTeamAndTitleID (ctx , & team .ID , t1app .TitleID )
1121
1139
require .NoError (t , err )
1122
1140
1123
- t1Policy , err := ds .NewTeamPolicy (ctx , team .ID , nil , fleet.PolicyPayload {
1124
- Name : "p1 " ,
1141
+ t1Policy2 , err := ds .NewTeamPolicy (ctx , team .ID , nil , fleet.PolicyPayload {
1142
+ Name : "t1p2 " ,
1125
1143
Query : "SELECT 1;" ,
1126
1144
VPPAppsTeamsID : & t1meta .VPPAppsTeamsID ,
1127
1145
})
@@ -1130,9 +1148,9 @@ func testVPPTokensCRUD(t *testing.T, ds *Datastore) {
1130
1148
err = ds .DeleteVPPToken (ctx , tokTeam .ID )
1131
1149
assert .NoError (t , err )
1132
1150
1133
- t1Policy , err = ds .Policy (ctx , t1Policy .ID )
1151
+ t1Policy2 , err = ds .Policy (ctx , t1Policy2 .ID )
1134
1152
assert .NoError (t , err )
1135
- assert .Nil (t , t1Policy .VPPAppsTeamsID )
1153
+ assert .Nil (t , t1Policy2 .VPPAppsTeamsID )
1136
1154
1137
1155
tokNil , err = ds .GetVPPTokenByTeamID (ctx , nil )
1138
1156
assert .NoError (t , err )
0 commit comments