splunk / terraform-provider-splunk

Terraform Provider for Splunk
Mozilla Public License 2.0
103 stars 75 forks source link

authorization_role capabilities should be a Set (unordered) #95

Closed micahkemp-splunk closed 2 years ago

micahkemp-splunk commented 2 years ago

Due to the way capabilities are stored in the underlying authorize.conf file, they are inherently unordered, and the order returned by splunkd via the REST API is not determined by the order they were created (even when created by the same REST API). This results in non-empty plans for the same configuration after apply.

This can be seen by reordering the list of capabilities passed in the test, which results in this failed acceptance test:

=== RUN   TestAccSplunkAuthorizationRoles
    testing.go:684: Step 0 error: After applying this step, the plan was not empty:

        DIFF:

        UPDATE: splunk_authorization_roles.role
          capabilities.#:                        "2" => "2"
          capabilities.0:                        "accelerate_datamodel" => "change_authentication"
          capabilities.1:                        "change_authentication" => "accelerate_datamodel"
          cumulative_realtime_search_jobs_quota: "0" => "0"
          cumulative_search_jobs_quota:          "0" => "0"
          default_app:                           "search" => "search"
          id:                                    "new-role" => "new-role"
          imported_roles.#:                      "1" => "1"
          imported_roles.0:                      "user" => "user"
          name:                                  "new-role" => "new-role"
          realtime_search_jobs_quota:            "6" => "6"
          search_disk_quota:                     "100" => "100"
          search_filter:                         "" => ""
          search_indexes_allowed.#:              "2" => "2"
          search_indexes_allowed.0:              "_audit" => "_audit"
          search_indexes_allowed.1:              "_internal" => "_internal"
          search_indexes_default.#:              "2" => "2"
          search_indexes_default.0:              "_audit" => "_audit"
          search_indexes_default.1:              "_internal" => "_internal"
          search_jobs_quota:                     "3" => "3"
          search_time_win:                       "-1" => "-1"

        STATE:

        splunk_authorization_roles.role:
          ID = new-role
          provider = provider.splunk
          capabilities.# = 2
          capabilities.0 = accelerate_datamodel
          capabilities.1 = change_authentication
          cumulative_realtime_search_jobs_quota = 0
          cumulative_search_jobs_quota = 0
          default_app = search
          imported_roles.# = 1
          imported_roles.0 = user
          name = new-role
          realtime_search_jobs_quota = 6
          search_disk_quota = 100
          search_filter = 
          search_indexes_allowed.# = 2
          search_indexes_allowed.0 = _audit
          search_indexes_allowed.1 = _internal
          search_indexes_default.# = 2
          search_indexes_default.0 = _audit
          search_indexes_default.1 = _internal
          search_jobs_quota = 3
          search_time_win = -1
--- FAIL: TestAccSplunkAuthorizationRoles (0.15s)
FAIL
FAIL    github.com/splunk/terraform-provider-splunk/splunk      0.629s
FAIL