-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Generate safe email
and domain_name
by default (RFC 2606)
#2733
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,29 @@ | ||
# Faker::Internet | ||
|
||
### About faker-ruby transition to be RFC 2606 compliant | ||
|
||
faker-ruby is transitioning to no longer generating real email and url addresses. | ||
|
||
The migration plan is: | ||
- First step: | ||
- change `email` and `domain_name` to be RFC 2606 compliant. Both now generate safe values by default using the Reserved Top Level DNS Names: `example` and `test`. To maintain backwards compatibility and give users the option to use non-safe domains at their own risk, custom domains are allowed. | ||
- add deprecation message for `free_email` and `safe_email` users to switch to `email` instead. | ||
- Second step (after October 2023): | ||
- remove deprecated generators and locales. | ||
|
||
To give users time, once the first step is released, users will have until October 2023 to make the necessary changes. | ||
|
||
```ruby | ||
# Keyword arguments: name, username, email, password, domain_name, user_agent, uuid etc... | ||
Faker::Internet.user #=> { username: 'alexie', email: 'alexie@example.net' } | ||
Faker::Internet.user('username', 'email', 'password') #=> { username: 'alexie', email: 'alexie@example.net', password: 'DtEf9P8wS31iMyC' } | ||
Faker::Internet.user #=> { username: 'alexie', email: 'trudie@grant.test' } | ||
Faker::Internet.user('username', 'email', 'password') #=> { username: 'alexie', email: 'gayle@kohler.test', password: 'DtEf9P8wS31iMyC' } | ||
|
||
# Keyword arguments: name, separators | ||
Faker::Internet.email #=> "eliza@mann.net" | ||
Faker::Internet.email(name: 'Nancy') #=> "nancy@terry.biz" | ||
Faker::Internet.email(name: 'Janelle Santiago', separators: '+') #=> "janelle+santiago@becker.com" | ||
Faker::Internet.email(domain: 'example') #=> "alice@example.name" | ||
# Keyword arguments: name, separators, domain | ||
Faker::Internet.email #=> "eliza@mann.test" | ||
Faker::Internet.email(name: 'Nancy') #=> "nancy@terry.test" | ||
Faker::Internet.email(name: 'Janelle Santiago', separators: ['+']) #=> "janelle+santiago@becker.example" | ||
Faker::Internet.email(domain: 'gmail.com') #=> "foo@gmail.com" | ||
Faker::Internet.email(name: 'sam smith', separators: ['-'], domain: 'test') #=> "sam-smith@test.test" | ||
|
||
# Keyword arguments: name | ||
Faker::Internet.free_email #=> "freddy@gmail.com" | ||
|
@@ -44,13 +58,18 @@ Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true) #=> "3k | |
Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true, special_characters: true) #=> "*%NkOnJsH4" | ||
|
||
# Keyword arguments: subdomain, domain | ||
Faker::Internet.domain_name #=> "effertz.info" | ||
Faker::Internet.domain_name(domain: "example") #=> "example.net" | ||
Faker::Internet.domain_name(subdomain: true, domain: "example") #=> "horse.example.org" | ||
Faker::Internet.domain_name #=> "herzog.example" | ||
Faker::Internet.domain_name(subdomain: true) #=> "tillman.kohler.test" | ||
Faker::Internet.domain_name(subdomain: true, domain: 'faker') #=> "ebert.faker.example" | ||
Faker::Internet.domain_name(domain: 'faker-ruby.org') #=> "faker-ruby.org" | ||
Faker::Internet.domain_name(subdomain: true, domain: 'faker-ruby.org') #=> "foo.faker-ruby.org" | ||
Faker::Internet.domain_name(subdomain: true, domain: 'faker.faker-ruby.org') #=> "faker.faker-ruby.org" | ||
|
||
Faker::Internet.domain_word #=> "haleyziemann" | ||
|
||
# Keyword arguments: safe ('example' and 'test' suffixes) | ||
Faker::Internet.domain_suffix #=> "info" | ||
Faker::Internet.domain_suffix(safe: true) #=> "example" | ||
Comment on lines
+70
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (minor): since we're making breaking changes here, it may be good to also rename this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you clarify more why you think this is a breaking change? If the argument is not provided, the generator still works 🤔 I like the idea of using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let me know what you think and I will merge this once I hear back from you :) Thanks for the review @Zeragamba There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking about this PR being a breaking change or not. The way this PR handles the problem is by maintaining backwards compatibility for those who want to use unsafe domains. What is going to change is the behavior: the results will be safe by default. It doesn't seem like a breaking change to me. What am I missing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with you, Stefanni. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vbrazo did you mean to approve this PR? Just checking because I see your comments but not an approval 🍡 Thank you! |
||
|
||
Faker::Internet.ip_v4_address #=> "24.29.18.175" | ||
|
||
|
@@ -71,7 +90,9 @@ Faker::Internet.mac_address #=> "e6:0d:00:11:ed:4f" | |
Faker::Internet.mac_address(prefix: '55:44:33') #=> "55:44:33:02:1d:9b" | ||
|
||
# Keyword arguments: host, path, scheme | ||
Faker::Internet.url #=> "http://thiel.com/chauncey_simonis" | ||
Faker::Internet.url #=> "http://treutel.test/demarcus" | ||
Faker::Internet.url #=> "http://ullrich.example/fritz_braun" | ||
Faker::Internet.url(host: 'faker') #=> "http://faker/nakita" | ||
Faker::Internet.url(host: 'example.com') #=> "http://example.com/clotilde.swift" | ||
Faker::Internet.url(host: 'example.com', path: '/foobar.html') #=> "http://example.com/foobar.html" | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,9 @@ en: | |
- org | ||
- io | ||
- co | ||
safe_domain_suffix: | ||
- example | ||
- test | ||
free_email: | ||
- gmail.com | ||
- yahoo.com | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding more examples and completing the Internet doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