Skip to content

Commit

Permalink
Fix Optional Fields on DB Connection Options
Browse files Browse the repository at this point in the history
  • Loading branch information
developerkunal committed Aug 6, 2024
1 parent 234fb62 commit d875fe0
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 52 deletions.
16 changes: 8 additions & 8 deletions management/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,12 +454,12 @@ type ConnectionOptionsAttributes struct {

// ConnectionOptionsAttributeIdentifier defines whether an attribute is active as an identifier.
type ConnectionOptionsAttributeIdentifier struct {
Active *bool `json:"active"`
Active *bool `json:"active,omitempty"`
}

// ConnectionOptionsAttributeSignup defines signup settings for an attribute.
type ConnectionOptionsAttributeSignup struct {
Status *string `json:"status"`
Status *string `json:"status,omitempty"`

// Verification settings for an attribute. Only applicable to email and phone_number attributes.
Verification *ConnectionOptionsAttributeVerification `json:"verification,omitempty"`
Expand All @@ -483,7 +483,7 @@ func (c *ConnectionOptionsUsernameAttribute) MarshalJSON() ([]byte, error) {

// ConnectionOptionsAttributeVerification defines verification settings for an attribute.
type ConnectionOptionsAttributeVerification struct {
Active *bool `json:"active"`
Active *bool `json:"active,omitempty"`
}

// ConnectionOptionsAttributeValidation defines validation settings for an attribute.
Expand All @@ -495,21 +495,21 @@ type ConnectionOptionsAttributeValidation struct {

// ConnectionOptionsAttributeAllowedTypes defines allowed types for an attribute.
type ConnectionOptionsAttributeAllowedTypes struct {
Email *bool `json:"email"`
PhoneNumber *bool `json:"phone_number"`
Email *bool `json:"email,omitempty"`
PhoneNumber *bool `json:"phone_number,omitempty"`
}

// ConnectionOptionsEmailAttribute defines configuration settings for email attributes.
type ConnectionOptionsEmailAttribute struct {
Identifier *ConnectionOptionsAttributeIdentifier `json:"identifier,omitempty"`
ProfileRequired *bool `json:"profile_required"`
ProfileRequired *bool `json:"profile_required,omitempty"`
Signup *ConnectionOptionsAttributeSignup `json:"signup,omitempty"`
}

// ConnectionOptionsUsernameAttribute defines configuration settings for username attributes.
type ConnectionOptionsUsernameAttribute struct {
Identifier *ConnectionOptionsAttributeIdentifier `json:"identifier,omitempty"`
ProfileRequired *bool `json:"profile_required"`
ProfileRequired *bool `json:"profile_required,omitempty"`
Signup *ConnectionOptionsAttributeSignup `json:"signup,omitempty"`
Validation *ConnectionOptionsAttributeValidation `json:"validation,omitempty"`
}
Expand All @@ -518,7 +518,7 @@ type ConnectionOptionsUsernameAttribute struct {
// This attribute is available only when the Prompt 'identifier first' setting is enabled.
type ConnectionOptionsPhoneNumberAttribute struct {
Identifier *ConnectionOptionsAttributeIdentifier `json:"identifier,omitempty"`
ProfileRequired *bool `json:"profile_required"`
ProfileRequired *bool `json:"profile_required,omitempty"`
Signup *ConnectionOptionsAttributeSignup `json:"signup,omitempty"`
}

Expand Down
8 changes: 8 additions & 0 deletions management/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,14 @@ var Auth0ConnectionTestCase = []connectionTestCase{
Signup: &ConnectionOptionsAttributeSignup{
Status: auth0.String("required"),
},
Validation: &ConnectionOptionsAttributeValidation{
MinLength: auth0.Int(1),
MaxLength: auth0.Int(5),
AllowedTypes: &ConnectionOptionsAttributeAllowedTypes{
Email: auth0.Bool(true),
PhoneNumber: auth0.Bool(false),
},
},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ interactions:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 252
content_length: 301
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: |
{"name":"Test-Auth0-Connection-Attribute-Inactive-On-Signup-1720679132","strategy":"auth0","options":{"attributes":{"phone_number":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"inactive","verification":{"active":false}}}}}}
{"name":"Test-Auth0-Connection-Attribute-Inactive-On-Signup-1722944272","strategy":"auth0","options":{"precedence":["username","email","phone_number"],"attributes":{"phone_number":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"inactive","verification":{"active":false}}}}}}
form: {}
headers:
Content-Type:
Expand All @@ -36,4 +36,4 @@ interactions:
- application/json; charset=utf-8
status: 400 Bad Request
code: 400
duration: 349.747667ms
duration: 236.792042ms
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ interactions:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 249
content_length: 298
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: |
{"name":"Test-Auth0-Connection-Invalid-1720679132","strategy":"auth0","options":{"requires_username":true,"attributes":{"email":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}}}}}
{"name":"Test-Auth0-Connection-Invalid-1722944272","strategy":"auth0","options":{"requires_username":true,"precedence":["username","email","phone_number"],"attributes":{"email":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}}}}}
form: {}
headers:
Content-Type:
Expand All @@ -36,4 +36,4 @@ interactions:
- application/json; charset=utf-8
status: 400 Bad Request
code: 400
duration: 376.519916ms
duration: 230.9955ms
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ interactions:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 383
content_length: 432
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: |
{"name":"Test-Auth0-Connection-Attributes-And-Validation-1720679132","strategy":"auth0","options":{"validation":{"username":{"max":5,"min":1}},"attributes":{"email":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":true}}},"username":{"identifier":{"active":true},"profile_required":false,"signup":{"status":"required"}}}}}
{"name":"Test-Auth0-Connection-Attributes-And-Validation-1722944272","strategy":"auth0","options":{"validation":{"username":{"max":5,"min":1}},"precedence":["username","email","phone_number"],"attributes":{"email":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}},"username":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required"}}}}}
form: {}
headers:
Content-Type:
Expand All @@ -36,4 +36,4 @@ interactions:
- application/json; charset=utf-8
status: 400 Bad Request
code: 400
duration: 516.528375ms
duration: 278.591625ms
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ interactions:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 473
content_length: 519
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: |
{"name":"Test-Auth0-Connection-No-Active-Attributes-1720679132","strategy":"auth0","options":{"attributes":{"email":{"identifier":{"active":false},"profile_required":false,"signup":{"status":"required","verification":{"active":false}}},"phone_number":{"identifier":{"active":false},"profile_required":false,"signup":{"status":"required","verification":{"active":false}}},"username":{"identifier":{"active":false},"profile_required":false,"signup":{"status":"required"}}}}}
{"name":"Test-Auth0-Connection-No-Active-Attributes-1722944272","strategy":"auth0","options":{"precedence":["username","email","phone_number"],"attributes":{"email":{"identifier":{"active":false},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}},"username":{"identifier":{"active":false},"profile_required":true,"signup":{"status":"required"}},"phone_number":{"identifier":{"active":false},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}}}}}
form: {}
headers:
Content-Type:
Expand All @@ -36,4 +36,4 @@ interactions:
- application/json; charset=utf-8
status: 400 Bad Request
code: 400
duration: 357.934708ms
duration: 235.546625ms
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ interactions:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 116
content_length: 165
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: |
{"name":"Test-Auth0-Connection-RequireUsername-1720679132","strategy":"auth0","options":{"requires_username":true}}
{"name":"Test-Auth0-Connection-RequireUsername-1722944272","strategy":"auth0","options":{"requires_username":true,"precedence":["username","email","phone_number"]}}
form: {}
headers:
Content-Type:
Expand All @@ -28,15 +28,15 @@ interactions:
proto_minor: 0
transfer_encoding: []
trailer: {}
content_length: 577
content_length: 626
uncompressed: false
body: '{"id":"con_m9a3URYUtiwf0BGT","options":{"mfa":{"active":true,"return_enroll_settings":true},"passwordPolicy":"good","requires_username":true,"strategy_version":2,"authentication_methods":{"password":{"enabled":true},"passkey":{"enabled":false}},"passkey_options":{"challenge_ui":"both","progressive_enrollment_enabled":true,"local_enrollment_enabled":true},"brute_force_protection":true},"strategy":"auth0","name":"Test-Auth0-Connection-RequireUsername-1720679132","is_domain_connection":false,"enabled_clients":[],"realms":["Test-Auth0-Connection-RequireUsername-1720679132"]}'
body: '{"id":"con_5IOlGu2ZxeX9Sk1E","options":{"mfa":{"active":true,"return_enroll_settings":true},"passwordPolicy":"good","requires_username":true,"precedence":["username","email","phone_number"],"strategy_version":2,"authentication_methods":{"password":{"enabled":true},"passkey":{"enabled":false}},"passkey_options":{"challenge_ui":"both","progressive_enrollment_enabled":true,"local_enrollment_enabled":true},"brute_force_protection":true},"strategy":"auth0","name":"Test-Auth0-Connection-RequireUsername-1722944272","is_domain_connection":false,"enabled_clients":[],"realms":["Test-Auth0-Connection-RequireUsername-1722944272"]}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 201 Created
code: 201
duration: 966.438125ms
duration: 902.643167ms
- id: 1
request:
proto: HTTP/1.1
Expand All @@ -55,7 +55,7 @@ interactions:
- application/json
User-Agent:
- Go-Auth0/1.8.0
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections/con_m9a3URYUtiwf0BGT
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections/con_5IOlGu2ZxeX9Sk1E
method: DELETE
response:
proto: HTTP/2.0
Expand All @@ -65,10 +65,10 @@ interactions:
trailer: {}
content_length: 41
uncompressed: false
body: '{"deleted_at":"2024-07-11T06:25:33.377Z"}'
body: '{"deleted_at":"2024-08-06T11:37:54.076Z"}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 202 Accepted
code: 202
duration: 367.648416ms
duration: 288.051167ms
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ interactions:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 222
content_length: 271
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: |
{"name":"Test-Auth0-Connection-Email-1720679132","strategy":"auth0","options":{"attributes":{"email":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}}}}}
{"name":"Test-Auth0-Connection-Email-1722944272","strategy":"auth0","options":{"precedence":["username","email","phone_number"],"attributes":{"email":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}}}}}
form: {}
headers:
Content-Type:
Expand All @@ -28,15 +28,15 @@ interactions:
proto_minor: 0
transfer_encoding: []
trailer: {}
content_length: 673
content_length: 722
uncompressed: false
body: '{"id":"con_79cNlTmqfsIeaCep","options":{"mfa":{"active":true,"return_enroll_settings":true},"passwordPolicy":"good","attributes":{"email":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}}},"strategy_version":2,"authentication_methods":{"password":{"enabled":true},"passkey":{"enabled":false}},"passkey_options":{"challenge_ui":"both","progressive_enrollment_enabled":true,"local_enrollment_enabled":true},"brute_force_protection":true},"strategy":"auth0","name":"Test-Auth0-Connection-Email-1720679132","is_domain_connection":false,"enabled_clients":[],"realms":["Test-Auth0-Connection-Email-1720679132"]}'
body: '{"id":"con_0XAEEFvSK34smafH","options":{"mfa":{"active":true,"return_enroll_settings":true},"passwordPolicy":"good","precedence":["username","email","phone_number"],"attributes":{"email":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}}},"strategy_version":2,"authentication_methods":{"password":{"enabled":true},"passkey":{"enabled":false}},"passkey_options":{"challenge_ui":"both","progressive_enrollment_enabled":true,"local_enrollment_enabled":true},"brute_force_protection":true},"strategy":"auth0","name":"Test-Auth0-Connection-Email-1722944272","is_domain_connection":false,"enabled_clients":[],"realms":["Test-Auth0-Connection-Email-1722944272"]}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 201 Created
code: 201
duration: 419.663875ms
duration: 269.858042ms
- id: 1
request:
proto: HTTP/1.1
Expand All @@ -55,7 +55,7 @@ interactions:
- application/json
User-Agent:
- Go-Auth0/1.8.0
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections/con_79cNlTmqfsIeaCep
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections/con_0XAEEFvSK34smafH
method: DELETE
response:
proto: HTTP/2.0
Expand All @@ -65,10 +65,10 @@ interactions:
trailer: {}
content_length: 41
uncompressed: false
body: '{"deleted_at":"2024-07-11T06:25:35.112Z"}'
body: '{"deleted_at":"2024-08-06T11:37:55.197Z"}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 202 Accepted
code: 202
duration: 505.959625ms
duration: 304.755625ms
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ interactions:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 229
content_length: 278
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: |
{"name":"Test-Auth0-Connection-Phone-1720679132","strategy":"auth0","options":{"attributes":{"phone_number":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}}}}}
{"name":"Test-Auth0-Connection-Phone-1722944272","strategy":"auth0","options":{"precedence":["username","email","phone_number"],"attributes":{"phone_number":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}}}}}
form: {}
headers:
Content-Type:
Expand All @@ -28,15 +28,15 @@ interactions:
proto_minor: 0
transfer_encoding: []
trailer: {}
content_length: 680
content_length: 729
uncompressed: false
body: '{"id":"con_o3oE5KvCvPLkZh4d","options":{"mfa":{"active":true,"return_enroll_settings":true},"passwordPolicy":"good","attributes":{"phone_number":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}}},"strategy_version":2,"authentication_methods":{"password":{"enabled":true},"passkey":{"enabled":false}},"passkey_options":{"challenge_ui":"both","progressive_enrollment_enabled":true,"local_enrollment_enabled":true},"brute_force_protection":true},"strategy":"auth0","name":"Test-Auth0-Connection-Phone-1720679132","is_domain_connection":false,"enabled_clients":[],"realms":["Test-Auth0-Connection-Phone-1720679132"]}'
body: '{"id":"con_3wxxbtjncdDdzJwE","options":{"mfa":{"active":true,"return_enroll_settings":true},"passwordPolicy":"good","precedence":["username","email","phone_number"],"attributes":{"phone_number":{"identifier":{"active":true},"profile_required":true,"signup":{"status":"required","verification":{"active":false}}}},"strategy_version":2,"authentication_methods":{"password":{"enabled":true},"passkey":{"enabled":false}},"passkey_options":{"challenge_ui":"both","progressive_enrollment_enabled":true,"local_enrollment_enabled":true},"brute_force_protection":true},"strategy":"auth0","name":"Test-Auth0-Connection-Phone-1722944272","is_domain_connection":false,"enabled_clients":[],"realms":["Test-Auth0-Connection-Phone-1722944272"]}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 201 Created
code: 201
duration: 400.634334ms
duration: 271.787583ms
- id: 1
request:
proto: HTTP/1.1
Expand All @@ -55,7 +55,7 @@ interactions:
- application/json
User-Agent:
- Go-Auth0/1.8.0
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections/con_o3oE5KvCvPLkZh4d
url: https://go-auth0-dev.eu.auth0.com/api/v2/connections/con_3wxxbtjncdDdzJwE
method: DELETE
response:
proto: HTTP/2.0
Expand All @@ -65,10 +65,10 @@ interactions:
trailer: {}
content_length: 41
uncompressed: false
body: '{"deleted_at":"2024-07-11T06:25:34.174Z"}'
body: '{"deleted_at":"2024-08-06T11:37:54.617Z"}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 202 Accepted
code: 202
duration: 400.471542ms
duration: 256.782333ms
Loading

0 comments on commit d875fe0

Please sign in to comment.