@@ -263,6 +263,56 @@ func TestCloudAccountsListByType(t *testing.T) {
263263 }
264264}
265265
266+ func TestCloudAccountMigrate (t * testing.T ) {
267+ var (
268+ intgGUID = intgguid .New ()
269+ apiPath = "migrateGcpAtSes"
270+ fakeServer = lacework .MockServer ()
271+ )
272+ fakeServer .MockToken ("TOKEN" )
273+ defer fakeServer .Close ()
274+
275+ fakeServer .MockAPI (apiPath , func (w http.ResponseWriter , r * http.Request ) {
276+ assert .Equal (t , "PATCH" , r .Method , "cloudAccountMigrate() should be a PATCH method" )
277+
278+ if assert .NotNil (t , r .Body ) {
279+ body := httpBodySniffer (r )
280+ assert .Contains (t , body , intgGUID , "INTG_GUID missing" )
281+ assert .Contains (t , body , "props" , "migration props are missing" )
282+ assert .Contains (t , body , "migrate\" :true" ,
283+ "migrate field is missing or it is set to false" )
284+ assert .Contains (t , body , "migrationTimestamp" , "migration timestamp is missing" )
285+ }
286+ fmt .Fprintf (w , generateCloudAccountResponse (singleGcpAtCloudAccount (intgGUID )))
287+ })
288+
289+ c , err := api .NewClient ("test" ,
290+ api .WithToken ("TOKEN" ),
291+ api .WithURL (fakeServer .URL ()),
292+ )
293+ assert .Nil (t , err )
294+
295+ cloudAccount := api .NewCloudAccount ("integration_name" ,
296+ api .GcpAtSesCloudAccount ,
297+ api.GcpAtSesData {
298+ Credentials : api.GcpAtSesCredentials {
299+ ClientID : "123456789" ,
300+ 301+ PrivateKeyID : "" ,
302+ PrivateKey : "" ,
303+ },
304+ },
305+ )
306+ assert .Equal (t , "integration_name" , cloudAccount .Name , "GcpAtSes cloud account name mismatch" )
307+ assert .Equal (t , "GcpAtSes" , cloudAccount .Type ,
308+ "a new GcpAtSes cloud account should match its type" )
309+ assert .Equal (t , 1 , cloudAccount .Enabled , "a new GcpAtSes cloud account should be enabled" )
310+ cloudAccount .IntgGuid = intgGUID
311+
312+ err = c .V2 .CloudAccounts .Migrate (intgGUID )
313+ assert .Nil (t , err )
314+ }
315+
266316func generateCloudAccounts (guids []string , iType string ) string {
267317 cloudAccounts := make ([]string , len (guids ))
268318 for i , guid := range guids {
0 commit comments