diff --git a/auth0_test.go b/auth0_test.go index 203f12ed..1ca7a461 100644 --- a/auth0_test.go +++ b/auth0_test.go @@ -72,6 +72,23 @@ func TestString(t *testing.T) { } } +func TestStringf(t *testing.T) { + for _, test := range []struct { + in *string + expected string + }{ + {nil, ""}, + {Stringf(""), ""}, + {Stringf("%s", "foo"), "foo"}, + {Stringf("%s %d", "bar", 1), "bar 1"}, + } { + have := StringValue(test.in) + if have != test.expected { + t.Errorf("unexpected output. have %v, expected %v", have, test.expected) + } + } +} + func TestTime(t *testing.T) { for _, test := range []struct { in *time.Time diff --git a/management/branding_test.go b/management/branding_test.go index 38a1a67b..e7820500 100644 --- a/management/branding_test.go +++ b/management/branding_test.go @@ -127,4 +127,23 @@ func TestBrandingColors(t *testing.T) { assert.Equal(t, testCase.colors, &colors) }) } + + t.Run("Should error is not expected type", func(t *testing.T) { + var actual BrandingColors + err := json.Unmarshal([]byte(`{"page_background":123}`), &actual) + assert.Contains(t, err.Error(), "unexpected type for field page_background") + }) + + t.Run("Should disallow setting PageBackground and PageBackgroundGradient", func(t *testing.T) { + _, err := json.Marshal(&BrandingColors{ + PageBackground: auth0.String("#ffffff"), + PageBackgroundGradient: &BrandingPageBackgroundGradient{ + Type: auth0.String("linear-gradient"), + Start: auth0.String("#ffffff"), + End: auth0.String("#000000"), + AngleDegree: auth0.Int(3), + }, + }) + assert.Contains(t, err.Error(), "only one of PageBackground and PageBackgroundGradient is allowed") + }) } diff --git a/management/client_test.go b/management/client_test.go index 08f2fe0f..d9cc7628 100644 --- a/management/client_test.go +++ b/management/client_test.go @@ -150,6 +150,15 @@ func TestJWTConfiguration(t *testing.T) { assert.NoError(t, err) assert.Equal(t, &actual, expected) } + + t.Run("Should error if unexpected type", func(t *testing.T) { + var actual ClientJWTConfiguration + err := json.Unmarshal([]byte(`{"lifetime_in_seconds":true}`), &actual) + assert.Contains(t, err.Error(), "unexpected type for field lifetime_in_seconds") + + err = json.Unmarshal([]byte(`{"lifetime_in_seconds":"fooo"}`), &actual) + assert.Contains(t, err.Error(), "unexpected type for field lifetime_in_seconds") + }) }) } diff --git a/management/log_test.go b/management/log_test.go index 1d42d1d5..eb782f22 100644 --- a/management/log_test.go +++ b/management/log_test.go @@ -33,6 +33,30 @@ func TestLogManager(t *testing.T) { ) assert.NoError(t, err) assert.NotEmpty(t, logs) + assert.Equal(t, "API Operation", logs[0].TypeName()) +} + +func TestLogManager_Search(t *testing.T) { + configureHTTPTestRecordings(t) + + // Limit results to 5 entries, starting from the first page. + logs, err := api.Log.Search(context.Background(), Page(1), PerPage(5)) + assert.NoError(t, err) + assert.Greater(t, len(logs), 0, "can't seem to find any logs, have you ran any tests before?") + + actualLog, err := api.Log.Read(context.Background(), logs[0].GetID()) + assert.NoError(t, err) + assert.Equal(t, logs[0], actualLog) + + // Search by type "Success API Operation" and limit results to 5 entries. + logs, err = api.Log.List( + context.Background(), + Parameter("q", fmt.Sprintf(`type:%q`, successfulAPIOperation)), + PerPage(5), + ) + assert.NoError(t, err) + assert.NotEmpty(t, logs) + assert.Equal(t, "API Operation", logs[0].TypeName()) } func TestLogManager_CheckpointPagination(t *testing.T) { diff --git a/management/management_error_test.go b/management/management_error_test.go index e80e26d9..b236fb24 100644 --- a/management/management_error_test.go +++ b/management/management_error_test.go @@ -59,4 +59,14 @@ func TestNewError(t *testing.T) { assert.Equal(t, &testCase.expectedError, actualError) }) } + + t.Run("Error should format into a string", func(t *testing.T) { + err := managementError{ + StatusCode: 403, + Err: "Forbidden", + Message: "message", + } + + assert.Equal(t, "403 Forbidden: message", err.Error()) + }) } diff --git a/management/management_test.go b/management/management_test.go index c08cffbb..111c2bfb 100644 --- a/management/management_test.go +++ b/management/management_test.go @@ -4,6 +4,7 @@ import ( "context" "encoding/base64" "encoding/json" + "io" "log" "net/http" "net/http/httptest" @@ -168,6 +169,26 @@ func TestOptionSort(t *testing.T) { assert.Equal(t, "name:-1", sort) } +func TestOptionHeader(t *testing.T) { + r, _ := http.NewRequest("GET", "/", nil) + + Header("foo", "bar").apply(r) + + v := r.Header.Get("foo") + assert.Equal(t, "bar", v) +} + +func TestOptionBody(t *testing.T) { + r, _ := http.NewRequest("GET", "/", nil) + + body := []byte("fooo") + Body(body).apply(r) + + v, err := io.ReadAll(r.Body) + assert.NoError(t, err) + assert.Equal(t, body, v) +} + func TestStringify(t *testing.T) { expected := `{ "foo": "bar" diff --git a/management/tenant_test.go b/management/tenant_test.go index 8e2d20b8..e3f9ce04 100644 --- a/management/tenant_test.go +++ b/management/tenant_test.go @@ -101,6 +101,19 @@ func TestTenantUniversalLoginColors_MarshalJSON(t *testing.T) { assert.NoError(t, err) assert.Equal(t, expected, string(payload)) } + + t.Run("Should disallow setting PageBackground and PageBackgroundGradient", func(t *testing.T) { + _, err := json.Marshal(&TenantUniversalLoginColors{ + PageBackground: auth0.String("#ffffff"), + PageBackgroundGradient: &BrandingPageBackgroundGradient{ + Type: auth0.String("linear-gradient"), + Start: auth0.String("#ffffff"), + End: auth0.String("#000000"), + AngleDegree: auth0.Int(3), + }, + }) + assert.Contains(t, err.Error(), "only one of PageBackground and PageBackgroundGradient is allowed") + }) } func TestTenantUniversalLoginColors_UnmarshalJSON(t *testing.T) { @@ -123,4 +136,10 @@ func TestTenantUniversalLoginColors_UnmarshalJSON(t *testing.T) { assert.NoError(t, err) assert.Equal(t, &actual, expected) } + + t.Run("Should error is not expected type", func(t *testing.T) { + var actual TenantUniversalLoginColors + err := json.Unmarshal([]byte(`{"page_background":123}`), &actual) + assert.Contains(t, err.Error(), "unexpected type for field page_background") + }) } diff --git a/management/user_test.go b/management/user_test.go index fcdca3a7..30486758 100644 --- a/management/user_test.go +++ b/management/user_test.go @@ -429,6 +429,21 @@ func TestUserManager_AuthenticationMethods(t *testing.T) { assert.Len(t, methods.Authenticators, 0) } +func TestUserManager_Organizations(t *testing.T) { + configureHTTPTestRecordings(t) + + user := givenAUser(t) + org := givenAnOrganization(t) + + err := api.Organization.AddMembers(context.Background(), org.GetID(), []string{user.GetID()}) + require.NoError(t, err) + + orgs, err := api.User.Organizations(context.Background(), user.GetID()) + require.NoError(t, err) + assert.Len(t, orgs.Organizations, 1) + assert.Equal(t, org.GetID(), orgs.Organizations[0].GetID()) +} + func givenAUser(t *testing.T) *User { t.Helper() diff --git a/test/data/recordings/TestLogManager_Search.yaml b/test/data/recordings/TestLogManager_Search.yaml new file mode 100644 index 00000000..38526b6a --- /dev/null +++ b/test/data/recordings/TestLogManager_Search.yaml @@ -0,0 +1,111 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 5 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + null + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/latest + url: https://go-auth0-dev.eu.auth0.com/api/v2/logs?page=1&per_page=5 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '[{"_id":"90020231110110819308230000000000000001223372060221940944","log_id":"90020231110110819308230000000000000001223372060221940944","date":"2023-11-10T11:08:19.262Z","type":"sapi","description":"Delete organization","connection":null,"connection_id":null,"organization_id":null,"organization_name":null,"client_id":"11tYwy5rk6iavoGW9BgtXYuzcVrCasjE","client_name":"","ip":"[REDACTED]","hostname":null,"details":{"request":{"auth":{"credentials":{},"strategy":"jwt","user":{}},"body":{},"channel":"api","ip":"2a02:8084:6024:b100:6c86:1b9c:de81:f3aa","method":"delete","path":"/api/v2/organizations/org_VvIJTfJhf3NwyCie","query":{},"userAgent":"Go-Auth0/latest"},"response":{"body":{},"statusCode":204}},"user_id":null,"user_name":null,"user_agent":"Other 0.0.0 / Other 0.0.0","audience":null,"strategy":null,"strategy_type":null,"isMobile":false,"location_info":null},{"_id":"90020231110110818979303000000000000001223372060221940339","log_id":"90020231110110818979303000000000000001223372060221940339","date":"2023-11-10T11:08:18.965Z","type":"sapi","description":"Add members to an organization","connection":null,"connection_id":null,"organization_id":null,"organization_name":null,"client_id":"11tYwy5rk6iavoGW9BgtXYuzcVrCasjE","client_name":"","ip":"[REDACTED]","hostname":null,"details":{"request":{"auth":{"credentials":{},"strategy":"jwt","user":{}},"body":{"members":["auth0|654e0f2209d0e266cf0aa508"]},"channel":"api","ip":"2a02:8084:6024:b100:6c86:1b9c:de81:f3aa","method":"post","path":"/api/v2/organizations/org_VvIJTfJhf3NwyCie/members","query":{},"userAgent":"Go-Auth0/latest"},"response":{"body":{},"statusCode":204}},"user_id":null,"user_name":null,"user_agent":"Other 0.0.0 / Other 0.0.0","audience":null,"strategy":null,"strategy_type":null,"isMobile":false,"location_info":null},{"_id":"90020231110110818877262000000000000001223372060221940137","log_id":"90020231110110818877262000000000000001223372060221940137","date":"2023-11-10T11:08:18.825Z","type":"sapi","description":"Create an Organization","connection":null,"connection_id":null,"organization_id":null,"organization_name":null,"client_id":"11tYwy5rk6iavoGW9BgtXYuzcVrCasjE","client_name":"","ip":"[REDACTED]","hostname":null,"details":{"request":{"auth":{"credentials":{},"strategy":"jwt","user":{}},"body":{"name":"test-organization368"},"channel":"api","ip":"2a02:8084:6024:b100:6c86:1b9c:de81:f3aa","method":"post","path":"/api/v2/organizations","query":{},"userAgent":"Go-Auth0/latest"},"response":{"body":{"id":"org_VvIJTfJhf3NwyCie","name":"test-organization368"},"statusCode":201}},"user_id":null,"user_name":null,"user_agent":"Other 0.0.0 / Other 0.0.0","audience":null,"strategy":null,"strategy_type":null,"isMobile":false,"location_info":null},{"_id":"90020231110110818731591000000000000001223372060221939866","log_id":"90020231110110818731591000000000000001223372060221939866","date":"2023-11-10T11:08:18.669Z","type":"fn","description":"To: chuck253@example.com","connection":"Username-Password-Authentication","connection_id":"","organization_id":null,"organization_name":null,"client_id":"11tYwy5rk6iavoGW9BgtXYuzcVrCasjE","client_name":null,"ip":"[REDACTED]","hostname":null,"details":{"email_type":"welcome_email","error":"the domain is blacklisted","to":"chuck253@example.com"},"user_id":"auth0|654e0f2209d0e266cf0aa508","user_name":"chuck253@example.com","user_agent":"Other 0.0.0 / Other 0.0.0","audience":null,"strategy":null,"strategy_type":null,"isMobile":false,"location_info":null},{"_id":"90020231110110818714046000000000000001223372060221939810","log_id":"90020231110110818714046000000000000001223372060221939810","date":"2023-11-10T11:08:18.652Z","type":"ss","description":"","connection":"Username-Password-Authentication","connection_id":"con_AFENSpbGUJYLjZz6","organization_id":null,"organization_name":null,"client_id":"11tYwy5rk6iavoGW9BgtXYuzcVrCasjE","client_name":"Auth0 CLI","ip":"[REDACTED]","hostname":null,"details":{"authentication_methods":["pwd"],"body":{"app_metadata":{"facts":["count_to_infinity_twice","kill_two_stones_with_one_bird","can_hear_sign_language"]},"blocked":false,"client_id":"11tYwy5rk6iavoGW9BgtXYuzcVrCasjE","connection":"Username-Password-Authentication","email":"chuck253@example.com","email_verified":true,"family_name":"Sanchez","given_name":"Chuck","is_signup":false,"nickname":"Chucky","password":"*****","picture":"https://example-picture-url.jpg","tenant":"go-auth0-dev.eu.auth0.com","user_metadata":{"favourite_attack":"roundhouse_kick"},"username":"test-user892"}},"user_id":"auth0|654e0f2209d0e266cf0aa508","user_name":"test-user892","user_agent":"Other 0.0.0 / Other 0.0.0","audience":null,"strategy":"auth0","strategy_type":"database","isMobile":false,"location_info":null}]' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 424.815209ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 5 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + null + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/latest + url: https://go-auth0-dev.eu.auth0.com/api/v2/logs/90020231110110819308230000000000000001223372060221940944 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"_id":"90020231110110819308230000000000000001223372060221940944","log_id":"90020231110110819308230000000000000001223372060221940944","date":"2023-11-10T11:08:19.262Z","type":"sapi","description":"Delete organization","connection":null,"connection_id":null,"organization_id":null,"organization_name":null,"client_id":"11tYwy5rk6iavoGW9BgtXYuzcVrCasjE","client_name":"","ip":"[REDACTED]","hostname":null,"details":{"request":{"auth":{"credentials":{},"strategy":"jwt","user":{}},"body":{},"channel":"api","ip":"2a02:8084:6024:b100:6c86:1b9c:de81:f3aa","method":"delete","path":"/api/v2/organizations/org_VvIJTfJhf3NwyCie","query":{},"userAgent":"Go-Auth0/latest"},"response":{"body":{},"statusCode":204}},"user_id":null,"user_name":null,"user_agent":"Other 0.0.0 / Other 0.0.0","audience":null,"strategy":null,"strategy_type":null,"isMobile":false,"location_info":null}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 133.681834ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 5 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + null + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/latest + url: https://go-auth0-dev.eu.auth0.com/api/v2/logs?per_page=5&q=type%3A%22sapi%22 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '[{"_id":"90020231110110819436518000000000000001223372060221941173","log_id":"90020231110110819436518000000000000001223372060221941173","date":"2023-11-10T11:08:19.425Z","type":"sapi","description":"Delete a User","connection":null,"connection_id":null,"organization_id":null,"organization_name":null,"client_id":"11tYwy5rk6iavoGW9BgtXYuzcVrCasjE","client_name":"","ip":"[REDACTED]","hostname":null,"details":{"request":{"auth":{"credentials":{"scopes":["read:client_grants","create:client_grants","delete:client_grants","update:client_grants","read:users","update:users","delete:users","create:users","read:users_app_metadata","update:users_app_metadata","delete:users_app_metadata","create:users_app_metadata","read:user_custom_blocks","create:user_custom_blocks","delete:user_custom_blocks","create:user_tickets","read:clients","update:clients","delete:clients","create:clients","read:client_keys","update:client_keys","delete:client_keys","create:client_keys","read:connections","update:connections","delete:connections","create:connections","read:resource_servers","update:resource_servers","delete:resource_servers","create:resource_servers","read:device_credentials","update:device_credentials","delete:device_credentials","create:device_credentials","read:rules","update:rules","delete:rules","create:rules","read:rules_configs","update:rules_configs","delete:rules_configs","read:hooks","update:hooks","delete:hooks","create:hooks","read:actions","update:actions","delete:actions","create:actions","read:email_provider","update:email_provider","delete:email_provider","create:email_provider","blacklist:tokens","read:stats","read:insights","read:tenant_settings","update:tenant_settings","read:logs","read:logs_users","read:shields","create:shields","update:shields","delete:shields","read:anomaly_blocks","delete:anomaly_blocks","update:triggers","read:triggers","read:grants","delete:grants","read:guardian_factors","update:guardian_factors","read:guardian_enrollments","delete:guardian_enrollments","create:guardian_enrollment_tickets","read:user_idp_tokens","create:passwords_checking_job","delete:passwords_checking_job","read:custom_domains","delete:custom_domains","create:custom_domains","update:custom_domains","read:email_templates","create:email_templates","update:email_templates","read:mfa_policies","update:mfa_policies","read:roles","create:roles","delete:roles","update:roles","read:prompts","update:prompts","read:branding","update:branding","delete:branding","read:log_streams","create:log_streams","delete:log_streams","update:log_streams","create:signing_keys","read:signing_keys","update:signing_keys","read:limits","update:limits","create:role_members","read:role_members","delete:role_members","read:entitlements","read:attack_protection","update:attack_protection","read:organizations","update:organizations","create:organizations","delete:organizations","create:organization_members","read:organization_members","delete:organization_members","create:organization_connections","read:organization_connections","update:organization_connections","delete:organization_connections","create:organization_member_roles","read:organization_member_roles","delete:organization_member_roles","create:organization_invitations","read:organization_invitations","delete:organization_invitations","read:organizations_summary","create:actions_log_sessions","create:authentication_methods","read:authentication_methods","update:authentication_methods","delete:authentication_methods","read:client_credentials","create:client_credentials","update:client_credentials","delete:client_credentials"]},"strategy":"jwt","user":{}},"body":null,"channel":"api","ip":"2a02:8084:6024:b100:6c86:1b9c:de81:f3aa","method":"delete","path":"/api/v2/users/auth0%7C654e0f2209d0e266cf0aa508","query":{},"userAgent":"Go-Auth0/latest"},"response":{"body":{},"statusCode":204}},"user_id":null,"user_name":null,"user_agent":"Other 0.0.0 / Other 0.0.0","audience":null,"strategy":null,"strategy_type":null,"isMobile":false,"location_info":null},{"_id":"90020231110110819308230000000000000001223372060221940944","log_id":"90020231110110819308230000000000000001223372060221940944","date":"2023-11-10T11:08:19.262Z","type":"sapi","description":"Delete organization","connection":null,"connection_id":null,"organization_id":null,"organization_name":null,"client_id":"11tYwy5rk6iavoGW9BgtXYuzcVrCasjE","client_name":"","ip":"[REDACTED]","hostname":null,"details":{"request":{"auth":{"credentials":{},"strategy":"jwt","user":{}},"body":{},"channel":"api","ip":"2a02:8084:6024:b100:6c86:1b9c:de81:f3aa","method":"delete","path":"/api/v2/organizations/org_VvIJTfJhf3NwyCie","query":{},"userAgent":"Go-Auth0/latest"},"response":{"body":{},"statusCode":204}},"user_id":null,"user_name":null,"user_agent":"Other 0.0.0 / Other 0.0.0","audience":null,"strategy":null,"strategy_type":null,"isMobile":false,"location_info":null},{"_id":"90020231110110818979303000000000000001223372060221940339","log_id":"90020231110110818979303000000000000001223372060221940339","date":"2023-11-10T11:08:18.965Z","type":"sapi","description":"Add members to an organization","connection":null,"connection_id":null,"organization_id":null,"organization_name":null,"client_id":"11tYwy5rk6iavoGW9BgtXYuzcVrCasjE","client_name":"","ip":"[REDACTED]","hostname":null,"details":{"request":{"auth":{"credentials":{},"strategy":"jwt","user":{}},"body":{"members":["auth0|654e0f2209d0e266cf0aa508"]},"channel":"api","ip":"2a02:8084:6024:b100:6c86:1b9c:de81:f3aa","method":"post","path":"/api/v2/organizations/org_VvIJTfJhf3NwyCie/members","query":{},"userAgent":"Go-Auth0/latest"},"response":{"body":{},"statusCode":204}},"user_id":null,"user_name":null,"user_agent":"Other 0.0.0 / Other 0.0.0","audience":null,"strategy":null,"strategy_type":null,"isMobile":false,"location_info":null},{"_id":"90020231110110818877262000000000000001223372060221940137","log_id":"90020231110110818877262000000000000001223372060221940137","date":"2023-11-10T11:08:18.825Z","type":"sapi","description":"Create an Organization","connection":null,"connection_id":null,"organization_id":null,"organization_name":null,"client_id":"11tYwy5rk6iavoGW9BgtXYuzcVrCasjE","client_name":"","ip":"[REDACTED]","hostname":null,"details":{"request":{"auth":{"credentials":{},"strategy":"jwt","user":{}},"body":{"name":"test-organization368"},"channel":"api","ip":"2a02:8084:6024:b100:6c86:1b9c:de81:f3aa","method":"post","path":"/api/v2/organizations","query":{},"userAgent":"Go-Auth0/latest"},"response":{"body":{"id":"org_VvIJTfJhf3NwyCie","name":"test-organization368"},"statusCode":201}},"user_id":null,"user_name":null,"user_agent":"Other 0.0.0 / Other 0.0.0","audience":null,"strategy":null,"strategy_type":null,"isMobile":false,"location_info":null},{"_id":"90020231110110818697487000000000000001223372060221939794","log_id":"90020231110110818697487000000000000001223372060221939794","date":"2023-11-10T11:08:18.675Z","type":"sapi","description":"Create a User","connection":null,"connection_id":null,"organization_id":null,"organization_name":null,"client_id":"11tYwy5rk6iavoGW9BgtXYuzcVrCasjE","client_name":"","ip":"[REDACTED]","hostname":null,"details":{"request":{"auth":{"credentials":{"scopes":["read:client_grants","create:client_grants","delete:client_grants","update:client_grants","read:users","update:users","delete:users","create:users","read:users_app_metadata","update:users_app_metadata","delete:users_app_metadata","create:users_app_metadata","read:user_custom_blocks","create:user_custom_blocks","delete:user_custom_blocks","create:user_tickets","read:clients","update:clients","delete:clients","create:clients","read:client_keys","update:client_keys","delete:client_keys","create:client_keys","read:connections","update:connections","delete:connections","create:connections","read:resource_servers","update:resource_servers","delete:resource_servers","create:resource_servers","read:device_credentials","update:device_credentials","delete:device_credentials","create:device_credentials","read:rules","update:rules","delete:rules","create:rules","read:rules_configs","update:rules_configs","delete:rules_configs","read:hooks","update:hooks","delete:hooks","create:hooks","read:actions","update:actions","delete:actions","create:actions","read:email_provider","update:email_provider","delete:email_provider","create:email_provider","blacklist:tokens","read:stats","read:insights","read:tenant_settings","update:tenant_settings","read:logs","read:logs_users","read:shields","create:shields","update:shields","delete:shields","read:anomaly_blocks","delete:anomaly_blocks","update:triggers","read:triggers","read:grants","delete:grants","read:guardian_factors","update:guardian_factors","read:guardian_enrollments","delete:guardian_enrollments","create:guardian_enrollment_tickets","read:user_idp_tokens","create:passwords_checking_job","delete:passwords_checking_job","read:custom_domains","delete:custom_domains","create:custom_domains","update:custom_domains","read:email_templates","create:email_templates","update:email_templates","read:mfa_policies","update:mfa_policies","read:roles","create:roles","delete:roles","update:roles","read:prompts","update:prompts","read:branding","update:branding","delete:branding","read:log_streams","create:log_streams","delete:log_streams","update:log_streams","create:signing_keys","read:signing_keys","update:signing_keys","read:limits","update:limits","create:role_members","read:role_members","delete:role_members","read:entitlements","read:attack_protection","update:attack_protection","read:organizations","update:organizations","create:organizations","delete:organizations","create:organization_members","read:organization_members","delete:organization_members","create:organization_connections","read:organization_connections","update:organization_connections","delete:organization_connections","create:organization_member_roles","read:organization_member_roles","delete:organization_member_roles","create:organization_invitations","read:organization_invitations","delete:organization_invitations","read:organizations_summary","create:actions_log_sessions","create:authentication_methods","read:authentication_methods","update:authentication_methods","delete:authentication_methods","read:client_credentials","create:client_credentials","update:client_credentials","delete:client_credentials"]},"strategy":"jwt","user":{}},"body":{"app_metadata":{"facts":["count_to_infinity_twice","kill_two_stones_with_one_bird","can_hear_sign_language"]},"blocked":false,"connection":"Username-Password-Authentication","email":"chuck253@example.com","email_verified":true,"family_name":"Sanchez","given_name":"Chuck","nickname":"Chucky","password":"*****","picture":"https://example-picture-url.jpg","user_metadata":{"favourite_attack":"roundhouse_kick"},"username":"test-user892","verify_email":false},"channel":"api","ip":"2a02:8084:6024:b100:6c86:1b9c:de81:f3aa","method":"post","path":"/api/v2/users","query":{},"userAgent":"Go-Auth0/latest"},"response":{"body":{"app_metadata":{"facts":["count_to_infinity_twice","kill_two_stones_with_one_bird","can_hear_sign_language"]},"blocked":false,"created_at":"2023-11-10T11:08:18.661Z","email":"chuck253@example.com","email_verified":true,"family_name":"Sanchez","given_name":"Chuck","identities":[{"connection":"Username-Password-Authentication","isSocial":false,"provider":"auth0","user_id":"654e0f2209d0e266cf0aa508"}],"name":"chuck253@example.com","nickname":"Chucky","picture":"https://example-picture-url.jpg","updated_at":"2023-11-10T11:08:18.661Z","user_id":"auth0|654e0f2209d0e266cf0aa508","user_metadata":{"favourite_attack":"roundhouse_kick"},"username":"test-user892"},"statusCode":201}},"user_id":null,"user_name":null,"user_agent":"Other 0.0.0 / Other 0.0.0","audience":null,"strategy":null,"strategy_type":null,"isMobile":false,"location_info":null}]' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 134.68425ms diff --git a/test/data/recordings/TestUserManager_Organizations.yaml b/test/data/recordings/TestUserManager_Organizations.yaml new file mode 100644 index 00000000..110835b7 --- /dev/null +++ b/test/data/recordings/TestUserManager_Organizations.yaml @@ -0,0 +1,217 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 480 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"connection":"Username-Password-Authentication","email":"chuck253@example.com","given_name":"Chuck","family_name":"Sanchez","username":"test-user892","nickname":"Chucky","password":"Passwords hide their chuck","user_metadata":{"favourite_attack":"roundhouse_kick"},"verify_email":false,"app_metadata":{"facts":["count_to_infinity_twice","kill_two_stones_with_one_bird","can_hear_sign_language"]},"picture":"https://example-picture-url.jpg","blocked":false,"email_verified":true} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/latest + url: https://go-auth0-dev.eu.auth0.com/api/v2/users + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 661 + uncompressed: false + body: '{"blocked":false,"created_at":"2023-11-10T11:08:18.661Z","email":"chuck253@example.com","email_verified":true,"family_name":"Sanchez","given_name":"Chuck","identities":[{"connection":"Username-Password-Authentication","user_id":"654e0f2209d0e266cf0aa508","provider":"auth0","isSocial":false}],"name":"chuck253@example.com","nickname":"Chucky","picture":"https://example-picture-url.jpg","updated_at":"2023-11-10T11:08:18.661Z","user_id":"auth0|654e0f2209d0e266cf0aa508","user_metadata":{"favourite_attack":"roundhouse_kick"},"username":"test-user892","app_metadata":{"facts":["count_to_infinity_twice","kill_two_stones_with_one_bird","can_hear_sign_language"]}}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 201 Created + code: 201 + duration: 500.39925ms + - id: 1 + 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-organization368","display_name":"Test Organization","branding":{"logo_url":"https://example.com/logo.gif"}} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/latest + 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: '{"name":"test-organization368","display_name":"Test Organization","branding":{"logo_url":"https://example.com/logo.gif"},"id":"org_VvIJTfJhf3NwyCie"}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 201 Created + code: 201 + duration: 156.833458ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 47 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + {"members":["auth0|654e0f2209d0e266cf0aa508"]} + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/latest + url: https://go-auth0-dev.eu.auth0.com/api/v2/organizations/org_VvIJTfJhf3NwyCie/members + method: POST + 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: 136.61225ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 5 + transfer_encoding: [] + trailer: {} + host: go-auth0-dev.eu.auth0.com + remote_addr: "" + request_uri: "" + body: | + null + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - Go-Auth0/latest + url: https://go-auth0-dev.eu.auth0.com/api/v2/users/auth0%7C654e0f2209d0e266cf0aa508/organizations?include_totals=true&per_page=50 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: true + body: '{"organizations":[{"branding":{"logo_url":"https://example.com/logo.gif"},"id":"org_VvIJTfJhf3NwyCie","display_name":"Test Organization","name":"test-organization368"}],"start":0,"limit":50,"total":1}' + headers: + Content-Type: + - application/json; charset=utf-8 + status: 200 OK + code: 200 + duration: 150.128208ms + - 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/latest + url: https://go-auth0-dev.eu.auth0.com/api/v2/organizations/org_VvIJTfJhf3NwyCie + 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: 141.614541ms + - id: 5 + 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/latest + url: https://go-auth0-dev.eu.auth0.com/api/v2/users/auth0%7C654e0f2209d0e266cf0aa508 + 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: 162.259ms