Merge branch 'master' of github.com:internetee/registry

This commit is contained in:
Andres Keskküla 2015-01-08 11:37:47 +02:00
commit 8c20f2697b
9 changed files with 220 additions and 166 deletions

234
Gemfile
View file

@ -1,172 +1,104 @@
source 'https://rubygems.org'
gem 'rails', '4.1.4'
# core
gem 'rails', '4.1.4' # '4.2.0'
gem 'iso8601', '~> 0.8.2' # for dates and times
gem 'hashie_rails', '~> 0.0.1'
# Use postgresql as the database for Active Record
gem 'pg'
# model related
gem 'pg', '~> 0.18.0'
gem 'ransack', '~> 1.3.0' # '1.5.1' # for searching
gem 'paper_trail', '~> 3.0.5' # '3.0.6' # archiving
gem 'rails-settings-cached', '~> 0.4.1' # for settings
gem 'delayed_job_active_record', '~> 4.0.2' # '4.0.3' # delayed job
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# html-xml
gem 'haml-rails', '~> 0.5.3' # '0.6.0' haml for views
gem 'nokogiri', '~> 1.6.2.1' # For XML parsing
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# style
gem 'sass-rails', '~> 4.0.3' # '5.0.0' # sass style
gem 'bootstrap-sass', '~> 3.2.0.1' # '3.3.1.0' # bootstrap style
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# js
gem 'uglifier', '>= 1.3.0' # '2.6.1' # minifies js
gem 'coffee-rails', '~> 4.0.0' # '4.1.0' # coffeescript support
gem 'turbolinks', '~> 2.5.3' # faster page load
gem 'jquery-rails', '~> 3.1.1' # '4.0.3' jquery
gem 'selectize-rails', '~> 0.11.0' # '0.11.2' # include selectize.js for select
gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# view helpers
gem 'kaminari', '~> 0.16.1' # pagination
gem 'nprogress-rails', '~> 0.1.3.1' # '0.1.6.5' # visual loader
# Turbolinks makes following links in your web application faster.
# Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# rights
gem 'devise', '~> 3.3.0' # '3.4.0' # authenitcation
gem 'cancancan', '~> 1.9.2' # autharization
# Build JSON APIs with ease.
# Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# rest api
gem 'grape', '~> 0.10.1'
gem 'jbuilder', '~> 2.2.6' # json api
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# registry specfic
gem 'simpleidn', '~> 0.0.5' # For punycode
gem 'isikukood' # for EE-id validation
# Replacement for erb
gem 'haml-rails', '~> 0.5.3'
# For XML parsing
gem 'nokogiri', '~> 1.6.2.1'
# For punycode
gem 'simpleidn', '~> 0.0.5'
# for EE-id validation
gem 'isikukood'
# for using bootstrap
gem 'bootstrap-sass', '~> 3.2.0.1'
# for visual loader
gem 'nprogress-rails', '~> 0.1.3.1'
# for pagination
gem 'kaminari', '~> 0.16.1'
# for searching
gem 'ransack', '~> 1.3.0'
# for rights
gem 'cancancan', '~> 1.9.2'
# for login
gem 'devise', '~> 3.3.0'
# for archiving
gem 'paper_trail', '~> 3.0.5'
# for select
gem 'selectize-rails', '~> 0.11.0'
# for settings
gem 'rails-settings-cached', '0.4.1'
# delayed job
gem 'delayed_job_active_record', '~> 4.0.2'
# to process delayed jobs
gem 'daemons'
# cron
# deploy
gem 'whenever', '~> 0.9.4', require: false
# for dates and times
gem 'iso8601', '~> 0.8.2'
group :development, :test do
# for inserting dummy data
gem 'activerecord-import', '~> 0.6.0'
gem 'capybara', '~> 2.4.1'
# For feature testing
# gem 'capybara-webkit', '1.2.0' # Webkit driver didn't work with turbolinks
gem 'phantomjs-binaries', '~> 1.9.2.4'
gem 'poltergeist', '~> 1.5.1' # We are using PhantomJS instead
gem 'phantomjs', '~> 1.9.7.1'
# For cleaning db in feature and epp tests
gem 'database_cleaner', '~> 1.3.0'
# EPP client
gem 'epp', '~> 1.4.0'
# EPP XMLs
gem 'epp-xml', '~> 0.10.3'
# Replacement for fixtures
gem 'fabrication', '~> 2.11.3'
# Library to generate fake data
gem 'faker', '~> 1.3.0'
# For debugging
gem 'pry', '~> 0.10.1'
# gem 'pry-byebug', '~> 1.3.3'
# Testing framework
gem 'rspec-rails', '~> 3.0.2'
# Additional matchers for RSpec
gem 'shoulda-matchers', '~> 2.6.1', require: false
# For unique IDs (used by the epp gem)
gem 'uuidtools', '~> 2.1.4'
# For code review
gem 'simplecov', '~> 0.9.1', require: false
gem 'rubycritic', '~> 1.1.1'
# for finding database optimizations
gem 'bullet', '~> 4.14.0'
# for finding future vulnerable gems
gem 'bundler-audit'
# for security audit'
gem 'brakeman', '~> 2.6.2', require: false
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0'
# faster dev load time
gem 'unicorn'
# for opening browser automatically
gem 'launchy', '~> 2.4.3'
end
gem 'daemons', '~> 1.1.9' # process delayed jobs
group :development do
# Spring speeds up development by keeping your application running in the background.
# Read more: https://github.com/rails/spring
gem 'spring', '~> 1.2.0'
# dev tools
gem 'spring', '~> 1.2.0'
gem 'spring-commands-rspec', '~> 1.0.2'
# for fast deployment
gem 'mina', '~> 0.3.1'
# for finding dead routes and unused actions
gem 'traceroute', '~> 0.4.0'
# for improved errors
gem 'better_errors', '~> 2.0.0'
gem 'binding_of_caller', '~> 0.7.2'
# run tests automatically
gem 'guard', '~> 2.6.1'
# rspec support for guard
gem 'guard', '~> 2.6.1' # run tests automatically
gem 'guard-rspec', '~> 4.3.1'
gem 'rubocop', '~> 0.26.1'
gem 'guard-rubocop', '~> 1.1.0'
# to generate database diagrams
gem 'railroady'
# improved errors
gem 'better_errors', '~> 2.0.0'
gem 'binding_of_caller', '~> 0.7.2'
gem 'traceroute', '~> 0.4.0' # for finding dead routes and unused actions
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby
# deploy
gem 'mina', '~> 0.3.1' # for fast deployment
end
group :development, :test do
# test stack
gem 'rspec-rails', '~> 3.0.2'
gem 'capybara', '~> 2.4.1'
gem 'phantomjs-binaries', '~> 1.9.2.4'
gem 'poltergeist', '~> 1.5.1' # We are using PhantomJS instead
gem 'phantomjs', '~> 1.9.7.1'
gem 'fabrication', '~> 2.11.3' # Replacement for fixtures
gem 'shoulda-matchers', '~> 2.6.1', require: false # Additional matchers for RSpec
gem 'launchy', '~> 2.4.3' # for opening browser automatically
# helper gems
gem 'activerecord-import', '~> 0.6.0' # for inserting dummy data
gem 'database_cleaner', '~> 1.3.0' # For cleaning db in feature and epp tests
gem 'faker', '~> 1.3.0' # Library to generate fake data
# EPP
gem 'epp', '~> 1.4.0' # EPP client
gem 'epp-xml', '~> 0.10.3' # EPP XMLs
gem 'uuidtools', '~> 2.1.4' # For unique IDs (used by the epp gem)
# debug
gem 'pry', '~> 0.10.1'
# code review
gem 'simplecov', '~> 0.9.1', require: false
gem 'rubycritic', '~> 1.1.1'
gem 'bullet', '~> 4.14.0' # for finding database optimizations
gem 'bundler-audit', '~> 0.3.1' # for finding future vulnerable gems
gem 'brakeman', '~> 2.6.2', require: false # for security audit'
gem 'sdoc', '~> 0.4.0' # bundle exec rake doc:rails generates the API under doc/api.
gem 'railroady', '~> 1.3.0' # to generate database diagrams
# dev tools
gem 'unicorn'
end

