Basic REPP doc

This commit is contained in:
Martin Lensment 2015-03-18 11:06:52 +02:00
parent 30147db127
commit dcf64bf5df
7 changed files with 165 additions and 6 deletions

View file

@ -122,4 +122,6 @@ group :development, :test do
# for travis # for travis
gem 'rake' gem 'rake'
gem "autodoc"
end end

View file

@ -64,6 +64,10 @@ GEM
ast (2.0.0) ast (2.0.0)
astrolabe (1.3.0) astrolabe (1.3.0)
parser (>= 2.2.0.pre.3, < 3.0) parser (>= 2.2.0.pre.3, < 3.0)
autodoc (0.4.3)
actionpack
activesupport (>= 3.0.0)
rspec
axiom-types (0.1.1) axiom-types (0.1.1)
descendants_tracker (~> 0.0.4) descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0) ice_nine (~> 0.11.0)
@ -445,6 +449,7 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
activerecord-import (~> 0.6.0) activerecord-import (~> 0.6.0)
autodoc
better_errors (~> 2.0.0) better_errors (~> 2.0.0)
binding_of_caller (~> 0.7.2) binding_of_caller (~> 0.7.2)
bootstrap-sass (~> 3.3.1.0) bootstrap-sass (~> 3.3.1.0)

76
doc/repp/v1/contact.md Normal file
View file

@ -0,0 +1,76 @@
## GET /repp/v1/contacts
Returns contacts of the current registrar.
### Example
#### Request
```
GET /repp/v1/contacts?page=1 HTTP/1.1
Accept: application/json
Authorization: Basic Z2l0bGFiOmdoeXQ5ZTRmdQ==
Content-Length: 0
Content-Type: application/json
Host: www.example.com
```
#### Response
```
HTTP/1.1 200
Cache-Control: max-age=0, private, must-revalidate
Content-Length: 867
Content-Type: application/json
ETag: W/"0fe2b795798cd8d371fc1ba5e0a7d8c4"
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Request-Id: 4629e62c-8636-4624-b5ab-3ffa91ec799b
X-Runtime: 0.147222
X-XSS-Protection: 1; mode=block
{
"contacts": [
{
"registrar_id": 1,
"id": 1,
"code": "sh16377490",
"reg_no": null,
"phone": "+372.12345678",
"email": "juliet@oreilly.org",
"fax": null,
"created_at": "2015-03-18T09:03:02.001Z",
"updated_at": "2015-03-18T09:03:02.001Z",
"ident": "37605030299",
"ident_type": "priv",
"created_by_id": null,
"updated_by_id": null,
"auth_info": "password",
"name": "Adrianna Ferry0",
"org_name": null,
"creator_str": null,
"updator_str": null,
"ident_country_code": "EE"
},
{
"registrar_id": 1,
"id": 2,
"code": "sh63156547",
"reg_no": null,
"phone": "+372.12345678",
"email": "juliet@oreilly.org",
"fax": null,
"created_at": "2015-03-18T09:03:02.052Z",
"updated_at": "2015-03-18T09:03:02.052Z",
"ident": "37605030299",
"ident_type": "priv",
"created_by_id": null,
"updated_by_id": null,
"auth_info": "password",
"name": "Miss Stuart Ritchie1",
"org_name": null,
"creator_str": null,
"updator_str": null,
"ident_country_code": "EE"
}
],
"total_pages": 1
}
```

74
doc/repp/v1/domain.md Normal file
View file

