mirror of
https://github.com/internetee/registry.git
synced 2025-08-06 01:35:10 +02:00
Refactor EPP users to API users
This commit is contained in:
parent
b8494993ea
commit
c91c9c8ebf
44 changed files with 154 additions and 150 deletions
|
@ -2,9 +2,9 @@ require 'rails_helper'
|
|||
|
||||
describe 'EPP Contact', epp: true do
|
||||
before :all do
|
||||
Fabricate(:epp_user)
|
||||
Fabricate(:epp_user, username: 'registrar1', registrar: registrar1)
|
||||
Fabricate(:epp_user, username: 'registrar2', registrar: registrar2)
|
||||
Fabricate(:api_user)
|
||||
Fabricate(:api_user, username: 'registrar1', registrar: registrar1)
|
||||
Fabricate(:api_user, username: 'registrar2', registrar: registrar2)
|
||||
|
||||
login_as :gitlab
|
||||
|
||||
|
@ -68,7 +68,7 @@ describe 'EPP Contact', epp: true do
|
|||
@contact = Contact.last
|
||||
|
||||
@contact.registrar.should == registrar1
|
||||
registrar1.epp_users.should include(@contact.created_by)
|
||||
registrar1.api_users.should include(@contact.created_by)
|
||||
@contact.updated_by_id.should == nil
|
||||
@contact.ident.should == '37605030299'
|
||||
@contact.address.street.should == '123 Example'
|
||||
|
@ -153,7 +153,7 @@ describe 'EPP Contact', epp: true do
|
|||
|
||||
context 'update command' do
|
||||
before :all do
|
||||
@contact =
|
||||
@contact =
|
||||
Fabricate(
|
||||
:contact,
|
||||
created_by_id: 1,
|
||||
|
@ -212,11 +212,11 @@ describe 'EPP Contact', epp: true do
|
|||
|
||||
it 'updates disclosure items' do
|
||||
Fabricate(
|
||||
:contact,
|
||||
:contact,
|
||||
code: 'sh8013disclosure',
|
||||
auth_info: '2fooBAR',
|
||||
registrar: registrar1,
|
||||
created_by_id: EppUser.first.id,
|
||||
created_by_id: ApiUser.first.id,
|
||||
disclosure: Fabricate(:contact_disclosure, phone: true, email: true))
|
||||
|
||||
xml = {
|
||||
|
@ -245,7 +245,7 @@ describe 'EPP Contact', epp: true do
|
|||
|
||||
it 'deletes contact' do
|
||||
@contact_deleted =
|
||||
Fabricate(:contact, code: 'dwa1234', created_by_id: EppUser.first.id, registrar: registrar1)
|
||||
Fabricate(:contact, code: 'dwa1234', created_by_id: ApiUser.first.id, registrar: registrar1)
|
||||
|
||||
response = epp_plain_request(delete_contact_xml({ id: { value: 'dwa1234' } }), :xml)
|
||||
response[:msg].should == 'Command completed successfully'
|
||||
|
@ -341,7 +341,7 @@ describe 'EPP Contact', epp: true do
|
|||
end
|
||||
|
||||
# it 'returns auth error for non-owner with wrong password' do
|
||||
# @contact = Fabricate(:contact,
|
||||
# @contact = Fabricate(:contact,
|
||||
# registrar: registrar2, code: 'info-4444', name: 'Johnny Awesome', auth_info: 'asde',
|
||||
# address: Fabricate(:address), disclosure: Fabricate(:contact_disclosure, name: false))
|
||||
|
||||
|
@ -354,8 +354,8 @@ describe 'EPP Contact', epp: true do
|
|||
|
||||
context 'about disclose' do
|
||||
# it 'discloses items with wrong password when queried by owner' do
|
||||
# @contact = Fabricate(:contact,
|
||||
# registrar: registrar1, code: 'info-4444',
|
||||
# @contact = Fabricate(:contact,
|
||||
# registrar: registrar1, code: 'info-4444',
|
||||
# name: 'Johnny Awesome', auth_info: 'asde',
|
||||
# address: Fabricate(:address), disclosure: Fabricate(:contact_disclosure, name: false))
|
||||
|
||||
|
@ -424,9 +424,9 @@ describe 'EPP Contact', epp: true do
|
|||
# expect(response[:msg]).to eq('Required parameter missing: pw')
|
||||
end
|
||||
|
||||
it 'does not display unassociated object with wrong password' do
|
||||
it 'does not display unassociated object with wrong password' do
|
||||
login_as :registrar2
|
||||
xml = epp_xml.info(id: { value: @registrar1_contact.code },
|
||||
xml = epp_xml.info(id: { value: @registrar1_contact.code },
|
||||
authInfo: { pw: { value: 'wrong-pw' } })
|
||||
response = epp_plain_request(xml, :xml)
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ describe 'EPP Domain', epp: true do
|
|||
end
|
||||
|
||||
before(:all) do
|
||||
Fabricate(:epp_user, username: 'registrar1', registrar: registrar1)
|
||||
Fabricate(:epp_user, username: 'registrar2', registrar: registrar2)
|
||||
Fabricate(:api_user, username: 'registrar1', registrar: registrar1)
|
||||
Fabricate(:api_user, username: 'registrar2', registrar: registrar2)
|
||||
|
||||
login_as :registrar1
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ describe 'EPP Keyrelay', epp: true do
|
|||
before(:all) do
|
||||
@elkdata = Fabricate(:registrar, { name: 'Elkdata', reg_no: '123' })
|
||||
@zone = Fabricate(:registrar)
|
||||
Fabricate(:epp_user, username: 'zone', registrar: @zone)
|
||||
Fabricate(:epp_user, username: 'elkdata', registrar: @elkdata)
|
||||
Fabricate(:api_user, username: 'zone', registrar: @zone)
|
||||
Fabricate(:api_user, username: 'elkdata', registrar: @elkdata)
|
||||
|
||||
@uniq_no = proc { @i ||= 0; @i += 1 }
|
||||
end
|
||||
|
|
|
@ -12,8 +12,8 @@ describe 'EPP Poll', epp: true do
|
|||
end
|
||||
|
||||
before(:all) do
|
||||
Fabricate(:epp_user, username: 'registrar1', registrar: registrar1)
|
||||
Fabricate(:epp_user, username: 'registrar2', registrar: registrar2)
|
||||
Fabricate(:api_user, username: 'registrar1', registrar: registrar1)
|
||||
Fabricate(:api_user, username: 'registrar2', registrar: registrar2)
|
||||
|
||||
login_as :registrar1
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe 'EPP Session', epp: true do
|
||||
before :all do
|
||||
@epp_user = Fabricate(:epp_user)
|
||||
before :all do
|
||||
@api_user = Fabricate(:api_user)
|
||||
@epp_xml = EppXml.new(cl_trid: 'ABC-12345')
|
||||
@login_xml_cache = @epp_xml.session.login(clID: { value: 'gitlab' }, pw: { value: 'ghyt9e4fu' })
|
||||
|
||||
|
@ -31,7 +31,7 @@ describe 'EPP Session', epp: true do
|
|||
|
||||
it 'does not log in with inactive user' do
|
||||
@registrar = Fabricate(:registrar, { name: 'registrar1', reg_no: '123' })
|
||||
Fabricate(:epp_user, username: 'inactive-user', active: false, registrar: @registrar)
|
||||
Fabricate(:api_user, username: 'inactive-user', active: false, registrar: @registrar)
|
||||
|
||||
inactive = @epp_xml.session.login(clID: { value: 'inactive-user' }, pw: { value: 'ghyt9e4fu' })
|
||||
response = epp_plain_request(inactive, :xml)
|
||||
|
@ -73,12 +73,12 @@ describe 'EPP Session', epp: true do
|
|||
it 'logs out epp user' do
|
||||
epp_plain_request(@login_xml_cache, :xml)
|
||||
|
||||
EppSession.last[:epp_user_id].should == 1
|
||||
EppSession.last[:api_user_id].should == 1
|
||||
response = epp_plain_request(@epp_xml.session.logout, :xml)
|
||||
response[:msg].should == 'Command completed successfully; ending session'
|
||||
response[:result_code].should == '1500'
|
||||
|
||||
EppSession.last[:epp_user_id].should == nil
|
||||
EppSession.last[:api_user_id].should == nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Fabricator(:epp_user) do
|
||||
Fabricator(:api_user) do
|
||||
username 'gitlab'
|
||||
password 'ghyt9e4fu'
|
||||
registrar
|
|
@ -1,5 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe EppUser do
|
||||
describe ApiUser do
|
||||
it { should belong_to(:registrar) }
|
||||
end
|
|
@ -1,9 +1,9 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Contact do
|
||||
before :all do
|
||||
before :all do
|
||||
create_disclosure_settings
|
||||
@epp_user = Fabricate(:epp_user)
|
||||
@api_user = Fabricate(:api_user)
|
||||
end
|
||||
|
||||
it { should have_one(:address) }
|
||||
|
@ -150,7 +150,7 @@ describe Contact do
|
|||
|
||||
context 'with creator' do
|
||||
before :all do
|
||||
@contact.created_by = @epp_user
|
||||
@contact.created_by = @api_user
|
||||
end
|
||||
|
||||
# TODO: change cr_id to something else
|
||||
|
@ -161,9 +161,9 @@ describe Contact do
|
|||
|
||||
context 'with updater' do
|
||||
before :all do
|
||||
@contact.updated_by = @epp_user
|
||||
@contact.updated_by = @api_user
|
||||
end
|
||||
|
||||
|
||||
# TODO: change up_id to something else
|
||||
it 'should return username of updater' do
|
||||
@contact.up_id.should == 'gitlab'
|
||||
|
|
|
@ -10,12 +10,12 @@ describe EppSession do
|
|||
end
|
||||
|
||||
it 'stores data' do
|
||||
expect(epp_session[:epp_user_id]).to eq(1)
|
||||
expect(epp_session[:api_user_id]).to eq(1)
|
||||
|
||||
epp_session[:epp_user_id] = 3
|
||||
expect(epp_session[:epp_user_id]).to eq(3)
|
||||
epp_session[:api_user_id] = 3
|
||||
expect(epp_session[:api_user_id]).to eq(3)
|
||||
|
||||
epp_session = EppSession.find_by(session_id: 'test')
|
||||
expect(epp_session[:epp_user_id]).to eq(3)
|
||||
expect(epp_session[:api_user_id]).to eq(3)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,6 @@ require 'rails_helper'
|
|||
describe Registrar do
|
||||
it { should belong_to(:country) }
|
||||
it { should have_many(:domains) }
|
||||
it { should have_many(:epp_users) }
|
||||
it { should have_many(:api_users) }
|
||||
it { should have_many(:messages) }
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ describe User do
|
|||
it { should be_able_to(:manage, ZonefileSetting.new) }
|
||||
it { should be_able_to(:manage, DomainVersion.new) }
|
||||
it { should be_able_to(:manage, User.new) }
|
||||
it { should be_able_to(:manage, EppUser.new) }
|
||||
it { should be_able_to(:manage, ApiUser.new) }
|
||||
it { should be_able_to(:manage, Keyrelay.new) }
|
||||
it { should be_able_to(:manage, LegalDocument.new) }
|
||||
it { should be_able_to(:read, ApiLog::EppLog.new) }
|
||||
|
@ -36,7 +36,7 @@ describe User do
|
|||
it { should_not be_able_to(:manage, ZonefileSetting.new) }
|
||||
it { should_not be_able_to(:manage, DomainVersion.new) }
|
||||
it { should_not be_able_to(:manage, User.new) }
|
||||
it { should_not be_able_to(:manage, EppUser.new) }
|
||||
it { should_not be_able_to(:manage, ApiUser.new) }
|
||||
it { should_not be_able_to(:manage, LegalDocument.new) }
|
||||
it { should_not be_able_to(:read, ApiLog::EppLog.new) }
|
||||
it { should_not be_able_to(:read, ApiLog::ReppLog.new) }
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Repp::ContactV1 do
|
||||
let(:epp_user) { Fabricate(:epp_user) }
|
||||
let(:api_user) { Fabricate(:api_user) }
|
||||
|
||||
before(:each) { create_settings }
|
||||
|
||||
describe 'GET /repp/v1/contacts' do
|
||||
it 'returns contacts of the current registrar' do
|
||||
Fabricate.times(2, :contact, registrar: epp_user.registrar)
|
||||
Fabricate.times(2, :contact, registrar: api_user.registrar)
|
||||
Fabricate.times(2, :contact)
|
||||
|
||||
get_with_auth '/repp/v1/contacts', {}, epp_user
|
||||
get_with_auth '/repp/v1/contacts', {}, api_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['contacts'].to_json).to eq(epp_user.registrar.contacts.to_json)
|
||||
expect(body['contacts'].to_json).to eq(api_user.registrar.contacts.to_json)
|
||||
|
||||
log = ApiLog::ReppLog.first
|
||||
expect(log[:request_path]).to eq('/repp/v1/contacts')
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Repp::DomainV1 do
|
||||
let(:epp_user) { Fabricate(:epp_user) }
|
||||
let(:api_user) { Fabricate(:api_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)
|
||||
Fabricate.times(2, :domain, registrar: api_user.registrar)
|
||||
|
||||
get_with_auth '/repp/v1/domains', {}, epp_user
|
||||
get_with_auth '/repp/v1/domains', {}, api_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)
|
||||
expect(body['domains'].to_json).to eq(api_user.registrar.domains.to_json)
|
||||
|
||||
log = ApiLog::ReppLog.last
|
||||
expect(log[:request_path]).to eq('/repp/v1/domains')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue