Skip to content

Commit

Permalink
Added dedicated test case to client with defaultOrg
Browse files Browse the repository at this point in the history
  • Loading branch information
duedares-rvj committed Aug 26, 2024
1 parent dd19483 commit 8d14d75
Show file tree
Hide file tree
Showing 2 changed files with 209 additions and 0 deletions.
29 changes: 29 additions & 0 deletions management/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,35 @@ func TestClient_Create(t *testing.T) {
})
}

func TestClient_CreateWithDefaultOrg(t *testing.T) {
configureHTTPTestRecordings(t)

org := givenAnOrganization(t)

expectedClient := &Client{
Name: auth0.Stringf("Test Client (%s)", time.Now().Format(time.StampMilli)),
Description: auth0.String("This is just a test client."),
OrganizationUsage: auth0.String("allow"),
DefaultOrganization: &ClientDefaultOrganization{
Flows: &[]string{"client_credentials"},
OrganizationID: auth0.String(org.GetID()),
},
}

err := api.Client.Create(context.Background(), expectedClient)
assert.NoError(t, err)
assert.NotEmpty(t, expectedClient.GetClientID())

retrievedClient, err := api.Client.Read(context.Background(), expectedClient.GetClientID())
assert.NoError(t, err)
assert.NotEmpty(t, retrievedClient.DefaultOrganization.GetOrganizationID())
assert.NotEmpty(t, retrievedClient.DefaultOrganization.GetFlows())

t.Cleanup(func() {
cleanupClient(t, expectedClient.GetClientID())
})
}

func TestClientSignedRequestObject(t *testing.T) {
configureHTTPTestRecordings(t)

Expand Down
180 changes: 180 additions & 0 deletions test/data/recordings/TestClient_CreateWithDefaultOrg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
---
version: 2
interactions:
- id: 0
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 122
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: |
{"name":"test-organization426","display_name":"Test Organization","branding":{"logo_url":"https://example.com/logo.gif"}}
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0/1.9.0
url: https://go-auth0-dev.eu.auth0.com/api/v2/organizations
method: POST
response:
proto: HTTP/2.0
proto_major: 2
proto_minor: 0
transfer_encoding: []
trailer: {}
content_length: 149
uncompressed: false
body: '{"branding":{"logo_url":"https://example.com/logo.gif"},"id":"org_X6hYdaBImySituVC","display_name":"Test Organization","name":"test-organization426"}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 201 Created
code: 201
duration: 792.804584ms
- id: 1
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 215
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: |
{"name":"Test Client (Aug 26 20:33:45.418)","description":"This is just a test client.","organization_usage":"allow","default_organization":{"flows":["client_credentials"],"organization_id":"org_X6hYdaBImySituVC"}}
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0/1.9.0
url: https://go-auth0-dev.eu.auth0.com/api/v2/clients
method: POST
response:
proto: HTTP/2.0
proto_major: 2
proto_minor: 0
transfer_encoding: []
trailer: {}
content_length: -1
uncompressed: false
body: '{"name":"Test Client (Aug 26 20:33:45.418)","description":"This is just a test client.","client_id":"qD968mO3mpzPCKmKg5gpWG2NulLWpqhw","client_secret":"[REDACTED]","is_first_party":true,"is_token_endpoint_ip_header_trusted":false,"oidc_conformant":false,"jwt_configuration":{"secret_encoded":false,"lifetime_in_seconds":36000},"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","default_organization":{"flows":["client_credentials"],"organization_id":"org_X6hYdaBImySituVC"}}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 201 Created
code: 201
duration: 493.427584ms
- id: 2
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 0
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: ""
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0/1.9.0
url: https://go-auth0-dev.eu.auth0.com/api/v2/clients/qD968mO3mpzPCKmKg5gpWG2NulLWpqhw
method: GET
response:
proto: HTTP/2.0
proto_major: 2
proto_minor: 0
transfer_encoding: []
trailer: {}
content_length: -1
uncompressed: true
body: '{"name":"Test Client (Aug 26 20:33:45.418)","description":"This is just a test client.","client_id":"qD968mO3mpzPCKmKg5gpWG2NulLWpqhw","client_secret":"[REDACTED]","is_first_party":true,"is_token_endpoint_ip_header_trusted":false,"oidc_conformant":false,"jwt_configuration":{"secret_encoded":false,"lifetime_in_seconds":36000},"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","default_organization":{"flows":["client_credentials"],"organization_id":"org_X6hYdaBImySituVC"}}'
headers:
Content-Type:
- application/json; charset=utf-8
status: 200 OK
code: 200
duration: 347.987ms
- id: 3
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 0
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: ""
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0/1.9.0
url: https://go-auth0-dev.eu.auth0.com/api/v2/clients/qD968mO3mpzPCKmKg5gpWG2NulLWpqhw
method: DELETE
response:
proto: HTTP/2.0
proto_major: 2
proto_minor: 0
transfer_encoding: []
trailer: {}
content_length: 0
uncompressed: false
body: ""
headers:
Content-Type:
- application/json; charset=utf-8
status: 204 No Content
code: 204
duration: 390.335166ms
- id: 4
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 0
transfer_encoding: []
trailer: {}
host: go-auth0-dev.eu.auth0.com
remote_addr: ""
request_uri: ""
body: ""
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0/1.9.0
url: https://go-auth0-dev.eu.auth0.com/api/v2/organizations/org_X6hYdaBImySituVC
method: DELETE
response:
proto: HTTP/2.0
proto_major: 2
proto_minor: 0
transfer_encoding: []
trailer: {}
content_length: 0
uncompressed: false
body: ""
headers:
Content-Type:
- application/json; charset=utf-8
status: 204 No Content
code: 204
duration: 347.282792ms

0 comments on commit 8d14d75

Please sign in to comment.