@ -0,0 +1,74 @@
## GET /repp/v1/domains
Returns domains of the current registrar.
### Example
#### Request
```
GET /repp/v1/domains?page=1 HTTP/1.1
Accept: application/json
Authorization: Basic Z2l0bGFiOmdoeXQ5ZTRmdQ==
Content-Length: 0
Content-Type: application/json
Host: www.example.com
```
#### Response
```
HTTP/1.1 200
Cache-Control: max-age=0, private, must-revalidate
Content-Length: 1859
Content-Type: application/json
ETag: W/"a63861e741f479e8099f9fdb913a8e66"
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Request-Id: bdda3b2d-d65a-441f-8c2e-751e56de4d18
X-Runtime: 0.017877
X-XSS-Protection: 1; mode=block
{
"domains": [
{
"registrar_id": 1,
"id": 1,
"name": "domain0.ee",
"registered_at": "2015-03-18T09:03:02.686Z",
"status": null,
"valid_from": "2015-03-18T00:00:00.000Z",
"valid_to": "2016-03-18T00:00:00.000Z",
"owner_contact_id": 1,
"auth_info": "085f8c4cf5af0c14615a2da64f6a84c2",
"created_at": "2015-03-18T09:03:02.681Z",
"updated_at": "2015-03-18T09:03:02.680Z",
"name_dirty": "domain0.ee",
"name_puny": "domain0.ee",
"period": 1,
"period_unit": "y",
"creator_str": null,
"updator_str": null,
"whois_body": " This Whois Server contains information on\n Estonian Top Level Domain ee TLD\n\n domain: domain0.ee\n registrar: registrar1\n status:\n registered:\n changed: 2015-03-18 09:03:02\n expire:\n outzone:\n delete:\n\n contact\n name:\n e-mail:\n registrar:\n created:\n\n contact:\n\n nsset:\n nserver:\n\n registrar:\n org:\n url:\n phone:\n address:\n created:\n changed:\n"
},
{
"registrar_id": 1,
"id": 2,
"name": "domain1.ee",
"registered_at": "2015-03-18T09:03:02.856Z",
"status": null,
"valid_from": "2015-03-18T00:00:00.000Z",
"valid_to": "2016-03-18T00:00:00.000Z",
"owner_contact_id": 3,
"auth_info": "79fdd1a0174be7e141c2930aff278b43",
"created_at": "2015-03-18T09:03:02.854Z",
"updated_at": "2015-03-18T09:03:02.854Z",
"name_dirty": "domain1.ee",
"name_puny": "domain1.ee",
"period": 1,
"period_unit": "y",
"creator_str": null,
"updator_str": null,
"whois_body": " This Whois Server contains information on\n Estonian Top Level Domain ee TLD\n\n domain: domain1.ee\n registrar: registrar1\n status:\n registered:\n changed: 2015-03-18 09:03:02\n expire:\n outzone:\n delete:\n\n contact\n name:\n e-mail:\n registrar:\n created:\n\n contact:\n\n nsset:\n nserver:\n\n registrar:\n org:\n url:\n phone:\n address:\n created:\n changed:\n"
}
],
"total_pages": 1
}
```

View file

@ -88,4 +88,6 @@ RSpec.configure do |config|
config.expect_with :rspec do |c| config.expect_with :rspec do |c|
c.syntax = [:should, :expect] c.syntax = [:should, :expect]
end end
Autodoc.configuration.path = "doc/repp/v1"
end end

View file

@ -6,12 +6,12 @@ describe Repp::ContactV1 do
@api_user = Fabricate(:gitlab_api_user) @api_user = Fabricate(:gitlab_api_user)
end end
describe 'GET /repp/v1/contacts' do describe 'GET /repp/v1/contacts', autodoc: true do
it 'returns contacts of the current registrar' do it 'returns contacts of the current registrar' do
Fabricate.times(2, :contact, registrar: @api_user.registrar) Fabricate.times(2, :contact, registrar: @api_user.registrar)
Fabricate.times(2, :contact) Fabricate.times(2, :contact)
get_with_auth '/repp/v1/contacts', {}, @api_user get_with_auth '/repp/v1/contacts', { page: 1 }, @api_user
expect(response.status).to eq(200) expect(response.status).to eq(200)
body = JSON.parse(response.body) body = JSON.parse(response.body)
@ -23,7 +23,7 @@ describe Repp::ContactV1 do
log = ApiLog::ReppLog.first log = ApiLog::ReppLog.first
expect(log[:request_path]).to eq('/repp/v1/contacts') expect(log[:request_path]).to eq('/repp/v1/contacts')
expect(log[:request_method]).to eq('GET') expect(log[:request_method]).to eq('GET')
expect(log[:request_params]).to eq('{}') expect(log[:request_params]).to eq('{"page":"1"}')
expect(log[:response].length).to be > 20 expect(log[:response].length).to be > 20
expect(log[:response_code]).to eq('200') expect(log[:response_code]).to eq('200')
expect(log[:api_user_name]).to eq('gitlab') expect(log[:api_user_name]).to eq('gitlab')

View file

@ -7,11 +7,11 @@ describe Repp::DomainV1 do
@api_user = Fabricate(:gitlab_api_user, registrar: @registrar1) @api_user = Fabricate(:gitlab_api_user, registrar: @registrar1)
end end
describe 'GET /repp/v1/domains' do describe 'GET /repp/v1/domains', autodoc: true do
it 'returns domains of the current registrar' do it 'returns domains of the current registrar' do
Fabricate.times(2, :domain, registrar: @api_user.registrar) Fabricate.times(2, :domain, registrar: @api_user.registrar)
get_with_auth '/repp/v1/domains', {}, @api_user get_with_auth '/repp/v1/domains', { page: 1 }, @api_user
response.status.should == 200 response.status.should == 200
body = JSON.parse(response.body) body = JSON.parse(response.body)
@ -23,7 +23,7 @@ describe Repp::DomainV1 do
log = ApiLog::ReppLog.last log = ApiLog::ReppLog.last
log[:request_path].should == '/repp/v1/domains' log[:request_path].should == '/repp/v1/domains'
log[:request_method].should == 'GET' log[:request_method].should == 'GET'
log[:request_params].should == '{}' log[:request_params].should == '{"page":"1"}'
log[:response_code].should == '200' log[:response_code].should == '200'
log[:api_user_name].should == 'gitlab' log[:api_user_name].should == 'gitlab'
log[:api_user_registrar].should == 'registrar1' log[:api_user_registrar].should == 'registrar1'