Skip to content

Commit

Permalink
Merge pull request #1464 from kjhandy/khandy/add-device-posture-integ…
Browse files Browse the repository at this point in the history
…ration-access-fields

Adding Access client secret and ID to device posture integration
  • Loading branch information
jacobbednarz committed Dec 19, 2023
2 parents f6b429a + 7169cce commit ace6e0e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 6 deletions.
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

0 comments on commit ace6e0e

Please sign in to comment.