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

Add show_as_button field to Organization Enabled Connection #386

Merged
merged 6 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions management/management.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions management/management.gen_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions management/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ type OrganizationConnection struct {

// Connection details
Connection *OrganizationConnectionDetails `json:"connection,omitempty"`

// Determines whether a connection should be displayed on this organization’s login prompt.
// Only applicable for enterprise connections. Default: true.
ShowAsButton *bool `json:"show_as_button,omitempty"`
}

// OrganizationConnectionDetails holds connection details for an Organization.
Expand Down
8 changes: 6 additions & 2 deletions management/organization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func TestOrganizationManager_AddConnection(t *testing.T) {
conn := givenAConnection(t, connectionTestCase{connection: Connection{
Name: auth0.String(fmt.Sprintf("test-conn%v", rand.Intn(999))),
DisplayName: auth0.String(fmt.Sprintf("Test Connection %v", rand.Intn(999))),
Strategy: auth0.String(ConnectionStrategyAuth0),
Strategy: auth0.String(ConnectionStrategyAD),
EnabledClients: &[]string{
os.Getenv("AUTH0_CLIENT_ID"),
client.GetClientID(),
Expand All @@ -129,6 +129,7 @@ func TestOrganizationManager_AddConnection(t *testing.T) {
orgConn := &OrganizationConnection{
ConnectionID: conn.ID,
AssignMembershipOnLogin: auth0.Bool(true),
ShowAsButton: auth0.Bool(true),
}

err := api.Organization.AddConnection(context.Background(), org.GetID(), orgConn)
Expand Down Expand Up @@ -159,13 +160,15 @@ func TestOrganizationManager_UpdateConnection(t *testing.T) {
orgConn.GetConnectionID(),
&OrganizationConnection{
AssignMembershipOnLogin: auth0.Bool(false),
ShowAsButton: auth0.Bool(false),
},
)
assert.NoError(t, err)

actualOrgConn, err := api.Organization.Connection(context.Background(), org.GetID(), orgConn.GetConnectionID())
assert.NoError(t, err)
assert.Equal(t, false, actualOrgConn.GetAssignMembershipOnLogin())
assert.Equal(t, false, actualOrgConn.GetShowAsButton())
}

func TestOrganizationManager_DeleteConnection(t *testing.T) {
Expand Down Expand Up @@ -413,7 +416,7 @@ func givenAnOrganizationConnection(t *testing.T, orgID string) *OrganizationConn
connection: Connection{
Name: auth0.String(fmt.Sprintf("test-conn%v", rand.Intn(999))),
DisplayName: auth0.String(fmt.Sprintf("Test Connection %v", rand.Intn(999))),
Strategy: auth0.String(ConnectionStrategyAuth0),
Strategy: auth0.String(ConnectionStrategyAD),
EnabledClients: &[]string{
os.Getenv("AUTH0_CLIENT_ID"),
client.GetClientID(),
Expand All @@ -423,6 +426,7 @@ func givenAnOrganizationConnection(t *testing.T, orgID string) *OrganizationConn
orgConn := &OrganizationConnection{
ConnectionID: conn.ID,
AssignMembershipOnLogin: auth0.Bool(true),
ShowAsButton: auth0.Bool(true),
}

err := api.Organization.AddConnection(context.Background(), orgID, orgConn)
Expand Down
68 changes: 34 additions & 34 deletions test/data/recordings/TestOrganizationManager_AddConnection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ interactions:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 122
content_length: 121
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: |
{"name":"test-organization135","display_name":"Test Organization","branding":{"logo_url":"https://example.com/logo.gif"}}
{"name":"test-organization84","display_name":"Test Organization","branding":{"logo_url":"https://example.com/logo.gif"}}
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0-SDK/latest
- Go-Auth0/1.4.1
url: https://go-auth0-dev.eu.auth0.com/api/v2/organizations
method: POST
response:
Expand All @@ -28,34 +28,34 @@ interactions:
proto_minor: 0
transfer_encoding: []
trailer: {}
content_length: 149
content_length: 148
uncompressed: false
body: '{"name":"test-organization135","display_name":"Test Organization","branding":{"logo_url":"https://example.com/logo.gif"},"id":"org_Q7iOAmBVkznO9qKC"}'
body: '{"name":"test-organization84","display_name":"Test Organization","branding":{"logo_url":"https://example.com/logo.gif"},"id":"org_4qZ1E6dOgoRf4jUi"}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 201 Created
code: 201
duration: 115.199042ms
duration: 921.481167ms
- id: 1
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 118
content_length: 1125
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: |
{"name":"Test Client (Jan 25 18:49:19.325)","description":"This is just a test client.","organization_usage":"allow"}
{"name":"Test Client (Apr 15 15:34:07.237)","description":"This is just a test client.","jwt_configuration":{"alg":"RS256"},"organization_usage":"allow","client_authentication_methods":{"private_key_jwt":{"credentials":[{"name":"Test Credential (Apr 15 15:34:07.237)","credential_type":"public_key","pem":"-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAua6LXMfgDE/tDdkOL1Oe\n3oWUwg1r4dSTg9L7RCcI5hItUzmkVofHtWN0H4CH2lm2ANmaJUsnhzctYowYW2+R\ntHvU9afTmtbdhpy993972hUqZSYLsE3iGziphYkOKVsqq38+VRH3TNg93zSLoRao\nJnTTkMXseVqiyqYRmFN8+gQQoEclHSGPUWQG5XMZ+hhuXeFyo+Yw/qbZWca/6/2I\n3rsca9jXR1alhxhHrXrg8N4Dm3gBgGbmiht6YYYT2Tyl1OqB9+iOI/9D7dfoCF6X\nAWJXRE454cmC8k8oucpjZVpflA+ocKshwPDR6YTLQYbXYiaWxEoaz0QGUErNQBnG\nI+sr9jDY3ua/s6HF6h0qyi/HVZH4wx+m4CtOfJoYTjrGBbaRszzUxhtSN2/MhXDu\n+a35q9/2zcu/3fjkkfVvGUt+NyyiYOKQ9vsJC1g/xxdUWtowjNwjfZE2zcG4usi8\nr38Bp0lmiipAsMLduZM/D5dFXkRdWCBNDfULmmg/4nv2wwjbjQuLemAMh7mmrztW\ni/85WMnjKQZT8NqS43pmgyIzg1gK1neMqdS90YmQ/PvJ36qALxCs245w1JpN9BAL\nJbwxCg/dbmKT7PalfWrksx9hGcJxtGqebldaOpw+5GVIPxxtC1C0gVr9BKeiDS3f\naibASY5pIRiKENmbZELDtucCAwEAAQ==\n-----END PUBLIC KEY-----"}]}}}
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0-SDK/latest
- Go-Auth0/1.4.1
url: https://go-auth0-dev.eu.auth0.com/api/v2/clients
method: POST
response:
Expand All @@ -66,32 +66,32 @@ interactions:
trailer: {}
content_length: -1
uncompressed: false
body: '{"name":"Test Client (Jan 25 18:49:19.325)","description":"This is just a test client.","client_id":"OflO6yT8umZN1YaR6B0nNuRXFs29ZoE6","is_first_party":true,"is_token_endpoint_ip_header_trusted":false,"oidc_conformant":false,"jwt_configuration":{"secret_encoded":false,"lifetime_in_seconds":36000},"sso_disabled":false,"cross_origin_auth":false,"grant_types":["authorization_code","implicit","refresh_token","client_credentials"],"custom_login_page_on":true,"refresh_token":{"rotation_type":"non-rotating","expiration_type":"non-expiring","leeway":0,"token_lifetime":2592000,"infinite_token_lifetime":true,"infinite_idle_token_lifetime":true,"idle_token_lifetime":1296000},"organization_usage":"allow"}'
body: '{"name":"Test Client (Apr 15 15:34:07.237)","description":"This is just a test client.","client_id":"QSzR53mpRPYLuZdrcb5EhKH4D900wd9o","client_secret":"[REDACTED]","is_first_party":true,"is_token_endpoint_ip_header_trusted":false,"oidc_conformant":false,"jwt_configuration":{"secret_encoded":false,"alg":"RS256"},"signing_keys":[{"cert":"[REDACTED]"}],"sso_disabled":false,"grant_types":["authorization_code","implicit","refresh_token","client_credentials"],"custom_login_page_on":true,"refresh_token":{"rotation_type":"non-rotating","expiration_type":"non-expiring","leeway":0,"token_lifetime":2592000,"infinite_token_lifetime":true,"infinite_idle_token_lifetime":true,"idle_token_lifetime":1296000},"organization_usage":"allow","client_authentication_methods":{"private_key_jwt":{"credentials":[{"id":"cred_mSP13LXRPRNqGt7pu6aucR","name":"Test Credential (Apr 15 15:34:07.237)","kid":"4e7yYf0TKdyTLbVnpq2wLN6mZ8t7eb9UJkMksyHj9iU","credential_type":"public_key","alg":"RS256","created_at":"2024-04-15T10:04:07.562Z","updated_at":"2024-04-15T10:04:07.562Z"}]}}}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 201 Created
code: 201
duration: 277.429167ms
duration: 556.251125ms
- id: 2
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 169
content_length: 167
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: |
{"name":"test-conn565","display_name":"Test Connection 43","strategy":"auth0","enabled_clients":["3tjbn4dFI04fpHKnVlGs1GYDzQKIEmbF","OflO6yT8umZN1YaR6B0nNuRXFs29ZoE6"]}
{"name":"test-conn758","display_name":"Test Connection 877","strategy":"ad","enabled_clients":["T2QUXhLciH0CSlDCICirlExjNDIrsHJQ","QSzR53mpRPYLuZdrcb5EhKH4D900wd9o"]}
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0-SDK/latest
- Go-Auth0/1.4.1
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections
method: POST
response:
Expand All @@ -100,51 +100,51 @@ interactions:
proto_minor: 0
transfer_encoding: []
trailer: {}
content_length: 390
content_length: 422
uncompressed: false
body: '{"id":"con_C8S03WlnbPUvnIIK","options":{"mfa":{"active":true,"return_enroll_settings":true},"passwordPolicy":"good","strategy_version":2,"brute_force_protection":true},"strategy":"auth0","name":"test-conn565","is_domain_connection":false,"display_name":"Test Connection 43","enabled_clients":["3tjbn4dFI04fpHKnVlGs1GYDzQKIEmbF","OflO6yT8umZN1YaR6B0nNuRXFs29ZoE6"],"realms":["test-conn565"]}'
body: '{"id":"con_wmWO6ebGIGecPs04","options":{"ips":null,"brute_force_protection":true},"strategy":"ad","name":"test-conn758","provisioning_ticket_url":"https://go-auth0-dev.eu.auth0.com.us.auth0.com/p/ad/STuLnVKze0coWD7XkGFEtAPIy30aFgbD","is_domain_connection":false,"show_as_button":false,"display_name":"Test Connection 877","enabled_clients":["QSzR53mpRPYLuZdrcb5EhKH4D900wd9o","T2QUXhLciH0CSlDCICirlExjNDIrsHJQ"],"realms":["test-conn758"]}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 201 Created
code: 201
duration: 142.779625ms
duration: 388.592875ms
- id: 3
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 75
content_length: 97
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: |
{"connection_id":"con_C8S03WlnbPUvnIIK","assign_membership_on_login":true}
{"connection_id":"con_wmWO6ebGIGecPs04","assign_membership_on_login":true,"show_as_button":true}
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0-SDK/latest
url: https://go-auth0-dev.eu.auth0.com/api/v2/organizations/org_Q7iOAmBVkznO9qKC/enabled_connections
- Go-Auth0/1.4.1
url: https://go-auth0-dev.eu.auth0.com/api/v2/organizations/org_4qZ1E6dOgoRf4jUi/enabled_connections
method: POST
response:
proto: HTTP/2.0
proto_major: 2
proto_minor: 0
transfer_encoding: []
trailer: {}
content_length: 130
content_length: 149
uncompressed: false
body: '{"connection_id":"con_C8S03WlnbPUvnIIK","assign_membership_on_login":true,"connection":{"name":"test-conn565","strategy":"auth0"}}'
body: '{"connection_id":"con_wmWO6ebGIGecPs04","assign_membership_on_login":true,"show_as_button":true,"connection":{"name":"test-conn758","strategy":"ad"}}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 201 Created
code: 201
duration: 111.124041ms
duration: 351.179917ms
- id: 4
request:
proto: HTTP/1.1
Expand All @@ -162,8 +162,8 @@ interactions:
Content-Type:
- application/json
User-Agent:
- Go-Auth0-SDK/latest
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections/con_C8S03WlnbPUvnIIK
- Go-Auth0/1.4.1
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections/con_wmWO6ebGIGecPs04
method: DELETE
response:
proto: HTTP/2.0
Expand All @@ -173,13 +173,13 @@ interactions:
trailer: {}
content_length: 41
uncompressed: false
body: '{"deleted_at":"2023-01-25T17:49:20.073Z"}'
body: '{"deleted_at":"2024-04-15T10:04:08.822Z"}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 202 Accepted
code: 202
duration: 172.283375ms
duration: 375.211416ms
- id: 5
request:
proto: HTTP/1.1
Expand All @@ -197,8 +197,8 @@ interactions:
Content-Type:
- application/json
User-Agent:
- Go-Auth0-SDK/latest
url: https://go-auth0-dev.eu.auth0.com/api/v2/clients/OflO6yT8umZN1YaR6B0nNuRXFs29ZoE6
- Go-Auth0/1.4.1
url: https://go-auth0-dev.eu.auth0.com/api/v2/clients/QSzR53mpRPYLuZdrcb5EhKH4D900wd9o
method: DELETE
response:
proto: HTTP/2.0
Expand All @@ -214,7 +214,7 @@ interactions:
- application/json; charset=utf-8
status: 204 No Content
code: 204
duration: 182.829542ms
duration: 387.498125ms
- id: 6
request:
proto: HTTP/1.1
Expand All @@ -232,8 +232,8 @@ interactions:
Content-Type:
- application/json
User-Agent:
- Go-Auth0-SDK/latest
url: https://go-auth0-dev.eu.auth0.com/api/v2/organizations/org_Q7iOAmBVkznO9qKC
- Go-Auth0/1.4.1
url: https://go-auth0-dev.eu.auth0.com/api/v2/organizations/org_4qZ1E6dOgoRf4jUi
method: DELETE
response:
proto: HTTP/2.0
Expand All @@ -249,4 +249,4 @@ interactions:
- application/json; charset=utf-8
status: 204 No Content
code: 204
duration: 156.511625ms
duration: 351.149833ms
Loading
Loading