Skip to content

Commit

Permalink
feat: Introduce new sync_user_attributes SAML Connection field and ab…
Browse files Browse the repository at this point in the history
…ility to update it
  • Loading branch information
chanioxaris committed Jun 2, 2023
1 parent adfbf66 commit 02f1e29
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
42 changes: 22 additions & 20 deletions clerk/saml_connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
14 changes: 10 additions & 4 deletions clerk/saml_connections_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand Down Expand Up @@ -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 = `
Expand All @@ -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/Mrlc8EGhMA0GCSqGSIb3DQEBBQUAMBoxGDAWBgNVBAMMD3d3dy5leGFtcGxlLmNvbTAeFw0xNTEyMjgxOTE5NDVaFw0yNTE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