Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Access client secret and ID to device posture integration #1464

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/1464.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
device_posture_rules: add support for Access client fields in device posture integrations
```
14 changes: 8 additions & 6 deletions device_posture_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import (
// DevicePostureIntegrationConfig contains authentication information
// for a device posture integration.
type DevicePostureIntegrationConfig struct {
ClientID string `json:"client_id,omitempty"`
ClientSecret string `json:"client_secret,omitempty"`
AuthUrl string `json:"auth_url,omitempty"`
ApiUrl string `json:"api_url,omitempty"`
ClientKey string `json:"client_key,omitempty"`
CustomerID string `json:"customer_id,omitempty"`
ClientID string `json:"client_id,omitempty"`
ClientSecret string `json:"client_secret,omitempty"`
AuthUrl string `json:"auth_url,omitempty"`
ApiUrl string `json:"api_url,omitempty"`
ClientKey string `json:"client_key,omitempty"`
CustomerID string `json:"customer_id,omitempty"`
AccessClientID string `json:"access_client_id,omitempty"`
AccessClientSecret string `json:"access_client_secret,omitempty"`
}

// DevicePostureIntegration represents a device posture integration.
Expand Down
49 changes: 49 additions & 0 deletions device_posture_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,55 @@ func TestDevicePostureIntegrationCreate(t *testing.T) {
}
}

func TestDevicePostureIntegrationTaniumCreate(t *testing.T) {
setup()
defer teardown()

id := "480f4f69-1a28-4fdd-9240-1ed29f0ac1db"
handler := func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodPost, r.Method, "Expected method 'POST', got %s", r.Method)
w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, `{
"success": true,
"errors": [],
"messages": [],
"result": {
"id": "%s",
"interval": "1h",
"type": "tanium_s2s",
"name": "My Tanium integration",
"config": {
"api_url": "https://api_url.example.com",
"client_secret": "test_client_secret",
"access_client_id": "test_access_client_id",
"access_client_secret": "test_access_client_secret"
}
}
}`, id)
}

want := DevicePostureIntegration{
IntegrationID: id,
Name: "My Tanium integration",
Type: "tanium_s2s",
Interval: "1h",
Config: DevicePostureIntegrationConfig{
ApiUrl: "https://api_url.example.com",
ClientSecret: "test_client_secret",
AccessClientID: "test_access_client_id",
AccessClientSecret: "test_access_client_secret",
},
}

mux.HandleFunc("/accounts/"+testAccountID+"/devices/posture/integration", handler)

actual, err := client.CreateDevicePostureIntegration(context.Background(), testAccountID, want)

if assert.NoError(t, err) {
assert.Equal(t, want, actual)
}
}

func TestDevicePostureIntegrationDelete(t *testing.T) {
setup()
defer teardown()
Expand Down