View file

@ -125,6 +125,16 @@ GEM
ruby_parser (~> 3.1, > 3.1.0)
sexp_processor (~> 4.4)
formatador (0.2.5)
grape (0.10.1)
activesupport
builder
hashie (>= 2.1.0)
multi_json (>= 1.3.2)
multi_xml (>= 0.5.2)
rack (>= 1.3.0)
rack-accept
rack-mount
virtus (>= 1.0.0)
guard (2.6.1)
formatador (>= 0.2.4)
listen (~> 2.7)
@ -144,6 +154,10 @@ GEM
activesupport (>= 4.0.1)
haml (>= 3.1, < 5.0)
railties (>= 4.0.1)
hashie (3.3.2)
hashie_rails (0.0.1)
hashie (>= 3.0)
rails (~> 4.0)
highline (1.6.21)
hike (1.2.3)
hitimes (1.2.2)
@ -152,7 +166,7 @@ GEM
ice_nine (0.11.0)
isikukood (0.1.2)
iso8601 (0.8.2)
jbuilder (2.2.2)
jbuilder (2.2.6)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jquery-rails (3.1.2)
@ -183,6 +197,7 @@ GEM
mini_portile (0.6.0)
minitest (5.5.0)
multi_json (1.10.1)
multi_xml (0.5.5)
nokogiri (1.6.2.1)
mini_portile (= 0.6.0)
nprogress-rails (0.1.3.1)
@ -194,7 +209,7 @@ GEM
parser (2.2.0.pre.5)
ast (>= 1.1, < 3.0)
slop (~> 3.4, >= 3.4.5)
pg (0.17.1)
pg (0.18.1)
phantomjs (1.9.7.1)
phantomjs-binaries (1.9.2.4)
sys-uname (= 0.9.0)
@ -212,9 +227,13 @@ GEM
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.5.2)
rack-accept (0.4.5)
rack (>= 0.4)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-test (0.6.2)
rack (>= 1.0)
railroady (1.2.0)
railroady (1.3.0)
rails (4.1.4)
actionmailer (= 4.1.4)
actionpack (= 4.1.4)
@ -234,7 +253,7 @@ GEM
thor (>= 0.18.1, < 2.0)
rainbow (2.0.0)
raindrops (0.13.0)
rake (10.3.2)
rake (10.4.2)
ransack (1.3.0)
actionpack (>= 3.0)
activerecord (>= 3.0)
@ -343,7 +362,7 @@ GEM
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
turbolinks (2.4.0)
turbolinks (2.5.3)
coffee-rails
tzinfo (1.2.2)
thread_safe (~> 0.1)
@ -379,11 +398,11 @@ DEPENDENCIES
bootstrap-sass (~> 3.2.0.1)
brakeman (~> 2.6.2)
bullet (~> 4.14.0)
bundler-audit
bundler-audit (~> 0.3.1)
cancancan (~> 1.9.2)
capybara (~> 2.4.1)
coffee-rails (~> 4.0.0)
daemons
daemons (~> 1.1.9)
database_cleaner (~> 1.3.0)
delayed_job_active_record (~> 4.0.2)
devise (~> 3.3.0)
@ -391,28 +410,30 @@ DEPENDENCIES
epp-xml (~> 0.10.3)
fabrication (~> 2.11.3)
faker (~> 1.3.0)
grape (~> 0.10.1)
guard (~> 2.6.1)
guard-rspec (~> 4.3.1)
guard-rubocop (~> 1.1.0)
haml-rails (~> 0.5.3)
hashie_rails (~> 0.0.1)
isikukood
iso8601 (~> 0.8.2)
jbuilder (~> 2.0)
jquery-rails
jbuilder (~> 2.2.6)
jquery-rails (~> 3.1.1)
kaminari (~> 0.16.1)
launchy (~> 2.4.3)
mina (~> 0.3.1)
nokogiri (~> 1.6.2.1)
nprogress-rails (~> 0.1.3.1)
paper_trail (~> 3.0.5)
pg
pg (~> 0.18.0)
phantomjs (~> 1.9.7.1)
phantomjs-binaries (~> 1.9.2.4)
poltergeist (~> 1.5.1)
pry (~> 0.10.1)
railroady
railroady (~> 1.3.0)
rails (= 4.1.4)
rails-settings-cached (= 0.4.1)
rails-settings-cached (~> 0.4.1)
ransack (~> 1.3.0)
rspec-rails (~> 3.0.2)
rubocop (~> 0.26.1)
@ -427,7 +448,7 @@ DEPENDENCIES
spring-commands-rspec (~> 1.0.2)
therubyracer
traceroute (~> 0.4.0)
turbolinks
turbolinks (~> 2.5.3)
uglifier (>= 1.3.0)
unicorn
uuidtools (~> 2.1.4)

