Skip to content

Commit dea7efe

Browse files
authoredJul 12, 2021
Merge pull request #2 from vbelchio/vbelchio
Add /v2/accounts/ and /auth endpoints
2 parents cad1587 + b8a0fe3 commit dea7efe

9 files changed

+1266
-463
lines changed
 

‎README.md

+11-4
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,27 @@ Visit any of the supported endpoints below, now available on `http://localhost:8
1111

1212
### Supported Endpoints
1313

14-
- Users for an account: `http://localhost:8090/insights-services/v1/accounts/:id/users` - note that the account ID does not matter in this case.
14+
- Status:
15+
- `http://localhost:8090/insights-services/` - nothing is gonna be resulted
16+
- Users for an account (V1 endpoint):
17+
- `http://localhost:8090/insights-services/v1/accounts/:id/users` - note that the account ID does not matter in this case.
18+
- Users for an account (V2 endpoint):
19+
- `http://localhost:8090/insights-services/v2/accounts/:id/users` - note that the account ID does not matter in this case.
20+
- Details for a user:
21+
- `http://localhost:8090/insights-services/v1/auth`
1522

1623
### Future Endpoints
1724

18-
- Details for a user: `http://localhost:8090/insights-services/v1/auth`
25+
- https://backoffice-proxy-insights-services.ext.us-east.aws.preprod.paas.redhat.com/docs/#/
1926

2027
### Generating Fake Data
2128

22-
User data exists by default in `data/users.json`, but to populate new/different,
29+
User data exists by default in `data/{files}.json`, but to populate new/different,
2330
use the following:
2431

2532
```
2633
$ gem install faker
27-
$ ./bin/populate_users.rb
34+
$ ./bin/populate_{name}.rb
2835
```
2936

3037
### Integrating with RBAC

‎bin/populate_auth.rb

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'faker'
4+
5+
first_name = Faker::Name.first_name
6+
last_name = Faker::Name.last_name
7+
full_name = "#{first_name} #{last_name}"
8+
email = Faker::Internet.email(name: full_name, separators: '.', domain: 'example')
9+
address_string = "\"#{full_name}\" #{email}"
10+
11+
users = {
12+
user: {
13+
id: Faker::Number.number(digits: 8),
14+
username: full_name.split(' ').join('.'),
15+
email: email,
16+
first_name: first_name,
17+
last_name: last_name,
18+
account_number: Faker::Number.number(digits: 8),
19+
address_string: address_string,
20+
is_active: true,
21+
is_org_admin: Faker::Boolean.boolean(true_ratio: 0.2),
22+
is_internal: Faker::Boolean.boolean(true_ratio: 0.5),
23+
locale: 'en_US',
24+
org_id: Faker::Number.number(digits: 8),
25+
display_name: full_name,
26+
type: 'basic'
27+
},
28+
mechanism: 'basic'
29+
}
30+
31+
File.open('./data/auth.json', 'w') do |f|
32+
f.write(JSON.pretty_generate(users))
33+
end

‎bin/populate_users.rb ‎bin/populate_users_v1.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
last_name: last_name,
1515
email: Faker::Internet.email(name: full_name, separators: '.', domain: 'example'),
1616
is_active: true,
17-
locale: 'en_US'
17+
locale: 'en_US',
18+
is_org_admin: Faker::Boolean.boolean(true_ratio: 0.2),
19+
is_internal: Faker::Boolean.boolean(true_ratio: 0.5)
1820
}
1921
end
2022

21-
File.open('./data/users.json', 'w') do |f|
23+
File.open('./data/usersv1.json', 'w') do |f|
2224
f.write(JSON.pretty_generate(users))
2325
end

‎bin/populate_users_v2.rb

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'faker'
4+
5+
users = 50.times.map do
6+
first_name = Faker::Name.first_name
7+
last_name = Faker::Name.last_name
8+
full_name = "#{first_name} #{last_name}"
9+
10+
{
11+
id: Faker::Number.number(digits: 8),
12+
username: full_name.split(' ').join('.'),
13+
first_name: first_name,
14+
last_name: last_name,
15+
email: Faker::Internet.email(name: full_name, separators: '.', domain: 'example'),
16+
is_active: true,
17+
locale: 'en_US',
18+
is_org_admin: Faker::Boolean.boolean(true_ratio: 0.2),
19+
is_internal: Faker::Boolean.boolean(true_ratio: 0.5)
20+
}
21+
end
22+
23+
users = {
24+
users: users,
25+
userCount: 50
26+
}
27+
28+
File.open('./data/usersv2.json', 'w') do |f|
29+
f.write(JSON.pretty_generate(users))
30+
end

‎data/auth.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"user": {
3+
"id": 51834776,
4+
"username": "insights-qa",
5+
"email": "insights-qa@redhat.com",
6+
"first_name": "Insights",
7+
"last_name": "QA",
8+
"account_number": 6089719,
9+
"address_string": "\"Insights QA\" insights-qa@redhat.com",
10+
"is_active": true,
11+
"is_org_admin": true,
12+
"is_internal": true,
13+
"locale": "en_US",
14+
"org_id": 11789772,
15+
"display_name": "Insights QA",
16+
"type": "basic"
17+
},
18+
"mechanism": "basic"
19+
}

0 commit comments

Comments
 (0)
Please sign in to comment.