From 02f1e2990e184c38b4205245a9e929334cd98a49 Mon Sep 17 00:00:00 2001 From: Haris Chaniotakis Date: Thu, 1 Jun 2023 18:52:06 +0300 Subject: [PATCH] feat: Introduce new sync_user_attributes SAML Connection field and ability to update it --- clerk/saml_connections.go | 42 ++++++++++++++++++---------------- clerk/saml_connections_test.go | 14 ++++++++---- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/clerk/saml_connections.go b/clerk/saml_connections.go index 9e4b511..1f44456 100644 --- a/clerk/saml_connections.go +++ b/clerk/saml_connections.go @@ -8,20 +8,21 @@ import ( type SAMLConnectionsService service type SAMLConnection struct { - ID string `json:"id"` - Object string `json:"object"` - Name string `json:"name"` - Domain string `json:"domain"` - IdpEntityID string `json:"idp_entity_id"` - IdpSsoURL string `json:"idp_sso_url"` - IdpCertificate string `json:"idp_certificate"` - AcsURL string `json:"acs_url"` - SPEntityID string `json:"sp_entity_id"` - Active bool `json:"active"` - Provider string `json:"provider"` - UserCount int64 `json:"user_count"` - CreatedAt int64 `json:"created_at"` - UpdatedAt int64 `json:"updated_at"` + ID string `json:"id"` + Object string `json:"object"` + Name string `json:"name"` + Domain string `json:"domain"` + IdpEntityID string `json:"idp_entity_id"` + IdpSsoURL string `json:"idp_sso_url"` + IdpCertificate string `json:"idp_certificate"` + AcsURL string `json:"acs_url"` + SPEntityID string `json:"sp_entity_id"` + Active bool `json:"active"` + Provider string `json:"provider"` + UserCount int64 `json:"user_count"` + SyncUserAttributes bool `json:"sync_user_attributes"` + CreatedAt int64 `json:"created_at"` + UpdatedAt int64 `json:"updated_at"` } type ListSAMLConnectionsResponse struct { @@ -99,12 +100,13 @@ func (s SAMLConnectionsService) Create(params *CreateSAMLConnectionParams) (*SAM } type UpdateSAMLConnectionParams struct { - Name *string `json:"name,omitempty"` - Domain *string `json:"domain,omitempty"` - IdpEntityID *string `json:"idp_entity_id,omitempty"` - IdpSsoURL *string `json:"idp_sso_url,omitempty"` - IdpCertificate *string `json:"idp_certificate,omitempty"` - Active *bool `json:"active,omitempty"` + Name *string `json:"name,omitempty"` + Domain *string `json:"domain,omitempty"` + IdpEntityID *string `json:"idp_entity_id,omitempty"` + IdpSsoURL *string `json:"idp_sso_url,omitempty"` + IdpCertificate *string `json:"idp_certificate,omitempty"` + Active *bool `json:"active,omitempty"` + SyncUserAttributes *bool `json:"sync_user_attributes,omitempty"` } func (s SAMLConnectionsService) Update(id string, params *UpdateSAMLConnectionParams) (*SAMLConnection, error) { diff --git a/clerk/saml_connections_test.go b/clerk/saml_connections_test.go index c2a7e5c..56e7927 100644 --- a/clerk/saml_connections_test.go +++ b/clerk/saml_connections_test.go @@ -112,6 +112,7 @@ func TestSAMLConnectionsService_Create(t *testing.T) { func TestSAMLConnectionsService_Update(t *testing.T) { expectedName := "New name for Testing SAML" expectedActive := true + expectedSyncUserAttributes := false dummyResponse := dummySAMLConnectionUpdatedJSON c, mux, _, teardown := setup("token") @@ -126,8 +127,9 @@ func TestSAMLConnectionsService_Update(t *testing.T) { }) updateParams := &UpdateSAMLConnectionParams{ - Name: &expectedName, - Active: &expectedActive, + Name: &expectedName, + Active: &expectedActive, + SyncUserAttributes: &expectedSyncUserAttributes, } got, err := c.SAMLConnections().Update(dummySAMLConnectionID, updateParams) @@ -184,7 +186,8 @@ const ( "sp_entity_id": "` + "https://clerk.example.com/acs" + dummySAMLConnectionID + `", "active": false, "provider": "saml_custom", - "user_count": 3 + "user_count": 3, + "sync_user_attributes": true }` dummySAMLConnectionUpdatedJSON = ` @@ -198,7 +201,10 @@ const ( "idp_certificate": "` + dummySAMLConnectionCertificate + `", "acs_url": "` + "https://clerk.example.com/v1/saml/acs" + dummySAMLConnectionID + `", "sp_entity_id": "` + "https://clerk.example.com/acs" + dummySAMLConnectionID + `", - "active": true + "active": true, + "provider": "saml_custom", + "user_count": 3, + "sync_user_attributes": false }` dummySAMLConnectionCertificate = `MIIDBzCCAe+gAwIBAgIJAPr/Mrlc8EGhMA0GCSqGSIb3DQEBBQUAMBoxGDAWBgN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