16
app/api/repp/api.rb Normal file
View file

@ -0,0 +1,16 @@
module Repp
class API < Grape::API
format :json
prefix :repp
http_basic do |username, password|
@current_user ||= EppUser.find_by(username: username, password: password)
end
helpers do
attr_reader :current_user
end
mount Repp::DomainV1
end
end

16
app/api/repp/domain_v1.rb Normal file
View file

@ -0,0 +1,16 @@
module Repp
class DomainV1 < Grape::API
version 'v1', using: :path
resource :domains do
desc 'Return list of domains'
get '/' do
domains = current_user.registrar.domains.page(params[:page])
{
domains: domains,
total_pages: domains.total_pages
}
end
end
end
end

View file

@ -13,8 +13,8 @@ module Epp::DomainsHelper
end
def check_domain
ph = params_hash['epp']['command']['check']['check']
@domains = Epp::EppDomain.check_availability(ph[:name])
names = parsed_frame.css('name').map(&:text)
@domains = Epp::EppDomain.check_availability(names)
render '/epp/domains/check'
end
@ -119,6 +119,12 @@ module Epp::DomainsHelper
private
## CHECK
def validate_domain_check_request
epp_request_valid?('name')
end
## CREATE
def validate_domain_create_request
ret = true

View file

@ -27,6 +27,9 @@ module Registry
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
config.generators do |g|
g.stylesheets false
g.javascripts false

