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

feat: add missing fields from AdminSAMLSetting and AdminSAMLSettingsUpdateOptions structs #731

Merged
merged 3 commits into from
Jul 12, 2023
Merged

feat: add missing fields from AdminSAMLSetting and AdminSAMLSettingsUpdateOptions structs #731

merged 3 commits into from
Jul 12, 2023

Conversation

karvounis-form3
Copy link
Contributor

@karvounis-form3 karvounis-form3 commented Jul 5, 2023

Description

This change is about adding missing fields to the AdminSAMLSetting and AdminSAMLSettingsUpdateOptions structs.

AdminSAMLSetting

Fields that appear in the JSON response of the TFE v202305-2 when calling the GET /api/v2/admin/saml-settings endpoint. Some of them were added to the AdminSAMLSetting struct.

$ curl -s --header "Authorization: Bearer $TFE_TOKEN" --header "Content-Type: application/vnd.api+json" --request GET https://$TFE_HOSTNAME/api/v2/admin/saml-settings | jq . 
{
  "data": {
    "id": "saml",
    "type": "saml-settings",
    "attributes": {
      "enabled": true,
      "debug": true,
      "idp-cert": "...",
      "old-idp-cert": "...",
      "slo-endpoint-url": "https://example.com/url",
      "sso-endpoint-url": "https://example.com/sso",
      "team-management-enabled": true,
      "attr-username": "...",
      "attr-groups": "MemberOf",
      "attr-site-admin": "SiteAdmin-test",
      "site-admin-role": "site-admins-test",
      "sso-api-token-session-timeout": 1111111,
      "acs-consumer-url": "...",
      "metadata-url": "...",
      "certificate": "testCertificate",
      "authn-requests-signed": true,
      "want-assertions-signed": true,
      "signature-signing-method": "SHA256",
      "signature-digest-method": "SHA1",
      "private-key": null
    }
  }
}

AdminSAMLSettingsUpdateOptions

Fields are also missing from the AdminSAMLSettingsUpdateOptions struct. The API request body of the PATCH /api/v2/admin/saml-settings request supports more fields.

TFE Documentation is not up to date with the current TFE API.

Closes: #730

Testing plan

External links

Output from tests

Including output from tests may require access to a TFE instance. Ignore this section if you have no environment to test against.

Read SAML settings

$ TFE_ADDRESS="https://example" ENABLE_TFE=1 go test -run TestAdminSettings_SAML_Read -v ./...

=== RUN   TestAdminSettings_SAML_Read
--- PASS: TestAdminSettings_SAML_Read (0.48s)
PASS
ok  	github.com/hashicorp/go-tfe	(cached)
?   	github.com/hashicorp/go-tfe/examples/configuration_versions	[no test files]
?   	github.com/hashicorp/go-tfe/examples/organizations	[no test files]
?   	github.com/hashicorp/go-tfe/examples/registry_modules	[no test files]
?   	github.com/hashicorp/go-tfe/examples/state_versions	[no test files]
?   	github.com/hashicorp/go-tfe/examples/users	[no test files]
?   	github.com/hashicorp/go-tfe/examples/workspaces	[no test files]
?   	github.com/hashicorp/go-tfe/mocks	[no test files]

Update SAML settings

$ TFE_ADDRESS="https://example" ENABLE_TFE=1 go test -run TestAdminSettings_SAML_Update -v ./... 

=== RUN   TestAdminSettings_SAML_Update
=== RUN   TestAdminSettings_SAML_Update/with_certificate_defined
=== RUN   TestAdminSettings_SAML_Update/with_team_management_defined
=== RUN   TestAdminSettings_SAML_Update/with_invalid_signature_digest_method
=== RUN   TestAdminSettings_SAML_Update/with_invalid_signature_signing_method
--- PASS: TestAdminSettings_SAML_Update (2.22s)
    --- PASS: TestAdminSettings_SAML_Update/with_certificate_defined (0.12s)
    --- PASS: TestAdminSettings_SAML_Update/with_team_management_defined (0.12s)
    --- PASS: TestAdminSettings_SAML_Update/with_invalid_signature_digest_method (0.12s)
    --- PASS: TestAdminSettings_SAML_Update/with_invalid_signature_signing_method (0.16s)
PASS
ok  	github.com/hashicorp/go-tfe	3.055s
?   	github.com/hashicorp/go-tfe/examples/configuration_versions	[no test files]
?   	github.com/hashicorp/go-tfe/examples/organizations	[no test files]
?   	github.com/hashicorp/go-tfe/examples/registry_modules	[no test files]
?   	github.com/hashicorp/go-tfe/examples/state_versions	[no test files]
?   	github.com/hashicorp/go-tfe/examples/users	[no test files]
?   	github.com/hashicorp/go-tfe/examples/workspaces	[no test files]
?   	github.com/hashicorp/go-tfe/mocks	[no test files]

@karvounis-form3 karvounis-form3 requested a review from a team as a code owner July 5, 2023 12:47
@hashicorp-cla
Copy link

hashicorp-cla commented Jul 5, 2023

CLA assistant check
All committers have signed the CLA.

@karvounis-form3
Copy link
Contributor Author

By the way, documentation is not up to date for:

@karvounis-form3 karvounis-form3 changed the title feat: add SignatureSigningMethod and SignatureDigestMethod to AdminSAMLSetting struct feat: add missing fields from AdminSAMLSetting and AdminSAMLSettingsUpdateOptions structs Jul 5, 2023
@uturunku1 uturunku1 self-requested a review July 11, 2023 22:29
Copy link
Collaborator

@uturunku1 uturunku1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you for your contribution @karvounis-form3 ! Whenever you are ready, go ahead merge this PR and close the GitHub issue.

@uturunku1 uturunku1 mentioned this pull request Jul 11, 2023
@karvounis-form3
Copy link
Contributor Author

@uturunku1 Unfortunately, I do not have proper permissions to merge this PR

This branch has no conflicts with the base branch
Only those with [write access](https://docs.github.com/articles/what-are-the-different-access-permissions) to this repository can merge pull requests.

@uturunku1
Copy link
Collaborator

@uturunku1 Unfortunately, I do not have proper permissions to merge this PR

This branch has no conflicts with the base branch
Only those with [write access](https://docs.github.com/articles/what-are-the-different-access-permissions) to this repository can merge pull requests.

Opps, my bad. I will merge this then!

@uturunku1 uturunku1 merged commit 91cab4c into hashicorp:main Jul 12, 2023
@github-actions
Copy link

Reminder to the contributor that merged this PR: if your changes have added important functionality or fixed a relevant bug, open a follow-up PR to update CHANGELOG.md with a note on your changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AdminSAMLSetting struct does not support signature-signing-method and signature-digest-method attributes
3 participants