Skip to content

Commit

Permalink
fix(api): Gcp sidekick integration server token (#1054)
Browse files Browse the repository at this point in the history
* fix(api): expose server_token
* fix(api): test changes
  • Loading branch information
ammarekbote committed Dec 7, 2022
1 parent 57c282c commit 6a16fdf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
17 changes: 16 additions & 1 deletion api/cloud_accounts_gcp_sidekick.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ func (svc *CloudAccountsService) GetGcpSidekick(guid string) (
return
}

// CreateGcpSidekick creates an GcpSidekick Cloud Account integration
func (svc *CloudAccountsService) CreateGcpSidekick(data CloudAccount) (
response GcpSidekickIntegrationResponse,
err error,
) {
err = svc.create(data, &response)
return
}

// UpdateGcpSidekick updates a single GcpSidekick integration on the Lacework Server
func (svc *CloudAccountsService) UpdateGcpSidekick(data CloudAccount) (
response GcpSidekickIntegrationResponse,
Expand All @@ -40,9 +49,15 @@ type GcpSidekickIntegrationResponse struct {
Data V2GcpSidekickIntegration `json:"data"`
}

type GcpSidekickToken struct {
ServerToken string `json:"serverToken"`
Uri string `json:"uri"`
}

type V2GcpSidekickIntegration struct {
v2CommonIntegrationData
Data GcpSidekickData `json:"data"`
GcpSidekickToken `json:"serverToken"`
Data GcpSidekickData `json:"data"`
}

type GcpSidekickData struct {
Expand Down
6 changes: 5 additions & 1 deletion api/cloud_accounts_gcp_sidekick_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ func TestCloudAccountsGcpSidekickGet(t *testing.T) {
assert.Equal(t, "tokenTest", integrationData.Credentials.TokenUri)
assert.Equal(t, "proj1,proj2", integrationData.FilterList)
assert.Equal(t, "queryText", integrationData.QueryText)
assert.Equal(t, "token_"+integration.IntgGuid, integration.ServerToken)
}

func TestCloudAccountsGcpSidekickUpdate(t *testing.T) {
Expand Down Expand Up @@ -268,7 +269,10 @@ func getGcpData(id string, data api.GcpSidekickData) string {
"scanFrequency": ` + scanFrequency + `,
"scanContainers": ` + scanContainers + `,
"scanHostVulnerabilities": ` + scanHostVulnerabilities + `
}
},
"serverToken": {
"serverToken": "token_` + id + `"
}
}
`
}

0 comments on commit 6a16fdf

Please sign in to comment.