View file

@ -5,6 +5,8 @@ Rails.application.routes.draw do
get 'error/:command', to: 'errors#error', defaults: { format: :xml }
end
mount Repp::API => '/'
## ADMIN ROUTES
namespace(:admin) do
resources :keyrelays

View file

@ -0,0 +1,22 @@
require 'rails_helper'
describe Repp::DomainV1 do
let(:epp_user) { Fabricate(:epp_user) }
before(:each) { create_settings }
describe 'GET /repp/v1/domains' do
it 'returns domains of the current registrar' do
Fabricate.times(2, :domain, registrar: epp_user.registrar)
get_with_auth '/repp/v1/domains', {}, epp_user
expect(response.status).to eq(200)
body = JSON.parse(response.body)
expect(body['total_pages']).to eq(1)
# TODO: Maybe there is a way not to convert from and to json again
expect(body['domains'].to_json).to eq(epp_user.registrar.domains.to_json)
end
end
end

36
spec/support/request.rb Normal file
View file

@ -0,0 +1,36 @@
module Request
def get_with_auth(path, params, epp_user)
get path, params, env_with_auth(epp_user)
end
def delete_with_auth(path, epp_user)
delete path, params, env_with_auth(epp_user)
end
def post_with_auth(path, params, epp_user)
post path, params, env_with_auth(epp_user)
end
def patch_with_auth(path, params, epp_user)
patch path, params, env_with_auth(epp_user)
end
def env
{
'Accept' => 'application/json',
'Content-Type' => 'application/json'
}
end
def env_with_auth(epp_user)
env.merge({
'HTTP_AUTHORIZATION' => ActionController::HttpAuthentication::Basic.encode_credentials(
epp_user.username, epp_user.password
)
})
end
end
RSpec.configure do |c|
c.include Request, type: :request
end