Resolve merge errors

This commit is contained in:
Karl Erik Õunapuu 2020-09-02 16:25:34 +03:00
commit 73e9dd6870
817 changed files with 16875 additions and 17443 deletions

View file

@ -3,13 +3,24 @@ require 'test_helper'
require 'database_cleaner'
require 'selenium/webdriver'
ApplicationSystemTestCase = Class.new(ApplicationIntegrationTest)
class ApplicationSystemTestCase < ActionDispatch::IntegrationTest
include Capybara::DSL
include Capybara::Minitest::Assertions
include AbstractController::Translation
include Devise::Test::IntegrationHelpers
teardown do
WebMock.reset!
Capybara.reset_sessions!
Capybara.use_default_driver
end
end
class JavaScriptApplicationSystemTestCase < ApplicationSystemTestCase
self.use_transactional_fixtures = false
self.use_transactional_tests = false
DatabaseCleaner.strategy = :truncation
Capybara.register_driver(:chrome) do |_app|
Capybara.register_driver(:chrome) do |app|
options = ::Selenium::WebDriver::Chrome::Options.new
options.add_argument('--headless')
@ -17,13 +28,10 @@ class JavaScriptApplicationSystemTestCase < ApplicationSystemTestCase
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--window-size=1400,1400')
Capybara::Selenium::Driver.new(Rails.application, browser: :chrome, options: options)
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
end
Capybara.register_server(:silent_puma) do |app, port, _host|
require 'rack/handler/puma'
Rack::Handler::Puma.run(app, Port: port, Threads: '0:2', Silent: true)
end
Capybara.server = :puma, { Silent: true }
def setup
DatabaseCleaner.start
@ -31,7 +39,6 @@ class JavaScriptApplicationSystemTestCase < ApplicationSystemTestCase
super
Capybara.current_driver = :chrome
Capybara.server = :silent_puma
end
def teardown

View file

@ -2,4 +2,4 @@ one:
account: cash
invoice: one
bank_transaction: one
created_at: <%= Time.zone.parse('2010-07-05 10:00') %>
created_at: <%= Time.zone.parse('2010-07-05 10:00') %>

View file

@ -1,5 +1,5 @@
one:
sum: 1
currency: EUR
description: Order nr. 1
iban: US75512108001245126199
description: Order nr 1 from registrar 1234567 second number 2345678
iban: US75512108001245126199

View file

@ -1,5 +1,5 @@
create_one_month:
duration: 1 month
duration: 3 mons
price_cents: 100
operation_category: create
valid_from: 2010-07-05
@ -7,7 +7,7 @@ create_one_month:
zone: one
renew_one_month:
duration: 1 month
duration: 1 mons
price_cents: 100
operation_category: renew
valid_from: 2010-07-05

View file

@ -1,2 +1,4 @@
one:
name: blocked.test
idn:
name: blockedäöüõ.test

14
test/fixtures/certificates.yml vendored Normal file
View file

@ -0,0 +1,14 @@
api:
api_user: api_bestnames
common_name: registry.test
crt: "-----BEGIN CERTIFICATE-----\nMIICYjCCAcugAwIBAgIBADANBgkqhkiG9w0BAQ0FADBNMQswCQYDVQQGEwJ1czEO\nMAwGA1UECAwFVGV4YXMxFjAUBgNVBAoMDVJlZ2lzdHJ5IHRlc3QxFjAUBgNVBAMM\nDXJlZ2lzdHJ5LnRlc3QwIBcNMjAwNTA1MTIzNzQxWhgPMjEyMDA0MTExMjM3NDFa\nME0xCzAJBgNVBAYTAnVzMQ4wDAYDVQQIDAVUZXhhczEWMBQGA1UECgwNUmVnaXN0\ncnkgdGVzdDEWMBQGA1UEAwwNcmVnaXN0cnkudGVzdDCBnzANBgkqhkiG9w0BAQEF\nAAOBjQAwgYkCgYEAyn+GCkUJIhdXVBOPrZH+Zj2B/tQfL5TLZwVYZQt38x6GQT+4\n6ndty467IJvKSUlHej7uMpsCzC8Ffmda4cZm16jO1vUb4hXIrmeKP84zLrrUpKag\ngZR4rBDbG2+uL4SzMyy3yeQysYuTiQ4N1i4vdhvkKYPSWIht/QFvuzdFq+0CAwEA\nAaNQME4wHQYDVR0OBBYEFD6B5j6NnMCDBnfbtjBYKBJM7sCRMB8GA1UdIwQYMBaA\nFD6B5j6NnMCDBnfbtjBYKBJM7sCRMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEN\nBQADgYEArtCR6VOabD3nM/KlZTmHMZVT4ntenYlNTM9FS0RatzPmdh4REhykvmZs\nOlBcpoV5tN5Y8bHOVRqY9V2e903QEhQgoccQhbt0Py6uFwfLv+WLKAUbeGnPqK9d\ndL3wXN9BQs0hJA6IZNFyz2F/gSTURrD1zWW2na3ipRzhupW5+98=\n-----END CERTIFICATE-----\n"
md5: e6771ed5dc857a1dbcc1e0a36baa1fee
interface: api
revoked: false
registrar:
api_user: api_bestnames
common_name: registry.test
crt: "-----BEGIN CERTIFICATE-----\nMIICYjCCAcugAwIBAgIBADANBgkqhkiG9w0BAQ0FADBNMQswCQYDVQQGEwJ1czEO\nMAwGA1UECAwFVGV4YXMxFjAUBgNVBAoMDVJlZ2lzdHJ5IHRlc3QxFjAUBgNVBAMM\nDXJlZ2lzdHJ5LnRlc3QwIBcNMjAwNTA1MTIzNzQxWhgPMjEyMDA0MTExMjM3NDFa\nME0xCzAJBgNVBAYTAnVzMQ4wDAYDVQQIDAVUZXhhczEWMBQGA1UECgwNUmVnaXN0\ncnkgdGVzdDEWMBQGA1UEAwwNcmVnaXN0cnkudGVzdDCBnzANBgkqhkiG9w0BAQEF\nAAOBjQAwgYkCgYEAyn+GCkUJIhdXVBOPrZH+Zj2B/tQfL5TLZwVYZQt38x6GQT+4\n6ndty467IJvKSUlHej7uMpsCzC8Ffmda4cZm16jO1vUb4hXIrmeKP84zLrrUpKag\ngZR4rBDbG2+uL4SzMyy3yeQysYuTiQ4N1i4vdhvkKYPSWIht/QFvuzdFq+0CAwEA\nAaNQME4wHQYDVR0OBBYEFD6B5j6NnMCDBnfbtjBYKBJM7sCRMB8GA1UdIwQYMBaA\nFD6B5j6NnMCDBnfbtjBYKBJM7sCRMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEN\nBQADgYEArtCR6VOabD3nM/KlZTmHMZVT4ntenYlNTM9FS0RatzPmdh4REhykvmZs\nOlBcpoV5tN5Y8bHOVRqY9V2e903QEhQgoccQhbt0Py6uFwfLv+WLKAUbeGnPqK9d\ndL3wXN9BQs0hJA6IZNFyz2F/gSTURrD1zWW2na3ipRzhupW5+98=\n-----END CERTIFICATE-----\n"
md5: e6771ed5dc857a1dbcc1e0a36baa1fee
interface: registrar
revoked: false

View file

@ -85,3 +85,11 @@ invalid:
auth_info: any
registrar: bestnames
uuid: bd80c0f9-26ee-49e0-a2cb-2311d931c433
invalid_email:
name: any
code: invalid_email
email: invalid@invalid.
auth_info: any
registrar: bestnames
uuid: fa8c4f51-a221-4628-b3c6-47995f4edea3

22
test/fixtures/disputes.yml vendored Normal file
View file

@ -0,0 +1,22 @@
active:
domain_name: active-dispute.test
password: active-001
starts_at: <%= Date.parse '2010-07-05' %>
expires_at: <%= Date.parse '2013-07-05' %>
future:
domain_name: future-dispute.test
password: active-001
starts_at: <%= Date.parse '2010-10-05' %>
expires_at: <%= Date.parse '2013-10-05' %>
expired:
domain_name: shop.test
password: active-001
starts_at: <%= Date.parse '2010-07-05' %>
expires_at: <%= Date.parse '2013-07-05' %>
closed: <%= Date.parse '2013-07-05' %>
closed:
domain_name: closed_dispute.test
password: active-001
starts_at: <%= Date.parse '2010-07-05' %>
expires_at: <%= Date.parse '2013-07-05' %>
closed: <%= Date.parse '2013-07-05' %>

View file

@ -2,3 +2,10 @@
one:
origin: test
ttl: 1
refresh: 1
retry: 1
expire: 1
minimum_ttl: 1
email: admin@registry.test
master_nameserver: ns.test

View file

@ -1,5 +1,6 @@
shop:
name: shop.test
name_puny: shop.test
name_dirty: shop.test
registrar: bestnames
registrant: john
@ -15,6 +16,7 @@ shop:
airport:
name: airport.test
name_puny: airport.test
name_dirty: airport.test
registrar: bestnames
registrant: john
@ -26,6 +28,7 @@ airport:
library:
name: library.test
name_puny: library.test
name_dirty: library.test
registrar: bestnames
registrant: acme_ltd
@ -37,6 +40,7 @@ library:
metro:
name: metro.test
name_puny: metro.test
name_dirty: metro.test
registrar: goodnames
registrant: jack
@ -48,6 +52,7 @@ metro:
hospital:
name: hospital.test
name_puny: hospital.test
name_dirty: hospital.test
registrar: goodnames
registrant: john
@ -59,6 +64,8 @@ hospital:
invalid:
name: invalid.test
name_puny: invalid.test
name_dirty: invalid.test
transfer_code: 1438d6
valid_to: <%= Time.zone.parse('2010-07-05').utc.to_s(:db) %>
registrar: bestnames

View file

@ -0,0 +1,6 @@
VV 000689EE4567890123456789012005181404
VV 220200518 M EE456789012345678901EUR Algsaldo C 0
VV 12020051847406380MK EE456789012345678901EUR689EE123456789012345678 Registripidaja 413 ettemaks C 5000
VV 12020051847406461MK EE456789012345678901EUR767EE012345678901234567 Hankija 303 Kulu D 5000
VV 320200518 M EE456789012345678901EUR Lõppsaldo C 0
VV 999 10000

BIN
test/fixtures/files/keystore.p12 vendored Normal file

Binary file not shown.

BIN
test/fixtures/files/legaldoc.pdf vendored Normal file

Binary file not shown.

View file

@ -0,0 +1,35 @@
-----BEGIN CERTIFICATE-----
MIIGDDCCA/SgAwIBAgIJAKaLNUIy97o1MA0GCSqGSIb3DQEBCwUAMIGVMQswCQYD
VQQGEwJFRTERMA8GA1UECAwISGFyanVtYWExEDAOBgNVBAcMB1RhbGxpbm4xIzAh
BgNVBAoMGkVlc3RpIEludGVybmV0aSBTaWh0YXN1dHVzMRowGAYDVQQDDBFlcHBf
cHJveHkgdGVzdCBjYTEgMB4GCSqGSIb3DQEJARYRaGVsbG9AaW50ZXJuZXQuZWUw
HhcNMTkwNzExMTMwMDEzWhcNMjAwNzEwMTMwMDEzWjCBlTELMAkGA1UEBhMCRUUx
ETAPBgNVBAgMCEhhcmp1bWFhMRAwDgYDVQQHDAdUYWxsaW5uMSMwIQYDVQQKDBpF
ZXN0aSBJbnRlcm5ldGkgU2lodGFzdXR1czEaMBgGA1UEAwwRZXBwX3Byb3h5IHRl
c3QgY2ExIDAeBgkqhkiG9w0BCQEWEWhlbGxvQGludGVybmV0LmVlMIICIjANBgkq
hkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0PBwqZUeXZaR3mk3VTm7S78Xs4WDCfyi
RocHDU7cWhrBvFD5ZXzmbUJPPJHmljYAOLWLEyMzw0bvYVz2FSOCkBerxGFA4T17
RhjDEAmMMWiBAoFj6tNmxj3bq7nZfwaOY6KIxGiZcqx4usOQ3tQ+cxvrqzFVyX24
KScmx4l2HlmJu2boF8/C4LSYvGPys+2WKXlLr73gL+cmM7Z2Y+mNgURCKT9ODpFp
VdX9iTpmnF0UFmYq/cN8QFSNv0ErsMFDZWxAnDoy6gZzsUz3ZnznOdjB96PFV9aA
Rm5BYr7jMhu7rJPOyQNd9SfD6QhlyCSjd68p6nMFvYLG5lL5QxJSTotr3VuH1uqJ
kfFwlMPJZAj/SmFUnoIvWGCyujqx6ajVX8zBvmcalSp35LyDDCnlohorUuP9TNrI
U+k/Ap6vxfxSSIOPhq6BoFxMYASp8jo+8HdFOWce5krQh/h3vvEhu015yEXH4Vgb
6lL+nvUex35He1IQFERvRSj5IB1Yw6HpwYb7LIfjXYsfas3FuSxXz9Geb23dybYd
2MlmKeGvTyjM60BNW2ZKKQ00KgnqR62bPALbDZ/AnkzxnLd7NLVqKiSBzOOkZfaO
V7hDD78VzSklA2cSV1qaBPHUW4AgQkmDJIF/1H/K9nN/F6OWKSJ0Ug3XGwDjY3Ry
X//K+E1UNWMCAwEAAaNdMFswHQYDVR0OBBYEFP135kpzvaU8ZbO5z7UVlVkIZGgQ
MB8GA1UdIwQYMBaAFP135kpzvaU8ZbO5z7UVlVkIZGgQMAwGA1UdEwQFMAMBAf8w
CwYDVR0PBAQDAgEGMA0GCSqGSIb3DQEBCwUAA4ICAQDF3s887Qj2eLeJln1Z/Nem
ZR2tj0PvYEHEYKq9R8N8IM1ooZt475MgyYo7XDPcuG3MMaGY9WdjqoXlWSM7T518
U9ajFLqwNEnlfjZ33SdVDskfoRsKiDKUlvTNngn19KtAp3SBmQS6fgghlgha3tb+
W1fOgzCRwaVG4XcQfR+wijSSovFOp+5CY/FL6XUwtFCz4ZwnHgXciG91SjhEPB+J
P8iHFr4f0qV4kKv0hPfjQ7tneeho0AzI4BXOgbRJmur6+SP/gmsgBeKr1sUHuD+d
nIAlz4T2reV8FujcW3u8yT4PFIhi0mdnXKC6xKDFlmD9AQa7eUO1DHJiSZ7zAsLS
drsqMu3GhM70Uw0Oqv2aInv8N4vwF6CJ6p/wEUXTVjkjH3U/ZzuOGcl1/5sAao0r
APwRazSMcqrjc+JicpFZ6NGTwTs0G6KD0dqhhqoyoZzB/1UDR2cG5SsgSTqBUeGb
0VMW4EYU+DG1HV+OdNrFA0RgDn5o0VF3LxwAs5ErItlojFPeBDYMJvPGsMEarNHN
03JeeEK081gzLJQzFPQV1n6kE6CiGGTx4X3ptUtvvQBD/u6KNUwN5b6p5jOQBEdZ
F4PJOVZePI/dBHr98/jlcHfCOmySc+7uzPhB86OtdF/yYabImpvQ0cypZkXwzL6l
VgOJJfHQrIhSmCRVxCEJoQ==
-----END CERTIFICATE-----

View file

@ -0,0 +1 @@
8728BF086E9B1CE5

22
test/fixtures/files/test_ca/crl/crl.pem vendored Normal file
View file

@ -0,0 +1,22 @@
-----BEGIN X509 CRL-----
MIIDkjCCAXoCAQEwDQYJKoZIhvcNAQELBQAwgZUxCzAJBgNVBAYTAkVFMREwDwYD
VQQIDAhIYXJqdW1hYTEQMA4GA1UEBwwHVGFsbGlubjEjMCEGA1UECgwaRWVzdGkg
SW50ZXJuZXRpIFNpaHRhc3V0dXMxGjAYBgNVBAMMEWVwcF9wcm94eSB0ZXN0IGNh
MSAwHgYJKoZIhvcNAQkBFhFoZWxsb0BpbnRlcm5ldC5lZRcNMTkwNzI5MDc1NTA5
WhcNMjkwNzI2MDc1NTA5WjB+MBMCAhACFw0xOTA1MjkwNjM5MTJaMBMCAhADFw0x
OTA1MjkwODQxMDJaMBMCAhAEFw0xOTA1MzExMTI0NTJaMBMCAhAFFw0xOTA1MzEx
MTQyMjJaMBMCAhAGFw0xOTA1MzExMjQzNDlaMBMCAhAHFw0xOTA3MjkwNzU0MzRa
oDAwLjAfBgNVHSMEGDAWgBT9d+ZKc72lPGWzuc+1FZVZCGRoEDALBgNVHRQEBAIC
EAkwDQYJKoZIhvcNAQELBQADggIBAEk9pyZjqyYUdnA0Sv7RyevRUQGKbbf3EXdv
JLDyvI9rpoyuWPkMT6vPsYght0cf/wO7oaEK/uustvFEYQiJss60jI0XuczWypk9
paKu3LhIy6Drm3locY2k0ESrgP9IwNzS5Xr0FiaWRIozbkcawte8M4Nqe8BO5prk
/5sLjv3eFnD7E445tZhu3vmXkD50FT3PLHVBEz4yS6Fx6nTiv+9QUu8NGf+bc6+o
YKPMy6Lh/wGC7p6sZJCOCjfzLAcqWfB2EW6XU8WeQcQCZ0au7zvZjQownCS9CeJV
KVsC4QiUt97FxR2gcEN2GJesywIF11X9o8s1K/Hz3+rrtU1ymoMLeumaRW24z35A
zVsdNwRfSPmt1qHlyaJaFhKG6jw5/nws+/wGFycIjWK0DSORiGCYdKD0cCjKJbNO
2QJnJlNOaCUUj8ULyiFOtZvdadc4JVW42NI/F+AFy/bnBK0uH6CenK5XwX3kEMme
KD8b5reUcVRhQdVJdAABFJlihIg05yENI7hlH1CKfy4vmlBKl+M2mW9cmNO8O6uS
KMH8/wLuLga9gYziNT1RmVNFbnpF0hc6CFtSnlVXXTlU/TrxheH8ykrHQhKEkQj+
3krObDFDCUMKmaGu2nxRYZwLXzUe3wVl1SAxw0eEGyON/N83sLYlcrwWTVzRG3Z7
RqRHPn+h
-----END X509 CRL-----

1
test/fixtures/files/test_ca/crlnumber vendored Normal file
View file

@ -0,0 +1 @@
1000

View file

@ -0,0 +1,15 @@
# !/bin/sh
# Use localhost as common name.
openssl genrsa -out private/client.key.pem 4096
openssl req -sha256 -config openssl.cnf -new -days 3650 -key private/client.key.pem -out csrs/client.csr.pem
openssl ca -config openssl.cnf -keyfile private/ca.key.pem -cert certs/ca.crt.pem -extensions usr_cert -notext -md sha256 -in csrs/client.csr.pem -days 3650 -out certs/client.crt.pem
openssl genrsa -out private/revoked.key.pem 4096
openssl req -sha256 -config openssl.cnf -new -days 3650 -key private/revoked.key.pem -out csrs/revoked.csr.pem
openssl ca -config openssl.cnf -keyfile private/ca.key.pem -cert certs/ca.crt.pem -extensions usr_cert -notext -md sha256 -in csrs/revoked.csr.pem -days 3650 -out certs/revoked.crt.pem
openssl ca -config openssl.cnf -keyfile private/ca.key.pem -cert certs/ca.crt.pem -revoke certs/revoked.crt.pem
openssl ca -config openssl.cnf -keyfile private/ca.key.pem -cert certs/ca.crt.pem -crldays 3650 -gencrl -out crl/crl.pem
openssl req -config openssl.cnf -new -sha256 -nodes -out server.csr -newkey rsa:2048 -keyout private/apache.key -config server.csr.cnf
openssl x509 -req -in server.csr -CA certs/ca.crt.pem -CAkey private/ca.key.pem -CAcreateserial -out certs/apache.crt -days 3650 -sha256 -extfile v3.ext

0
test/fixtures/files/test_ca/index.txt vendored Normal file
View file

348
test/fixtures/files/test_ca/openssl.cnf vendored Normal file
View file

@ -0,0 +1,348 @@
#
# OpenSSL example configuration file.
# This is mostly being used for generation of certificate requests.
#
# This definition stops the following lines choking if HOME isn't
# defined.
HOME = .
RANDFILE = $ENV::HOME/.rnd
# Extra OBJECT IDENTIFIER info:
#oid_file = $ENV::HOME/.oid
oid_section = new_oids
# To use this configuration file with the "-extfile" option of the
# "openssl x509" utility, name here the section containing the
# X.509v3 extensions to use:
# extensions =
# (Alternatively, use a configuration file that has only
# X.509v3 extensions in its main [= default] section.)
[ new_oids ]
# We can add new OIDs in here for use by 'ca', 'req' and 'ts'.
# Add a simple OID like this:
# testoid1=1.2.3.4
# Or use config file substitution like this:
# testoid2=${testoid1}.5.6
# Policies used by the TSA examples.
tsa_policy1 = 1.2.3.4.1
tsa_policy2 = 1.2.3.4.5.6
tsa_policy3 = 1.2.3.4.5.7
####################################################################
[ ca ]
default_ca = CA_default # The default ca section
####################################################################
[ CA_default ]
dir = /opt/ca # Where everything is kept
certs = $dir/certs # Where the issued certs are kept
crl_dir = $dir/crl # Where the issued crl are kept
database = $dir/index.txt # database index file.
#unique_subject = no # Set to 'no' to allow creation of
# several certs with same subject.
new_certs_dir = $dir/newcerts # default place for new certs.
certificate = $dir/cacert.pem # The CA certificate
serial = $dir/serial # The current serial number
crlnumber = $dir/crlnumber # the current crl number
# must be commented out to leave a V1 CRL
crl = $dir/crl.pem # The current CRL
private_key = $dir/private/cakey.pem# The private key
RANDFILE = $dir/private/.rand # private random number file
x509_extensions = usr_cert # The extensions to add to the cert
# Comment out the following two lines for the "traditional"
# (and highly broken) format.
name_opt = ca_default # Subject Name options
cert_opt = ca_default # Certificate field options
# Extension copying option: use with caution.
# copy_extensions = copy
# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs
# so this is commented out by default to leave a V1 CRL.
# crlnumber must also be commented out to leave a V1 CRL.
crl_extensions = crl_ext
default_days = 365 # how long to certify for
default_crl_days= 30 # how long before next CRL
default_md = default # use public key default MD
preserve = no # keep passed DN ordering
# A few difference way of specifying how similar the request should look
# For type CA, the listed attributes must be the same, and the optional
# and supplied fields are just that :-)
policy = policy_match
# For the CA policy
[ policy_match ]
countryName = optional
stateOrProvinceName = optional
organizationName = optional
organizationalUnitName = optional
commonName = supplied
emailAddress = optional
# For the 'anything' policy
# At this point in time, you must list all acceptable 'object'
# types.
[ policy_anything ]
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = supplied
emailAddress = optional
####################################################################
[ req ]
default_bits = 2048
default_keyfile = privkey.pem
distinguished_name = req_distinguished_name
attributes = req_attributes
x509_extensions = v3_ca # The extensions to add to the self signed cert
# Passwords for private keys if not present they will be prompted for
# input_password = secret
# output_password = secret
# This sets a mask for permitted string types. There are several options.
# default: PrintableString, T61String, BMPString.
# pkix : PrintableString, BMPString (PKIX recommendation before 2004)
# utf8only: only UTF8Strings (PKIX recommendation after 2004).
# nombstr : PrintableString, T61String (no BMPStrings or UTF8Strings).
# MASK:XXXX a literal mask value.
# WARNING: ancient versions of Netscape crash on BMPStrings or UTF8Strings.
string_mask = utf8only
# req_extensions = v3_req # The extensions to add to a certificate request
[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = EE
countryName_min = 2
countryName_max = 2
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = Harjumaa
localityName = Locality Name (eg, city)
localityName_default = Tallinn
0.organizationName = Organization Name (eg, company)
0.organizationName_default = Eesti Interneti Sihtasutus
# we can do this but it is not needed normally :-)
#1.organizationName = Second Organization Name (eg, company)
#1.organizationName_default = World Wide Web Pty Ltd
organizationalUnitName = Organizational Unit Name (eg, section)
#organizationalUnitName_default =
commonName = Common Name (e.g. server FQDN or YOUR name)
commonName_max = 64
emailAddress = Email Address
emailAddress_default = hello@internet.ee
emailAddress_max = 64
# SET-ex3 = SET extension number 3
[ req_attributes ]
challengePassword = A challenge password
challengePassword_min = 4
challengePassword_max = 20
unstructuredName = An optional company name
[ usr_cert ]
# These extensions are added when 'ca' signs a request.
# This goes against PKIX guidelines but some CAs do it and some software
# requires this to avoid interpreting an end user certificate as a CA.
basicConstraints=CA:FALSE
# Here are some examples of the usage of nsCertType. If it is omitted
# the certificate can be used for anything *except* object signing.
# This is OK for an SSL server.
# nsCertType = server
# For an object signing certificate this would be used.
# nsCertType = objsign
# For normal client use this is typical
# nsCertType = client, email
# and for everything including object signing:
# nsCertType = client, email, objsign
# This is typical in keyUsage for a client certificate.
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
# This will be displayed in Netscape's comment listbox.
nsComment = "OpenSSL Generated Certificate"
# PKIX recommendations harmless if included in all certificates.
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer
# This stuff is for subjectAltName and issuerAltname.
# Import the email address.
# subjectAltName=email:copy
# An alternative to produce certificates that aren't
# deprecated according to PKIX.
# subjectAltName=email:move
# Copy subject details
# issuerAltName=issuer:copy
#nsCaRevocationUrl = http://www.domain.dom/ca-crl.pem
#nsBaseUrl
#nsRevocationUrl
#nsRenewalUrl
#nsCaPolicyUrl
#nsSslServerName
# This is required for TSA certificates.
# extendedKeyUsage = critical,timeStamping
[ v3_req ]
# Extensions to add to a certificate request
basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
[ v3_ca ]
# Extensions for a typical CA
# PKIX recommendation.
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer
basicConstraints = CA:true
# Key usage: this is typical for a CA certificate. However since it will
# prevent it being used as an test self-signed certificate it is best
# left out by default.
keyUsage = cRLSign, keyCertSign
# Some might want this also
# nsCertType = sslCA, emailCA
# Include email address in subject alt name: another PKIX recommendation
# subjectAltName=email:copy
# Copy issuer details
# issuerAltName=issuer:copy
# DER hex encoding of an extension: beware experts only!
# obj=DER:02:03
# Where 'obj' is a standard or added object
# You can even override a supported extension:
# basicConstraints= critical, DER:30:03:01:01:FF
[ crl_ext ]
# CRL extensions.
# Only issuerAltName and authorityKeyIdentifier make any sense in a CRL.
# issuerAltName=issuer:copy
authorityKeyIdentifier=keyid:always
[ proxy_cert_ext ]
# These extensions should be added when creating a proxy certificate
# This goes against PKIX guidelines but some CAs do it and some software
# requires this to avoid interpreting an end user certificate as a CA.
basicConstraints=CA:FALSE
# Here are some examples of the usage of nsCertType. If it is omitted
# the certificate can be used for anything *except* object signing.
# This is OK for an SSL server.
# nsCertType = server
# For an object signing certificate this would be used.
# nsCertType = objsign
# For normal client use this is typical
# nsCertType = client, email
# and for everything including object signing:
# nsCertType = client, email, objsign
# This is typical in keyUsage for a client certificate.
# keyUsage = nonRepudiation, digitalSignature, keyEncipherment
# This will be displayed in Netscape's comment listbox.
nsComment = "OpenSSL Generated Certificate"
# PKIX recommendations harmless if included in all certificates.
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer
# This stuff is for subjectAltName and issuerAltname.
# Import the email address.
# subjectAltName=email:copy
# An alternative to produce certificates that aren't
# deprecated according to PKIX.
# subjectAltName=email:move
# Copy subject details
# issuerAltName=issuer:copy
#nsCaRevocationUrl = http://www.domain.dom/ca-crl.pem
#nsBaseUrl
#nsRevocationUrl
#nsRenewalUrl
#nsCaPolicyUrl
#nsSslServerName
# This really needs to be in place for it to be a proxy certificate.
proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:3,policy:foo
####################################################################
[ tsa ]
default_tsa = tsa_config1 # the default TSA section
[ tsa_config1 ]
# These are used by the TSA reply generation only.
dir = /opt/ca # TSA root directory
serial = $dir/tsaserial # The current serial number (mandatory)
crypto_device = builtin # OpenSSL engine to use for signing
signer_cert = $dir/tsacert.pem # The TSA signing certificate
# (optional)
certs = $dir/cacert.pem # Certificate chain to include in reply
# (optional)
signer_key = $dir/private/tsakey.pem # The TSA private key (optional)
signer_digest = sha256 # Signing digest to use. (Optional)
default_policy = tsa_policy1 # Policy if request did not specify it
# (optional)
other_policies = tsa_policy2, tsa_policy3 # acceptable policies (optional)
digests = sha1, sha256, sha384, sha512 # Acceptable message digests (mandatory)
accuracy = secs:1, millisecs:500, microsecs:100 # (optional)
clock_precision_digits = 0 # number of digits after dot. (optional)
ordering = yes # Is ordering defined for timestamps?
# (optional, default: no)
tsa_name = yes # Must the TSA name be included in the reply?
# (optional, default: no)
ess_cert_id_chain = no # Must the ESS cert id chain be included?
# (optional, default: no)

View file

@ -0,0 +1,8 @@
# Prepare required files
touch index.txt
echo 1000 > serial
echo 1000 > crlnumber
# Generate Root CA.
openssl genrsa -aes256 -out private/ca.key.pem 4096
openssl req -config openssl.cnf -new -x509 -days 365 -key private/ca.key.pem -sha256 -extensions v3_ca -out certs/ca.crt.pem

View file

@ -0,0 +1,54 @@
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,AEB2DBECCB8452DE1D6E3F46B4AD32A8
i/cuYpPW2lzi/spv5ZOvF5Fw19ZNOqIl42jdxyTKnEa51xKW7nlOUFvglzYiEMS5
rP4TWqnlBdRl1QXUv9R9zsL6DaPXs0j1kX8OxsV8ZRF6Pzb0G0uJBF7xxKb7c/8j
GP3uURESHhVc4ku6ctkChzTrUd7V4/pPEG5hLFdpgdTNodtfzDGWORFBDv2Jp0Mc
hiJFKnLaCFItRpQnqGKfDwJPRUJIIwjH1EUx+U4WDzUI5z7LhNVZ9A/07hYvSh56
bwZ4T4CXBXxVtBPhzb5aLigqs6CGfslsQnvoajdKEHq6B1j5Yj0aDG/IYG2jNSJM
9rRbL/0/FPmKrjsbsyxskzp2vRKYOUA2G6SU4Q8db/OBwmaz7zQC+2Og6G115f6/
TvBNsF+SfiP7YlaRs6qGJLk9NBqqdsTvTli8qGvOV3dAUp1EXB+MGsyQGitG+7+d
7XSenjHN4Lxvb0o0BBHIDv6HScIB8a1ebtLDCV45NdYyM1lsx2rOQyKwVe++TVrH
PI+vHoR+Qx1eC2m+UOzzjtRREXbwMZfe0ErvtTUC+LrU90J48u9lRZglxOR2VdjV
/eHVlTbiWgR8fcbbbBxeVOwilwXC/vRtiYHjMkbAzul4VOPRc0gRJ4VED0mpRSf0
/n82W9fJnqhWjEV/zoqYUCWaLG/Q/FXE9o81GeI5Av5HNF7SSy3pvxvt+dvU1Cxi
mJGj/w3T5e4yAJi7tPYfRvjyD30WFgIDw3AmJly600B6QAQ2+xi1UPL5kew46haS
Z+bdRb6lPGpDhZXPGRKnTYsoHFbpoE1tYWUMzFzBF1VeCPgPrmjoXzcWVD1tnzu7
LV01qUfNL/SFnue7oa8xsZj4WMfhB6DsalDf30GdR4HFgswO3rPKWxP2r+tnOscv
MBwlaSvzAY4bx8rLE5Yf46rDvoby/oy3P9ZGrLygraIG4QNOJvSB8esHfXTkT7Mb
IAFPnYWc8CjwsfBTP1wl0qzgbx04FOQfmfqfS67KUcxCN2RSOidhmfrzpZhYSTli
/qpbek3rRSssAZKkuN53ozW5gfwLJpeStuSM/or6C2EKEj7KWYkTEFTRxQtFDfZB
uWdO5836XlsVZdm99OqRUlR4eLqtyGYpZjfaMcjSBbmTs8U7Xxixb6FcLyp6UbeQ
Fa3RJQL3vkINuFzIsxjRi7AUjd18+pFjYC5nOEdoJQBAM83inBrjGyxSKKcdYlVt
j4srLisCMrtDOfijyLzl+cwoUod5DUn8JhgHM1ypIPQ7pk8vYFo38I2YE4I/Djuo
EO6l8SFaWRa6AI/gkBUazwPh2OX/41e/eGeRVbTgfuzlBwJHhW5hyKTD9/DSsSmU
cC96Y9X8pwggPR8s5zLzheOCS9ysEJmgCgPgw02f/Nxydy4VWtEYlIv/C37a3JB5
Kgtz2icD80vugSF8BkkFpQjwC8fU61pDZ0SdP5WYricakSXya46BUnZk6pS1HmZC
iw6kUrPvQk8l6e0uuB2gWPIisvpoPDuxqccayUWSbZzkV+Q3t7Mjc1uTnVQDCSGo
pdJfOr1asIBSsUzhYbvw5pDBrOTtNT6k3WAdwbhQ31q+jwhzq8ESj7UQ9klsFLlc
nthCeTC6Wv0vNbIdf5YpCR21J1RxRv8XNO1HrN1/uJKcTvrpEVFopKTN5KYnOGlq
rQdA3zetvsncmmOJe+/77pVZ/GT05yCGPlEtdjSb6RJQ3hmOZAeY/KpKh7nrYH7i
Fk+N5EJJHdCbqFLQ//Xi/8Gx5wdpzJGfFx8R0XMkQ2mXwFmqYF/IFDLnMDfp0NWW
A1SVYaQcjTOkOCdVN6CJcs8dfNo3Fm8zoo+8HMO9K1wLMiQopI+UZovIguCXELsC
A+BuzsZsnSb4bFXVq4kXbHW86WfBwoPPjRtYgDXdRyOzEd4QY0wNyBn8Ab3ogJNJ
JqNTic7N9Gg6y2GvGryiEpZL10DFUpsIIx3bdXuBOQTlDRNtj2WyQ+vpMpDwW6iQ
u0zvpvZ60Qf+akU+Z6p/yLCQUZ4JNXsp6qUaEKG3WaIwlQh5bVeWEtAOAqFDS534
4NZoW/MMpjErHcJcoi3WAVHyq03WlnaCHTRaA5KUgVhAJ+iPh49th7uDjaqlYvC2
m+eedZuac0wrsPG0UuAZJSqtPpNL5H53WYnuGSUE3OkLxNau+9lEqG7M3lAn7/N3
NjHiyNvT+3JHxDMK5icSQKvvjzscX57OLneF5jxufbDXCf4fZbnMgFDH0SXOJkxV
ImGAIfaNnmBMz/mpvAGHOGUQxZDRHxvR8fO6BrZBomOmYEiWrhWbp6XRJEz+62M8
LwE9wQnoobko3xtX+90rHWUp1jIvZRoM3dHSxIEtI2mePPklHC9RpEf9qpiwY+yR
84mI/HGiC5MnBe4BN8BMI1s2pOvLKgaEf5FJRON2nAR1qTDh0BVZx9pby2fheXBr
U80cp5khOjOeNFTJfoTJcxRv43HH4U58Ce1Gra5grB8fhdBjCqUZnX2zsuAOVAcn
+bOMUcHMI9dW6og3Plb09nhTjzLlD3i2+rCBHZOlw9m3nTBALkE8iL0f5/BFxEFy
p3fX1YWoSh/XTKdaKCQsZ9xs1oCZ73h7l1F6+o/qD2PjCkOtI5PRAGmZ83FpKY0G
eRF3vM1guPaV4qpccOqN7qii3MLVEqxWbnM0+ZBfMoHIwSvWgxaallcoyhEgLwkO
9wliM4ORX+csTmdDCJl1URR7pJBRmBMX6a7fqsZPxLQ+VjhYXZDwCohuRSYRaoai
YMVp6s6KutzSt/JUSP1oDYPxIY6pfxq/LMN4R/tBK+bdhQP8EEvcJGjKkzxslThU
utQF9Ml8oBw0LmCsxRnkPfhF2d3PmNX97QPwLBN6q1PvhQLOd1s9ILKSLBN89UCM
P7BrU/m3qcXlkGbbzKjjTMqHlvoCUQnieyAKc3ugWwGc9LIAEaFTLj45B5POXKqk
TYG3ubWWgtwVtWlCO8IMjz3+8jnQ+bHoiBwVA0y3WyQvvwqeU7SnuBHb9ktURUrs
o2LrswBQbDxvfH7T7Iz2e6pvhGMegkNo3LO86e7gaC1shMs4juCT1jy2ln2XexgN
xP8Lo0hkO2UJEVs2OMBjmawbPSEg/p/7cftwMpVUV/Dgl/7viwcLy5RGJff9y5L7
-----END RSA PRIVATE KEY-----

1
test/fixtures/files/test_ca/serial vendored Normal file
View file

@ -0,0 +1 @@
1000

18
test/fixtures/files/test_ca/server.csr vendored Normal file
View file

@ -0,0 +1,18 @@
-----BEGIN CERTIFICATE REQUEST-----
MIIC2DCCAcACAQAwgZIxCzAJBgNVBAYTAkVFMREwDwYDVQQIDAhIYXJqdW1hYTEQ
MA4GA1UEBwwHVGFsbGlubjEZMBcGA1UECgwQRWVzdGlJbnRlcm5ldGlTQTEQMA4G
A1UECwwHQXJlbmR1czEgMB4GCSqGSIb3DQEJARYRaGVsbG9AaW50ZXJuZXQuZWUx
DzANBgNVBAMMBioudGVzdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
AKqGSyKRUfemyMMZPRr803k57DzKUyf3yPkll0IeVH5QCBu+B5fmgVvpPIyGflcc
F8J+7sGO33bXprvQswqmCuKamYNevCBAtNFZ3gu4In2jFoAXfwzYr9xWnzaU4oXT
Ga2YvMSySLjcPFy2g3mxkK63zlsNQnsLpvzCWiBZyAbbbAavoxcCrQCfUYDYOlJd
sThqaray5lNtR5iM5vYam3mliDSF9UA1QtmVnYFV4KBCA/0S1HPAPq4lVHWisxvZ
Aq7bsxjvD4V6BeQSVrbKwHGBUHr941USqZUhYcIYo4djGNeKgNtcLHjTBe/n0go4
brxKJsaczUEh9FAAx1tKde8CAwEAAaAAMA0GCSqGSIb3DQEBCwUAA4IBAQAkJkKR
jqptkp2vkHUH/Nnmqh9SCPD5wETGtGLZzS/ZnWAyRPHZ8Kw3XnCvyZj41EnWifWC
+0kKSpQTvhED8RPmgfE1piQtSPuFJ9f26vyag5sGPfUkBaBl6zaxpK3fDHpCercy
N5J6b1FAoWj/rhtRCMJx8OYCmurBp4BUtyYbduk0FWhdcX8uyRiLOOxaGO7ZpkEf
CEUhEarperXPqhm9NtNbPrEP15tunf5otM6FjpIoc0wFtlOUdrZBT9dE+67F8WlT
qlXUSXucrhWt/WXEiuzaj6w/J7prDr9ua/xO9qUo5aWA6QlPsSsaQl9KF9ST0qXG
hm/lggFVtkCvKv5L
-----END CERTIFICATE REQUEST-----

View file

@ -0,0 +1,14 @@
[req]
default_bits = 2048
prompt = no
default_md = sha256
distinguished_name = dn
[dn]
C=EE
ST=Harjumaa
L=Tallinn
O=EestiInternetiSA
OU=Arendus
emailAddress=hello@internet.ee
CN = *.test

8
test/fixtures/files/test_ca/v3.ext vendored Normal file
View file

@ -0,0 +1,8 @@
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = test
DNS.2 = registry.test

View file

@ -4,3 +4,10 @@ one:
quantity: 1
unit: pc
invoice: one
two:
description: Acme services
price: 5
quantity: 1
unit: pc
invoice: unpaid

View file

@ -3,10 +3,51 @@ one:
due_date: <%= Date.parse '2010-07-06' %>
currency: EUR
seller_name: Seller Ltd
seller_reg_no: 1234
seller_iban: US75512108001245126199
seller_bank: Main Bank
seller_swift: swift
seller_email: info@seller.test
seller_country_code: US
seller_street: Main Street 1
seller_city: New York
seller_contact_name: John Doe
buyer: bestnames
buyer_name: Buyer Ltd
buyer_reg_no: 12345
buyer_email: info@buyer.test
buyer_country_code: GB
buyer_street: Main Street 2
buyer_city: London
vat_rate: 0.1
total: 16.50
reference_no: 13
number: 1
number: 1
description: Order nr 1 from registrar 1234567 second number 2345678
unpaid:
issue_date: <%= Date.parse '2010-07-05' %>
due_date: <%= Date.parse '2010-07-06' %>
currency: EUR
seller_name: Seller Ltd
seller_reg_no: 1234
seller_iban: US75512108001245126199
seller_bank: Main Bank
seller_swift: swift
seller_email: info@seller.test
seller_country_code: US
seller_street: Main Street 1
seller_city: New York
seller_contact_name: John Doe
buyer: bestnames
buyer_name: Buyer Ltd
buyer_reg_no: 12345
buyer_email: info@buyer.test
buyer_country_code: GB
buyer_street: Main Street 2
buyer_city: London
vat_rate: 0.1
total: 16.50
reference_no: 13
number: 2
description: Order nr 2 from registrar 1234567 second number 2345678

27
test/fixtures/payment_orders.yml vendored Normal file
View file

@ -0,0 +1,27 @@
everypay_issued:
type: PaymentOrders::EveryPay
status: issued
invoice: one
response:
notes:
banklink_issued:
type: PaymentOrders::Seb
status: issued
invoice: one
response:
notes:
paid:
type: PaymentOrders::EveryPay
status: paid
invoice: unpaid
response: "{}"
notes:
cancelled:
type: PaymentOrders::Seb
status: cancelled
invoice: unpaid
response: "{}"
notes: User failed to make payment. Bank responded with code 1911

View file

@ -0,0 +1,6 @@
one:
action: confirmed
action_type: domain_delete
created_at: <%= Time.zone.parse('2010-07-05') %>
domain: shop
verification_token: 1234

464
test/fixtures/setting_entries.yml vendored Normal file
View file

@ -0,0 +1,464 @@
registry_vat_prc:
code: registry_vat_prc
value: '0.2'
group: billing
format: float
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
directo_sales_agent:
code: directo_sales_agent
value: HELEN
group: billing
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
admin_contacts_min_count:
code: admin_contacts_min_count
value: '1'
group: domain_validation
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
admin_contacts_max_count:
code: admin_contacts_max_count
value: '10'
group: domain_validation
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
tech_contacts_min_count:
code: tech_contacts_min_count
value: '1'
group: domain_validation
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
tech_contacts_max_count:
code: tech_contacts_max_count
value: '10'
group: domain_validation
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
orphans_contacts_in_months:
code: orphans_contacts_in_months
value: '6'
group: domain_validation
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
ds_data_allowed:
code: ds_data_allowed
value: 'false'
group: domain_validation
format: boolean
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
key_data_allowed:
code: key_data_allowed
value: 'true'
group: domain_validation
format: boolean
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
dnskeys_min_count:
code: dnskeys_min_count
value: '0'
group: domain_validation
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
dnskeys_max_count:
code: dnskeys_max_count
value: '9'
group: domain_validation
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
nameserver_required:
code: nameserver_required
value: 'false'
group: domain_validation
format: boolean
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
ns_min_count:
code: ns_min_count
value: '2'
group: domain_validation
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
ns_max_count:
code: ns_max_count
value: '11'
group: domain_validation
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
expire_pending_confirmation:
code: expire_pending_confirmation
value: '48'
group: domain_validation
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
days_to_renew_domain_before_expire:
code: days_to_renew_domain_before_expire
value: '90'
group: domain_expiration
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
expire_warning_period:
code: expire_warning_period
value: '15'
group: domain_expiration
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
redemption_grace_period:
code: redemption_grace_period
value: '30'
group: domain_expiration
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
transfer_wait_time:
code: transfer_wait_time
value: '0'
group: other
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
ds_digest_type:
code: ds_digest_type
value: '2'
group: other
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
client_side_status_editing_enabled:
code: client_side_status_editing_enabled
value: 'false'
group: other
format: boolean
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
api_ip_whitelist_enabled:
code: api_ip_whitelist_enabled
value: 'false'
group: other
format: boolean
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
registrar_ip_whitelist_enabled:
code: registrar_ip_whitelist_enabled
value: 'false'
group: other
format: boolean
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
request_confrimation_on_registrant_change_enabled:
code: request_confrimation_on_registrant_change_enabled
value: 'true'
group: other
format: boolean
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
request_confirmation_on_domain_deletion_enabled:
code: request_confirmation_on_domain_deletion_enabled
value: 'true'
group: other
format: boolean
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
default_language:
code: default_language
value: en
group: other
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
invoice_number_min:
code: invoice_number_min
value: '131050'
group: billing
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
invoice_number_max:
code: invoice_number_max
value: '149999'
group: billing
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
days_to_keep_invoices_active:
code: days_to_keep_invoices_active
value: '30'
group: billing
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
days_to_keep_overdue_invoices_active:
code: days_to_keep_overdue_invoices_active
value: '0'
group: billing
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
minimum_deposit:
code: minimum_deposit
value: '0.0'
group: billing
format: float
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
directo_receipt_payment_term:
code: directo_receipt_payment_term
value: R
group: billing
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
directo_receipt_product_name:
code: directo_receipt_product_name
value: ETTEM06
group: billing
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
registry_billing_email:
code: registry_billing_email
value: info@internet.ee
group: billing
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
registry_invoice_contact:
code: registry_invoice_contact
value: 'Martti Õigus'
group: billing
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
registry_vat_no:
code: registry_vat_no
value: EE101286464
group: billing
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
registry_bank:
code: registry_bank
value: 'LHV Pank'
group: billing
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
registry_iban:
code: registry_iban
value: EE557700771000598731
group: billing
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
registry_swift:
code: registry_swift
value: LHVBEE22
group: billing
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
registry_email:
code: registry_email
value: info@internet.ee
group: contacts
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
registry_phone:
code: registry_phone
value: '+372 727 1000'
group: contacts
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
registry_url:
code: registry_url
value: www.internet.ee
group: contacts
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
registry_street:
code: registry_street
value: 'Paldiski mnt 80'
group: contacts
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
registry_city:
code: registry_city
value: Tallinn
group: contacts
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
registry_state:
code: registry_state
value: Harjumaa
group: contacts
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
registry_country_code:
code: registry_country_code
value: US
group: contacts
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
expiration_reminder_mail:
code: expiration_reminder_mail
value: '2'
group: domain_expiration
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
directo_monthly_number_min:
code: directo_monthly_number_min
value: '309901'
group: billing
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
directo_monthly_number_max:
code: directo_monthly_number_max
value: '309999'
group: billing
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
registry_bank_code:
code: registry_bank_code
value: '689'
group: billing
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
registry_reg_no:
code: registry_reg_no
value: '90010019'
group: contacts
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
registry_zip:
code: registry_zip
value: '10617'
group: contacts
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
registry_juridical_name:
code: registry_juridical_name
value: 'Eesti Interneti SA'
group: contacts
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
address_processing:
code: address_processing
value: 'false'
group: other
format: boolean
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
directo_monthly_number_last:
code: directo_monthly_number_last
value: '309901'
group: billing
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
dispute_period_in_months:
code: dispute_period_in_months
value: '36'
group: other
format: integer
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
registry_whois_disclaimer:
code: registry_whois_disclaimer
value: 'Search results may not be used for commercial, advertising, recompilation,
repackaging, redistribution, reuse, obscuring or other similar activities.'
group: contacts
format: string
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>
legal_document_is_mandatory:
code: legal_document_is_mandatory
value: 'true'
group: domain_validation
format: boolean
created_at: <%= Time.zone.parse('2010-07-05') %>
updated_at: <%= Time.zone.parse('2010-07-05') %>

View file

@ -19,6 +19,7 @@ api_goodnames:
admin:
username: test
email: test@registry.test
encrypted_password: <%= Devise::Encryptor.digest(AdminUser, 'testtest') %>
type: AdminUser
country_code: US

View file

@ -0,0 +1,91 @@
require 'application_system_test_case'
require 'test_helper'
class AdminDisputesSystemTest < ApplicationSystemTestCase
include ActionView::Helpers::NumberHelper
setup do
@dispute = disputes(:active)
@original_default_language = Setting.default_language
sign_in users(:admin)
end
teardown do
Setting.default_language = @original_default_language
end
def test_creates_new_dispute
assert_nil Dispute.active.find_by(domain_name: 'hospital.test')
visit admin_disputes_path
click_on 'New disputed domain'
fill_in 'Domain name', with: 'hospital.test'
fill_in 'Password', with: '1234'
fill_in 'Starts at', with: (Time.zone.today - 2.years).to_s
fill_in 'Comment', with: 'Sample comment'
click_on 'Save'
assert_text 'Dispute was successfully created.'
assert_text 'hospital.test'
end
def test_creates_new_dispute_for_unregistered_domain
assert_nil Dispute.active.find_by(domain_name: 'nonexistant.test')
visit admin_disputes_path
click_on 'New disputed domain'
fill_in 'Domain name', with: 'nonexistant.test'
fill_in 'Password', with: '1234'
fill_in 'Starts at', with: Time.zone.today.to_s
fill_in 'Comment', with: 'Sample comment'
click_on 'Save'
assert_text 'Dispute was successfully created for domain that is not registered.'
assert_text 'nonexistant.test'
end
def test_throws_error_if_starts_at_is_in_future
assert_nil Dispute.active.find_by(domain_name: 'disputed.test')
visit admin_disputes_path
click_on 'New disputed domain'
fill_in 'Domain name', with: 'disputed.test'
fill_in 'Password', with: '1234'
fill_in 'Starts at', with: (Time.zone.today + 2.day).to_s
fill_in 'Comment', with: 'Sample comment'
click_on 'Save'
assert_text "Can not be greater than today's date"
end
def test_updates_dispute
assert_not_equal Time.zone.today, @dispute.starts_at
visit edit_admin_dispute_path(@dispute)
fill_in 'Starts at', with: Time.zone.today.to_s
click_link_or_button 'Save'
assert_text 'Dispute was successfully updated'
assert_text Time.zone.today
end
def test_deletes_dispute
visit delete_admin_dispute_path(@dispute)
assert_text 'Dispute was successfully closed.'
end
def test_can_not_create_overlapping_dispute
visit admin_disputes_path
click_on 'New disputed domain'
fill_in 'Domain name', with: 'active-dispute.test'
fill_in 'Starts at', with: @dispute.starts_at + 1.day
click_on 'Save'
assert_text 'Dispute already exists for this domain at given timeframe'
end
end

View file

@ -13,7 +13,7 @@ class AdminAreaInvoicesIntegrationTest < ApplicationIntegrationTest
assert_response :ok
assert_equal 'application/pdf', response.headers['Content-Type']
assert_equal 'attachment; filename="invoice-1.pdf"', response.headers['Content-Disposition']
assert_equal "attachment; filename=\"invoice-1.pdf\"; filename*=UTF-8''invoice-1.pdf", response.headers['Content-Disposition']
assert_not_empty response.body
end
end
end

View file

@ -12,7 +12,7 @@ class AdminAreaRegistrarsIntegrationTest < ActionDispatch::IntegrationTest
new_iban = 'GB94BARC10201530093459'
assert_not_equal new_iban, @registrar.iban
patch admin_registrar_path(@registrar), registrar: { iban: new_iban }
patch admin_registrar_path(@registrar), params: { registrar: { iban: new_iban } }
@registrar.reload
assert_equal new_iban, @registrar.iban

View file

@ -0,0 +1,27 @@
require 'test_helper'
class AdminAreaZonesIntegrationTest < ApplicationIntegrationTest
setup do
@zone = dns_zones(:one)
sign_in users(:admin)
end
def test_updates_zone
new_master_nameserver = 'new.test'
assert_not_equal new_master_nameserver, @zone.master_nameserver
patch admin_zone_path(@zone), params: { zone: { master_nameserver: new_master_nameserver } }
@zone.reload
assert_equal new_master_nameserver, @zone.master_nameserver
end
def test_downloads_zone_file
post admin_zonefiles_path(origin: @zone.origin)
assert_response :ok
assert_equal 'text/plain', response.headers['Content-Type']
assert_equal "attachment; filename=\"test.txt\"; filename*=UTF-8''test.txt", response.headers['Content-Disposition']
assert_not_empty response.body
end
end

View file

@ -2,9 +2,9 @@ require 'test_helper'
class APIDomainContactsTest < ApplicationIntegrationTest
def test_replace_all_tech_contacts_of_the_current_registrar
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
new_contact_id: 'john-001' },
{ 'HTTP_AUTHORIZATION' => http_auth_key }
patch '/repp/v1/domains/contacts', params: { current_contact_id: 'william-001',
new_contact_id: 'john-001' },
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_nil domains(:shop).tech_contacts.find_by(code: 'william-001')
assert domains(:shop).tech_contacts.find_by(code: 'john-001')
@ -14,17 +14,17 @@ class APIDomainContactsTest < ApplicationIntegrationTest
def test_skip_discarded_domains
domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
new_contact_id: 'john-001' },
{ 'HTTP_AUTHORIZATION' => http_auth_key }
patch '/repp/v1/domains/contacts', params: { current_contact_id: 'william-001',
new_contact_id: 'john-001' },
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert domains(:airport).tech_contacts.find_by(code: 'william-001')
end
def test_return_affected_domains_in_alphabetical_order
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
new_contact_id: 'john-001' },
{ 'HTTP_AUTHORIZATION' => http_auth_key }
patch '/repp/v1/domains/contacts', params: { current_contact_id: 'william-001',
new_contact_id: 'john-001' },
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_response :ok
assert_equal ({ affected_domains: %w[airport.test shop.test],
@ -36,9 +36,9 @@ class APIDomainContactsTest < ApplicationIntegrationTest
domains(:shop).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
domains(:airport).update!(statuses: [DomainStatus::DELETE_CANDIDATE])
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
new_contact_id: 'john-001' },
{ 'HTTP_AUTHORIZATION' => http_auth_key }
patch '/repp/v1/domains/contacts', params: { current_contact_id: 'william-001',
new_contact_id: 'john-001' },
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_response :ok
assert_equal %w[airport.test shop.test], JSON.parse(response.body,
@ -46,25 +46,25 @@ class APIDomainContactsTest < ApplicationIntegrationTest
end
def test_keep_other_tech_contacts_intact
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
new_contact_id: 'john-001' },
{ 'HTTP_AUTHORIZATION' => http_auth_key }
patch '/repp/v1/domains/contacts', params: { current_contact_id: 'william-001',
new_contact_id: 'john-001' },
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert domains(:shop).tech_contacts.find_by(code: 'acme-ltd-001')
end
def test_keep_admin_contacts_intact
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
new_contact_id: 'john-001' },
{ 'HTTP_AUTHORIZATION' => http_auth_key }
patch '/repp/v1/domains/contacts', params: { current_contact_id: 'william-001',
new_contact_id: 'john-001' },
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert domains(:airport).admin_contacts.find_by(code: 'william-001')
end
def test_restrict_contacts_to_the_current_registrar
patch '/repp/v1/domains/contacts', { current_contact_id: 'jack-001',
new_contact_id: 'william-002' },
{ 'HTTP_AUTHORIZATION' => http_auth_key }
patch '/repp/v1/domains/contacts', params: { current_contact_id: 'jack-001',
new_contact_id: 'william-002' },
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_response :bad_request
assert_equal ({ error: { type: 'invalid_request_error',
@ -74,9 +74,9 @@ class APIDomainContactsTest < ApplicationIntegrationTest
end
def test_non_existent_current_contact
patch '/repp/v1/domains/contacts', { current_contact_id: 'non-existent',
new_contact_id: 'john-001' },
{ 'HTTP_AUTHORIZATION' => http_auth_key }
patch '/repp/v1/domains/contacts', params: { current_contact_id: 'non-existent',
new_contact_id: 'john-001' },
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_response :bad_request
assert_equal ({ error: { type: 'invalid_request_error',
param: 'current_contact_id',
@ -85,9 +85,9 @@ class APIDomainContactsTest < ApplicationIntegrationTest
end
def test_non_existent_new_contact
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
new_contact_id: 'non-existent' },
{ 'HTTP_AUTHORIZATION' => http_auth_key }
patch '/repp/v1/domains/contacts', params: { current_contact_id: 'william-001',
new_contact_id: 'non-existent' },
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_response :bad_request
assert_equal ({ error: { type: 'invalid_request_error',
param: 'new_contact_id',
@ -96,9 +96,9 @@ class APIDomainContactsTest < ApplicationIntegrationTest
end
def test_disallow_invalid_new_contact
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
new_contact_id: 'invalid' },
{ 'HTTP_AUTHORIZATION' => http_auth_key }
patch '/repp/v1/domains/contacts', params: { current_contact_id: 'william-001',
new_contact_id: 'invalid' },
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_response :bad_request
assert_equal ({ error: { type: 'invalid_request_error',
param: 'new_contact_id',
@ -107,9 +107,9 @@ class APIDomainContactsTest < ApplicationIntegrationTest
end
def test_disallow_self_replacement
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
new_contact_id: 'william-001' },
{ 'HTTP_AUTHORIZATION' => http_auth_key }
patch '/repp/v1/domains/contacts', params: { current_contact_id: 'william-001',
new_contact_id: 'william-001' },
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_response :bad_request
assert_equal ({ error: { type: 'invalid_request_error',
message: 'New contact ID must be different from current contact ID' } }),

View file

@ -4,11 +4,17 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
setup do
@domain = domains(:shop)
@new_registrar = registrars(:goodnames)
@original_transfer_wait_time = Setting.transfer_wait_time
Setting.transfer_wait_time = 0 # Auto-approval
end
teardown do
Setting.transfer_wait_time = @original_transfer_wait_time
end
def test_returns_domain_transfers
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
post '/repp/v1/domain_transfers', params: request_params, as: :json,
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_response 200
assert_equal ({ data: [{
type: 'domain_transfer',
@ -21,17 +27,20 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
def test_creates_new_domain_transfer
assert_difference -> { @domain.transfers.size } do
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
post '/repp/v1/domain_transfers', params: request_params, as: :json,
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
end
end
def test_approves_automatically_if_auto_approval_is_enabled
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
post '/repp/v1/domain_transfers', params: request_params, as: :json,
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert @domain.transfers.last.approved?
end
def test_assigns_new_registrar
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
post '/repp/v1/domain_transfers', params: request_params, as: :json,
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
@domain.reload
assert_equal @new_registrar, @domain.registrar
end
@ -39,7 +48,8 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
def test_regenerates_transfer_code
@old_transfer_code = @domain.transfer_code
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
post '/repp/v1/domain_transfers', params: request_params, as: :json,
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
@domain.reload
refute_equal @domain.transfer_code, @old_transfer_code
end
@ -48,34 +58,41 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
@old_registrar = @domain.registrar
assert_difference -> { @old_registrar.notifications.count } do
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
post '/repp/v1/domain_transfers', params: request_params, as: :json,
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
end
end
def test_duplicates_registrant_admin_and_tech_contacts
assert_difference -> { @new_registrar.contacts.size }, 3 do
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
post '/repp/v1/domain_transfers', params: request_params, as: :json,
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
end
end
def test_reuses_identical_contact
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
post '/repp/v1/domain_transfers', params: request_params, as: :json,
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_equal 1, @new_registrar.contacts.where(name: 'William').size
end
def test_fails_if_domain_does_not_exist
request_params = { format: :json,
data: { domainTransfers: [{ domainName: 'non-existent.test', transferCode: 'any' }] } }
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
post '/repp/v1/domain_transfers',
params: { data: { domainTransfers: [{ domainName: 'non-existent.test',
transferCode: 'any' }] } },
as: :json,
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_response 400
assert_equal ({ errors: [{ title: 'non-existent.test does not exist' }] }),
JSON.parse(response.body, symbolize_names: true)
end
def test_fails_if_transfer_code_is_wrong
request_params = { format: :json,
data: { domainTransfers: [{ domainName: 'shop.test', transferCode: 'wrong' }] } }
post '/repp/v1/domain_transfers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
post '/repp/v1/domain_transfers',
params: { data: { domainTransfers: [{ domainName: 'shop.test',
transferCode: 'wrong' }] } },
as: :json,
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_response 400
refute_equal @new_registrar, @domain.registrar
assert_equal ({ errors: [{ title: 'shop.test transfer code is wrong' }] }),
@ -85,8 +102,7 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
private
def request_params
{ format: :json,
data: { domainTransfers: [{ domainName: 'shop.test', transferCode: '65078d5' }] } }
{ data: { domainTransfers: [{ domainName: 'shop.test', transferCode: '65078d5' }] } }
end
def http_auth_key

View file

@ -5,18 +5,23 @@ class APINameserversPutTest < ApplicationIntegrationTest
old_nameserver_ids = [nameservers(:shop_ns1).id,
nameservers(:airport_ns1).id,
nameservers(:metro_ns1).id]
request_params = { format: :json, data: { type: 'nameserver', id: 'ns1.bestnames.test',
attributes: { hostname: 'ns55.bestnames.test' } } }
put '/repp/v1/registrar/nameservers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_empty (old_nameserver_ids & registrars(:bestnames).nameservers(true).ids)
params = { data: { type: 'nameserver',
id: 'ns1.bestnames.test',
attributes: { hostname: 'ns55.bestnames.test' } } }
put '/repp/v1/registrar/nameservers', params: params, as: :json,
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_empty (old_nameserver_ids & registrars(:bestnames).nameservers.reload.ids)
end
def test_saves_all_attributes
request_params = { format: :json, data: { type: 'nameserver', id: 'ns1.bestnames.test',
attributes: { hostname: 'ns55.bestnames.test',
ipv4: ['192.0.2.55'],
ipv6: ['2001:db8::55'] } } }
put '/repp/v1/registrar/nameservers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
params = { data: { type: 'nameserver', id: 'ns1.bestnames.test',
attributes: { hostname: 'ns55.bestnames.test',
ipv4: ['192.0.2.55'],
ipv6: ['2001:db8::55'] } } }
put '/repp/v1/registrar/nameservers', params: params, as: :json,
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
new_nameserver = domains(:shop).nameservers.find_by(hostname: 'ns55.bestnames.test')
assert_equal ['192.0.2.55'], new_nameserver.ipv4
@ -24,52 +29,60 @@ class APINameserversPutTest < ApplicationIntegrationTest
end
def test_keeps_other_nameserver_intact
request_params = { format: :json, data: { type: 'nameserver', id: 'ns1.bestnames.test',
attributes: { hostname: 'ns55.bestnames.test' } } }
params = { data: { type: 'nameserver', id: 'ns1.bestnames.test',
attributes: { hostname: 'ns55.bestnames.test' } } }
other_nameserver_hash = nameservers(:shop_ns2).attributes
put '/repp/v1/registrar/nameservers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
put '/repp/v1/registrar/nameservers', params: params, as: :json,
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_equal other_nameserver_hash, nameservers(:shop_ns2).reload.attributes
end
def test_keeps_other_registrar_nameservers_intact
request_params = { format: :json, data: { type: 'nameserver', id: 'ns1.bestnames.test',
attributes: { hostname: 'ns55.bestnames.test' } } }
params = { data: { type: 'nameserver', id: 'ns1.bestnames.test',
attributes: { hostname: 'ns55.bestnames.test' } } }
nameserver_hash = nameservers(:metro_ns1).attributes
put '/repp/v1/registrar/nameservers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
put '/repp/v1/registrar/nameservers', params: params, as: :json,
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_equal nameserver_hash, nameservers(:metro_ns1).reload.attributes
end
def test_returns_new_nameserver_record_and_affected_domain
request_params = { format: :json, data: { type: 'nameserver', id: 'ns1.bestnames.test',
attributes: { hostname: 'ns55.bestnames.test',
ipv4: ['192.0.2.55'],
ipv6: ['2001:db8::55'] } } }
params = { data: { type: 'nameserver', id: 'ns1.bestnames.test',
attributes: { hostname: 'ns55.bestnames.test',
ipv4: ['192.0.2.55'],
ipv6: ['2001:db8::55'] } } }
put '/repp/v1/registrar/nameservers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
put '/repp/v1/registrar/nameservers', params: params, as: :json,
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_response 200
assert_equal ({ data: { type: 'nameserver',
id: 'ns55.bestnames.test',
attributes: { hostname: 'ns55.bestnames.test',
ipv4: ['192.0.2.55'],
ipv6: ['2001:db8::55'] }},
ipv6: ['2001:db8::55'] } },
affected_domains: ["airport.test", "shop.test"] }),
JSON.parse(response.body, symbolize_names: true)
end
def test_optional_params
request_params = { format: :json, data: { type: 'nameserver', id: 'ns1.bestnames.test',
attributes: { hostname: 'ns55.bestnames.test' } } }
put '/repp/v1/registrar/nameservers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
params = { data: { type: 'nameserver', id: 'ns1.bestnames.test',
attributes: { hostname: 'ns55.bestnames.test' } } }
put '/repp/v1/registrar/nameservers', params: params, as: :json,
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_response 200
end
def test_non_existent_nameserver_hostname
request_params = { format: :json, data: { type: 'nameserver', id: 'non-existent.test',
attributes: { hostname: 'any.bestnames.test' } } }
put '/repp/v1/registrar/nameservers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
params = { data: { type: 'nameserver', id: 'non-existent.test',
attributes: { hostname: 'any.bestnames.test' } } }
put '/repp/v1/registrar/nameservers', params: params, as: :json,
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_response 404
assert_equal ({ errors: [{ title: 'Hostname non-existent.test does not exist' }] }),
@ -77,9 +90,10 @@ class APINameserversPutTest < ApplicationIntegrationTest
end
def test_invalid_request_params
request_params = { format: :json, data: { type: 'nameserver', id: 'ns1.bestnames.test',
attributes: { hostname: '' } } }
put '/repp/v1/registrar/nameservers', request_params, { 'HTTP_AUTHORIZATION' => http_auth_key }
params = { data: { type: 'nameserver', id: 'ns1.bestnames.test',
attributes: { hostname: '' } } }
put '/repp/v1/registrar/nameservers', params: params, as: :json,
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_response 400
assert_equal ({ errors: [{ title: 'Hostname is missing' }] }),

View file

@ -20,7 +20,7 @@ class RegistrantApiAuthenticationTest < ApplicationIntegrationTest
last_name: 'Smith',
}
post '/api/v1/registrant/auth/eid', params
post '/api/v1/registrant/auth/eid', params: params
assert(User.find_by(registrant_ident: 'EE-30110100103'))
json = JSON.parse(response.body, symbolize_names: true)
@ -29,7 +29,7 @@ class RegistrantApiAuthenticationTest < ApplicationIntegrationTest
def test_request_returns_existing_user
assert_no_changes User.count do
post '/api/v1/registrant/auth/eid', @user_hash
post '/api/v1/registrant/auth/eid', params: @user_hash
end
end
@ -38,7 +38,7 @@ class RegistrantApiAuthenticationTest < ApplicationIntegrationTest
@original_whitelist_ip = ENV['registrant_api_auth_allowed_ips']
ENV['registrant_api_auth_allowed_ips'] = '1.2.3.4'
post '/api/v1/registrant/auth/eid', params
post '/api/v1/registrant/auth/eid', params: params
assert_equal(401, response.status)
json_body = JSON.parse(response.body, symbolize_names: true)
@ -50,7 +50,7 @@ class RegistrantApiAuthenticationTest < ApplicationIntegrationTest
def test_request_documented_parameters_are_required
params = { foo: :bar, test: :test }
post '/api/v1/registrant/auth/eid', params
post '/api/v1/registrant/auth/eid', params: params
json = JSON.parse(response.body, symbolize_names: true)
assert_equal({ errors: [{ ident: ['parameter is required'] }] }, json)
assert_equal(422, response.status)

View file

@ -12,20 +12,21 @@ class RegistrantApiContactsTest < ApplicationIntegrationTest
def test_root_accepts_limit_and_offset_parameters
contacts(:william).update!(ident: '1234', ident_type: 'priv', ident_country_code: 'US')
assert_equal 3, @user.contacts.size
assert_equal 4, @user.contacts.size
get '/api/v1/registrant/contacts', { 'limit' => 1, 'offset' => 0 }, @auth_headers
get '/api/v1/registrant/contacts', params: { 'limit' => 1, 'offset' => 0 },
headers: @auth_headers
response_json = JSON.parse(response.body, symbolize_names: true)
assert_equal(200, response.status)
assert_equal(1, response_json.count)
get '/api/v1/registrant/contacts', {}, @auth_headers
get '/api/v1/registrant/contacts', headers: @auth_headers
response_json = JSON.parse(response.body, symbolize_names: true)
assert_equal(3, response_json.count)
assert_equal(@user.contacts.size, response_json.count)
end
def test_get_contact_details_by_uuid
get api_v1_registrant_contact_path(@contact.uuid), nil, @auth_headers
get api_v1_registrant_contact_path(@contact.uuid), headers: @auth_headers
assert_response :ok
response_json = JSON.parse(response.body, symbolize_names: true)
@ -33,21 +34,23 @@ class RegistrantApiContactsTest < ApplicationIntegrationTest
end
def test_root_does_not_accept_limit_higher_than_200
get '/api/v1/registrant/contacts', { 'limit' => 400, 'offset' => 0 }, @auth_headers
get '/api/v1/registrant/contacts', params: { 'limit' => 400, 'offset' => 0 },
headers: @auth_headers
assert_equal(400, response.status)
response_json = JSON.parse(response.body, symbolize_names: true)
assert_equal({ errors: [{ limit: ['parameter is out of range'] }] }, response_json)
end
def test_root_does_not_accept_offset_lower_than_0
get '/api/v1/registrant/contacts', { 'limit' => 200, 'offset' => "-10" }, @auth_headers
get '/api/v1/registrant/contacts', params: { 'limit' => 200, 'offset' => "-10" },
headers: @auth_headers
assert_equal(400, response.status)
response_json = JSON.parse(response.body, symbolize_names: true)
assert_equal({ errors: [{ offset: ['parameter is out of range'] }] }, response_json)
end
def test_root_returns_401_without_authorization
get '/api/v1/registrant/contacts', {}, {}
get '/api/v1/registrant/contacts'
assert_equal(401, response.status)
json_body = JSON.parse(response.body, symbolize_names: true)

View file

@ -2,13 +2,13 @@ require 'test_helper'
class RegistrantApiCorsHeadersTest < ApplicationIntegrationTest
def test_returns_200_response_code_for_options_request
options '/api/v1/registrant/auth/eid', {}, { 'Origin' => 'https://example.com' }
process :options, api_v1_registrant_auth_eid_path,
headers: { 'Origin' => 'https://example.com' }
assert_equal('200', response.code)
end
def test_returns_expected_headers_for_options_requests
options '/api/v1/registrant/auth/eid', {}, { 'Origin' => 'https://example.com' }
process :options, api_v1_registrant_auth_eid_path, headers: { 'Origin' => 'https://example.com' }
assert_equal('https://example.com', response.headers['Access-Control-Allow-Origin'])
assert_equal('POST, GET, PUT, PATCH, DELETE, OPTIONS',
@ -20,16 +20,15 @@ class RegistrantApiCorsHeadersTest < ApplicationIntegrationTest
end
def test_returns_empty_body
options '/api/v1/registrant/auth/eid', { 'Origin' => 'https://example.com' }
process :options, api_v1_registrant_auth_eid_path, headers: { 'Origin' => 'https://example.com' }
assert_equal('', response.body)
end
def test_it_returns_cors_headers_for_other_requests
post '/api/v1/registrant/auth/eid', {}, { 'Origin' => 'https://example.com' }
post '/api/v1/registrant/auth/eid', headers: { 'Origin' => 'https://example.com' }
assert_equal('https://example.com', response.headers['Access-Control-Allow-Origin'])
get '/api/v1/registrant/contacts', {}, { 'Origin' => 'https://example.com' }
get '/api/v1/registrant/contacts', headers: { 'Origin' => 'https://example.com' }
assert_equal('https://example.com', response.headers['Access-Control-Allow-Origin'])
end
end

View file

@ -12,7 +12,7 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
end
def test_get_domain_details_by_uuid
get '/api/v1/registrant/domains/5edda1a5-3548-41ee-8b65-6d60daf85a37', {}, @auth_headers
get '/api/v1/registrant/domains/5edda1a5-3548-41ee-8b65-6d60daf85a37', headers: @auth_headers
assert_equal(200, response.status)
domain = JSON.parse(response.body, symbolize_names: true)
@ -20,17 +20,25 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
assert_equal('hospital.test', domain[:name])
assert_equal('5edda1a5-3548-41ee-8b65-6d60daf85a37', domain[:id])
assert_equal({name: 'John', id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957'}, domain[:registrant])
assert_equal([{name: 'John', id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957'}],
assert_equal([{name: 'John',
id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957',
email: 'john@inbox.test'}],
domain[:admin_contacts])
assert_equal([{name: 'John', id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957'}],
assert_equal([{name: 'John',
id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957',
email: 'john@inbox.test'}],
domain[:tech_contacts])
assert_equal({ name: 'Good Names', website: nil }, domain[:registrar])
assert_equal([], domain[:nameservers])
assert_equal([], domain[:dnssec_keys])
assert(domain.has_key?(:dnssec_changed_at))
assert(domain.has_key?(:locked_by_registrant_at))
end
def test_get_non_existent_domain_details_by_uuid
get '/api/v1/registrant/domains/random-uuid', {}, @auth_headers
get '/api/v1/registrant/domains/random-uuid', headers: @auth_headers
assert_equal(404, response.status)
response_json = JSON.parse(response.body, symbolize_names: true)
@ -38,7 +46,7 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
end
def test_root_returns_domain_list
get '/api/v1/registrant/domains', {}, @auth_headers
get '/api/v1/registrant/domains', headers: @auth_headers
assert_equal(200, response.status)
response_json = JSON.parse(response.body, symbolize_names: true)
@ -50,20 +58,22 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
end
def test_root_accepts_limit_and_offset_parameters
get '/api/v1/registrant/domains', { 'limit' => 2, 'offset' => 0 }, @auth_headers
get '/api/v1/registrant/domains', params: { 'limit' => 2, 'offset' => 0 },
headers: @auth_headers
response_json = JSON.parse(response.body, symbolize_names: true)
assert_equal(200, response.status)
assert_equal(2, response_json.count)
get '/api/v1/registrant/domains', {}, @auth_headers
get '/api/v1/registrant/domains', headers: @auth_headers
response_json = JSON.parse(response.body, symbolize_names: true)
assert_equal(4, response_json.count)
end
def test_root_does_not_accept_limit_higher_than_200
get '/api/v1/registrant/domains', { 'limit' => 400, 'offset' => 0 }, @auth_headers
get '/api/v1/registrant/domains', params: { 'limit' => 400, 'offset' => 0 },
headers: @auth_headers
assert_equal(400, response.status)
response_json = JSON.parse(response.body, symbolize_names: true)
@ -71,7 +81,8 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
end
def test_root_does_not_accept_offset_lower_than_0
get '/api/v1/registrant/domains', { 'limit' => 200, 'offset' => "-10" }, @auth_headers
get '/api/v1/registrant/domains', params: { 'limit' => 200, 'offset' => "-10" },
headers: @auth_headers
assert_equal(400, response.status)
response_json = JSON.parse(response.body, symbolize_names: true)
@ -79,7 +90,7 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
end
def test_root_returns_401_without_authorization
get '/api/v1/registrant/domains', {}, {}
get '/api/v1/registrant/domains'
assert_equal(401, response.status)
json_body = JSON.parse(response.body, symbolize_names: true)
@ -87,7 +98,7 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
end
def test_details_returns_401_without_authorization
get '/api/v1/registrant/domains/5edda1a5-3548-41ee-8b65-6d60daf85a37', {}, {}
get '/api/v1/registrant/domains/5edda1a5-3548-41ee-8b65-6d60daf85a37'
assert_equal(401, response.status)
json_body = JSON.parse(response.body, symbolize_names: true)

View file

@ -12,7 +12,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
def test_can_lock_a_not_locked_domain
post '/api/v1/registrant/domains/2df2c1a1-8f6a-490a-81be-8bdf29866880/registry_lock',
{}, @auth_headers
headers: @auth_headers
response_json = JSON.parse(response.body, symbolize_names: true)
@ -27,7 +27,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
def test_locking_a_domain_creates_a_version_record
assert_difference '@domain.versions.count', 1 do
post '/api/v1/registrant/domains/2df2c1a1-8f6a-490a-81be-8bdf29866880/registry_lock',
{}, @auth_headers
headers: @auth_headers
end
@domain.reload
@ -39,7 +39,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
@domain.save
post '/api/v1/registrant/domains/2df2c1a1-8f6a-490a-81be-8bdf29866880/registry_lock',
{}, @auth_headers
headers: @auth_headers
response_json = JSON.parse(response.body, symbolize_names: true)
assert_equal(422, response.status)
@ -51,7 +51,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
assert(@domain.locked_by_registrant?)
post '/api/v1/registrant/domains/2df2c1a1-8f6a-490a-81be-8bdf29866880/registry_lock',
{}, @auth_headers
headers: @auth_headers
response_json = JSON.parse(response.body, symbolize_names: true)
assert_equal(422, response.status)
@ -62,7 +62,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
@domain.apply_registry_lock
delete '/api/v1/registrant/domains/2df2c1a1-8f6a-490a-81be-8bdf29866880/registry_lock',
{}, @auth_headers
headers: @auth_headers
response_json = JSON.parse(response.body, symbolize_names: true)
assert(response_json[:statuses].include?(DomainStatus::OK))
@ -73,7 +73,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
def test_cannot_unlock_a_not_locked_domain
delete '/api/v1/registrant/domains/2df2c1a1-8f6a-490a-81be-8bdf29866880/registry_lock',
{}, @auth_headers
headers: @auth_headers
response_json = JSON.parse(response.body, symbolize_names: true)
assert_equal(422, response.status)
@ -81,8 +81,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
end
def test_returns_404_when_domain_is_not_found
post '/api/v1/registrant/domains/random-uuid/registry_lock',
{}, @auth_headers
post '/api/v1/registrant/domains/random-uuid/registry_lock', headers: @auth_headers
response_json = JSON.parse(response.body, symbolize_names: true)
assert_equal(404, response.status)
@ -99,7 +98,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
assert_equal '1234', contact.ident
assert_equal 'US', contact.ident_country_code
post api_v1_registrant_domain_registry_lock_path(domain.uuid), nil, @auth_headers
post api_v1_registrant_domain_registry_lock_path(domain.uuid), headers: @auth_headers
assert_response :unauthorized
response_json = JSON.parse(response.body, symbolize_names: true)
@ -109,7 +108,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
def test_registrant_can_lock_a_domain
post '/api/v1/registrant/domains/1b3ee442-e8fe-4922-9492-8fcb9dccc69c/registry_lock',
{}, @auth_headers
headers: @auth_headers
assert_equal(200, response.status)
response_json = JSON.parse(response.body, symbolize_names: true)
@ -125,16 +124,25 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
assert_equal 'https://bestnames.test', @domain.registrar.website
post '/api/v1/registrant/domains/1b3ee442-e8fe-4922-9492-8fcb9dccc69c/registry_lock',
{}, @auth_headers
headers: @auth_headers
assert_equal(200, response.status)
response_json = JSON.parse(response.body, symbolize_names: true)
assert_equal({ name: 'Best Names', website: 'https://bestnames.test' }, response_json[:registrar])
assert_equal({name: 'John', id: 'eb2f2766-b44c-4e14-9f16-32ab1a7cb957'}, response_json[:registrant])
assert_equal([{name: 'Jane', id: '9db3de62-2414-4487-bee2-d5c155567768'}], response_json[:admin_contacts])
assert_equal([{name: 'William', id: '0aa54704-d6f7-4ca9-b8ca-2827d9a4e4eb'},
{name: 'Acme Ltd', id: 'f1dd365c-5be9-4b3d-a44e-3fa002465e4d'}].to_set,
assert_equal([{name: 'Jane',
id: '9db3de62-2414-4487-bee2-d5c155567768',
email: 'jane@mail.test'
}],
response_json[:admin_contacts])
assert_equal([{name: 'William',
id: '0aa54704-d6f7-4ca9-b8ca-2827d9a4e4eb',
email: 'william@inbox.test'},
{name: 'Acme Ltd',
id: 'f1dd365c-5be9-4b3d-a44e-3fa002465e4d',
email: 'acme@outlook.test'
}].to_set,
response_json[:tech_contacts].to_set)
assert_equal(
[{hostname: 'ns1.bestnames.test', ipv4: ['192.0.2.1'], ipv6: ['2001:db8::1']},

View file

@ -15,18 +15,21 @@ class ApiV1AuctionDetailsTest < ActionDispatch::IntegrationTest
assert_equal 'auction.test', @auction.domain
assert_equal Auction.statuses[:no_bids], @auction.status
get api_v1_auction_path(@auction.uuid), nil, 'Content-Type' => Mime::JSON.to_s
get api_v1_auction_path(@auction.uuid), as: :json
assert_response :ok
assert_equal ({ 'id' => '1b3ee442-e8fe-4922-9492-8fcb9dccc69c',
'domain' => 'auction.test',
'status' => Auction.statuses[:no_bids] }), ActiveSupport::JSON
.decode(response.body)
.decode(response.body)
end
def test_auction_not_found
assert_raises ActiveRecord::RecordNotFound do
get api_v1_auction_path('non-existing-uuid'), nil, 'Content-Type' => Mime::JSON.to_s
end
expected_uuid = 'not-a-real-path'
get api_v1_auction_path(expected_uuid), as: :json
assert_response :not_found
json = JSON.parse(response.body, symbolize_names: true)
assert_equal expected_uuid, json[:uuid]
assert_equal 'Not Found', json[:error]
end
end
end

View file

@ -10,19 +10,19 @@ class ApiV1AuctionListTest < ActionDispatch::IntegrationTest
domain: 'auction.test',
status: Auction.statuses[:started])
get api_v1_auctions_path, nil, 'Content-Type' => Mime::JSON.to_s
get api_v1_auctions_path, as: :json
assert_response :ok
assert_equal ([{ 'id' => '1b3ee442-e8fe-4922-9492-8fcb9dccc69c',
'domain' => 'auction.test',
'status' => Auction.statuses[:started] }]), ActiveSupport::JSON
.decode(response.body)
.decode(response.body)
end
def test_does_not_return_finished_auctions
@auction.update!(domain: 'auction.test', status: Auction.statuses[:awaiting_payment])
get api_v1_auctions_path, nil, 'Content-Type' => Mime::JSON.to_s
get api_v1_auctions_path, as: :json
assert_response :ok
assert_empty ActiveSupport::JSON.decode(response.body)

View file

@ -20,47 +20,64 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
assert_equal '1b3ee442-e8fe-4922-9492-8fcb9dccc69c', @auction.uuid
assert_equal 'auction.test', @auction.domain
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:awaiting_payment] }
.to_json, 'Content-Type' => Mime::JSON.to_s
patch api_v1_auction_path(@auction.uuid),
params: { status: Auction.statuses[:awaiting_payment] },
as: :json
assert_response :ok
assert_equal ({ 'id' => '1b3ee442-e8fe-4922-9492-8fcb9dccc69c',
'domain' => 'auction.test',
'status' => Auction.statuses[:awaiting_payment] }), ActiveSupport::JSON
.decode(response.body)
.decode(response.body)
end
def test_marks_as_awaiting_payment
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:awaiting_payment] }
.to_json, 'Content-Type' => Mime::JSON.to_s
patch api_v1_auction_path(@auction.uuid),
params: { status: Auction.statuses[:awaiting_payment] },
as: :json
@auction.reload
assert @auction.awaiting_payment?
end
def test_sets_registration_deadline
deadline = (Time.zone.now + 10.days).end_of_day
patch api_v1_auction_path(@auction.uuid),
params: { status: Auction.statuses[:awaiting_payment],
registration_deadline: deadline},
as: :json
@auction.reload
assert_in_delta @auction.registration_deadline, deadline, 1.second
end
def test_marks_as_no_bids
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:no_bids] }
.to_json, 'Content-Type' => Mime::JSON.to_s
patch api_v1_auction_path(@auction.uuid),
params: { status: Auction.statuses[:no_bids] },
as: :json
@auction.reload
assert @auction.no_bids?
end
def test_marks_as_payment_received
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_received] }
.to_json, 'Content-Type' => Mime::JSON.to_s
patch api_v1_auction_path(@auction.uuid),
params: { status: Auction.statuses[:payment_received] },
as: :json
@auction.reload
assert @auction.payment_received?
end
def test_marks_as_payment_not_received
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_not_received] }
.to_json, 'Content-Type' => Mime::JSON.to_s
patch api_v1_auction_path(@auction.uuid),
params: { status: Auction.statuses[:payment_not_received] },
as: :json
@auction.reload
assert @auction.payment_not_received?
end
def test_marks_as_domain_not_registered
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:domain_not_registered] }
.to_json, 'Content-Type' => Mime::JSON.to_s
patch api_v1_auction_path(@auction.uuid),
params: { status: Auction.statuses[:domain_not_registered] },
as: :json
@auction.reload
assert @auction.domain_not_registered?
end
@ -69,8 +86,9 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
@auction.update!(registration_code: 'auction-001',
status: Auction.statuses[:awaiting_payment])
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_received] }
.to_json, 'Content-Type' => Mime::JSON.to_s
patch api_v1_auction_path(@auction.uuid),
params: { status: Auction.statuses[:payment_received] },
as: :json
response_json = ActiveSupport::JSON.decode(response.body)
assert_not_nil response_json['registration_code']
@ -79,8 +97,9 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
def test_conceals_registration_code_when_payment_is_not_received
@auction.update!(status: Auction.statuses[:awaiting_payment])
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_not_received] }
.to_json, 'Content-Type' => Mime::JSON.to_s
patch api_v1_auction_path(@auction.uuid),
params: { status: Auction.statuses[:payment_not_received] },
as: :json
response_json = ActiveSupport::JSON.decode(response.body)
assert_nil response_json['registration_code']
@ -91,8 +110,9 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
assert_equal 'auction.test', @auction.domain
@whois_record.update!(updated_at: '2010-07-04')
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_received] }
.to_json, 'Content-Type' => Mime::JSON.to_s
patch api_v1_auction_path(@auction.uuid),
params: { status: Auction.statuses[:payment_received] },
as: :json
@whois_record.reload
assert_equal Time.zone.parse('2010-07-05 10:00'), @whois_record.updated_at
@ -103,8 +123,9 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
assert_equal 'auction.test', @auction.domain
@whois_record.delete
patch api_v1_auction_path(@auction.uuid), { status: Auction.statuses[:payment_received] }
.to_json, 'Content-Type' => Mime::JSON.to_s
patch api_v1_auction_path(@auction.uuid),
params: { status: Auction.statuses[:payment_received] },
as: :json
new_whois_record = Whois::Record.find_by(name: @auction.domain)
assert_equal Time.zone.parse('2010-07-05 10:00'), new_whois_record.updated_at
@ -114,16 +135,20 @@ class ApiV1AuctionUpdateTest < ActionDispatch::IntegrationTest
def test_inaccessible_when_ip_address_is_not_allowed
ENV['auction_api_allowed_ips'] = ''
patch api_v1_auction_path(@auction.uuid), { status: 'any' }.to_json,
'Content-Type' => Mime::JSON.to_s
patch api_v1_auction_path(@auction.uuid), params: { status: 'any' }, as: :json
assert_response :unauthorized
end
def test_auction_not_found
assert_raises ActiveRecord::RecordNotFound do
patch api_v1_auction_path('non-existing-uuid'), { status: Auction.statuses[:no_bids] }.to_json,
'Content-Type' => Mime::JSON.to_s
end
expected_uuid = 'non-existing-uuid'
patch api_v1_auction_path(expected_uuid),
params: { status: Auction.statuses[:no_bids] },
as: :json
assert_response :not_found
json = JSON.parse(response.body, symbolize_names: true)
assert_equal expected_uuid, json[:uuid]
assert_equal 'Not Found', json[:error]
end
end

View file

@ -14,8 +14,8 @@ class RegistrantApiV1ContactDetailsTest < ActionDispatch::IntegrationTest
end
def test_returns_contact_details
get api_v1_registrant_contact_path(@contact.uuid), nil, 'HTTP_AUTHORIZATION' => auth_token,
'Content-Type' => Mime::JSON.to_s
get api_v1_registrant_contact_path(@contact.uuid), as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
assert_response :ok
assert_equal ({ id: @contact.uuid,
@ -43,8 +43,8 @@ class RegistrantApiV1ContactDetailsTest < ActionDispatch::IntegrationTest
end
def test_non_existent_contact
get api_v1_registrant_contact_path('non-existent'), nil, 'HTTP_AUTHORIZATION' => auth_token,
'Content-Type' => Mime::JSON.to_s
get api_v1_registrant_contact_path('non-existent'), as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
assert_response :not_found
assert_equal({ errors: [base: ['Contact not found']] }, JSON.parse(response.body,
@ -52,7 +52,7 @@ class RegistrantApiV1ContactDetailsTest < ActionDispatch::IntegrationTest
end
def test_anonymous_user
get api_v1_registrant_contact_path(@contact.uuid), nil, 'Content-Type' => Mime::JSON.to_s
get api_v1_registrant_contact_path(@contact.uuid)
assert_response :unauthorized
assert_equal({ errors: [base: ['Not authorized']] }, JSON.parse(response.body,
@ -66,8 +66,8 @@ class RegistrantApiV1ContactDetailsTest < ActionDispatch::IntegrationTest
assert_equal 'US-1234', @user.registrant_ident
CompanyRegister::Client.stub(:new, CompanyRegisterClientStub.new) do
get api_v1_registrant_contact_path(@contact.uuid), nil, 'HTTP_AUTHORIZATION' => auth_token,
'Content-Type' => Mime::JSON.to_s
get api_v1_registrant_contact_path(@contact.uuid), as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
end
response_json = JSON.parse(response.body, symbolize_names: true)
@ -75,11 +75,14 @@ class RegistrantApiV1ContactDetailsTest < ActionDispatch::IntegrationTest
end
def test_unmanaged_contact_cannot_be_accessed
assert_equal 'US-1234', @user.registrant_ident
@contact.update!(ident: '12345')
@user.update!(registrant_ident: 'US-12345')
@contact.update!(ident: '12345879')
companies = Contact.where(ident_type: 'org')
companies.update_all(ident: '78964521')
companies.reload
get api_v1_registrant_contact_path(@contact.uuid), nil, 'HTTP_AUTHORIZATION' => auth_token,
'Content-Type' => Mime::JSON.to_s
get api_v1_registrant_contact_path(@contact.uuid), as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
assert_response :not_found
response_json = JSON.parse(response.body, symbolize_names: true)
@ -93,4 +96,4 @@ class RegistrantApiV1ContactDetailsTest < ActionDispatch::IntegrationTest
hash = token_creator.token_in_hash
"Bearer #{hash[:access_token]}"
end
end
end

View file

@ -20,8 +20,7 @@ class RegistrantApiV1ContactListTest < ActionDispatch::IntegrationTest
assert_equal 'US', @contact.ident_country_code
assert_equal 'US-1234', @user.registrant_ident
get api_v1_registrant_contacts_path, nil, 'HTTP_AUTHORIZATION' => auth_token,
'Content-Type' => Mime::JSON.to_s
get api_v1_registrant_contacts_path, as: :json, headers: { 'HTTP_AUTHORIZATION' => auth_token }
response_json = JSON.parse(response.body, symbolize_names: true)
assert_equal 1, response_json.size
@ -33,12 +32,11 @@ class RegistrantApiV1ContactListTest < ActionDispatch::IntegrationTest
@contact = contacts(:acme_ltd)
assert_equal 'acme-ltd-001', @contact.code
get api_v1_registrant_contacts_path, nil, 'HTTP_AUTHORIZATION' => auth_token,
'Content-Type' => Mime::JSON.to_s
get api_v1_registrant_contacts_path, as: :json, headers: { 'HTTP_AUTHORIZATION' => auth_token }
response_json = JSON.parse(response.body, symbolize_names: true)
assert_equal 1, response_json.size
assert_equal 'acme-ltd-001', response_json.first[:code]
assert_equal @user.contacts.count, response_json.size
assert_includes response_json.map{ |hash| hash[:code] }, @contact.code
end
def test_returns_direct_contacts_when_company_register_is_unavailable
@ -48,8 +46,8 @@ class RegistrantApiV1ContactListTest < ActionDispatch::IntegrationTest
assert_equal 'US-1234', @user.registrant_ident
CompanyRegister::Client.stub(:new, CompanyRegisterClientStub.new) do
get api_v1_registrant_contacts_path, nil, 'HTTP_AUTHORIZATION' => auth_token,
'Content-Type' => Mime::JSON.to_s
get api_v1_registrant_contacts_path, as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
end
response_json = JSON.parse(response.body, symbolize_names: true)
@ -72,4 +70,4 @@ class RegistrantApiV1ContactListTest < ActionDispatch::IntegrationTest
hash = token_creator.token_in_hash
"Bearer #{hash[:access_token]}"
end
end
end

View file

@ -5,14 +5,14 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
setup do
@contact = contacts(:john)
@original_address_processing_setting = Setting.address_processing
@original_address_processing = Setting.address_processing
@original_fax_enabled_setting = ENV['fax_enabled']
@user = users(:registrant)
end
teardown do
Setting.address_processing = @original_address_processing_setting
Setting.address_processing = @original_address_processing
ENV['fax_enabled'] = @original_fax_enabled_setting
end
@ -21,12 +21,11 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
email: 'john@shop.test',
phone: '+111.1')
patch api_v1_registrant_contact_path(@contact.uuid), { name: 'William',
email: 'william@shop.test',
phone: '+222.2' }.to_json,
'HTTP_AUTHORIZATION' => auth_token,
'Accept' => Mime::JSON,
'Content-Type' => Mime::JSON.to_s
patch api_v1_registrant_contact_path(@contact.uuid), params: { name: 'William',
email: 'william@shop.test',
phone: '+222.2' },
as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
assert_response :ok
@contact.reload
@ -37,10 +36,9 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
def test_notify_registrar
assert_difference -> { @contact.registrar.notifications.count } do
patch api_v1_registrant_contact_path(@contact.uuid), { name: 'new name' }.to_json,
'HTTP_AUTHORIZATION' => auth_token,
'Accept' => Mime::JSON,
'Content-Type' => Mime::JSON.to_s
patch api_v1_registrant_contact_path(@contact.uuid), params: { name: 'new name' },
as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
end
notification = @contact.registrar.notifications.last
assert_equal 'Contact john-001 has been updated by registrant', notification.text
@ -50,10 +48,9 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
@contact.update!(fax: '+666.6')
ENV['fax_enabled'] = 'true'
patch api_v1_registrant_contact_path(@contact.uuid), { fax: '+777.7' }.to_json,
'HTTP_AUTHORIZATION' => auth_token,
'Accept' => Mime::JSON,
'Content-Type' => Mime::JSON.to_s
patch api_v1_registrant_contact_path(@contact.uuid), params: { fax: '+777.7' },
as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
assert_response :ok
@contact.reload
@ -63,10 +60,9 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
def test_fax_cannot_be_updated_when_disabled
ENV['fax_enabled'] = 'false'
patch api_v1_registrant_contact_path(@contact.uuid), { fax: '+823.7' }.to_json,
'HTTP_AUTHORIZATION' => auth_token,
'Accept' => Mime::JSON,
'Content-Type' => Mime::JSON.to_s
patch api_v1_registrant_contact_path(@contact.uuid), params: { fax: '+823.7' },
as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
assert_response :bad_request
@contact.reload
@ -80,14 +76,13 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
def test_update_address_when_enabled
Setting.address_processing = true
patch api_v1_registrant_contact_path(@contact.uuid), { address: { city: 'new city',
street: 'new street',
zip: '92837',
country_code: 'RU',
state: 'new state' } }.to_json,
'HTTP_AUTHORIZATION' => auth_token,
'Accept' => Mime::JSON,
'Content-Type' => Mime::JSON.to_s
patch api_v1_registrant_contact_path(@contact.uuid), params: { address: { city: 'new city',
street: 'new street',
zip: '92837',
country_code: 'RU',
state: 'new state' } },
as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
assert_response :ok
@contact.reload
@ -96,13 +91,12 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
end
def test_address_is_optional_when_enabled
@contact.update!(street: 'any', zip: 'any', city: 'any', state: 'any', country_code: 'US')
Setting.address_processing = true
@contact.update!(street: 'any', zip: 'any', city: 'any', state: 'any', country_code: 'US')
patch api_v1_registrant_contact_path(@contact.uuid), { name: 'any' }.to_json,
'HTTP_AUTHORIZATION' => auth_token,
'Accept' => Mime::JSON,
'Content-Type' => Mime::JSON.to_s
patch api_v1_registrant_contact_path(@contact.uuid), params: { name: 'any' },
as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
assert_response :ok
end
@ -111,11 +105,10 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
@contact.update!(street: 'old street')
Setting.address_processing = false
patch api_v1_registrant_contact_path(@contact.uuid), { address: { street: 'new street' } }
.to_json,
'HTTP_AUTHORIZATION' => auth_token,
'Accept' => Mime::JSON,
'Content-Type' => Mime::JSON.to_s
patch api_v1_registrant_contact_path(@contact.uuid),
params: { address: { street: 'new street' } },
as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
@contact.reload
assert_response :bad_request
@ -130,10 +123,10 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
@contact.update!(ident_type: Contact::PRIV,
disclosed_attributes: %w[])
patch api_v1_registrant_contact_path(@contact.uuid), { disclosed_attributes: %w[name] }.to_json,
'HTTP_AUTHORIZATION' => auth_token,
'Accept' => Mime::JSON,
'Content-Type' => Mime::JSON.to_s
patch api_v1_registrant_contact_path(@contact.uuid),
params: { disclosed_attributes: %w[name] },
as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
@contact.reload
assert_response :ok
@ -143,10 +136,10 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
def test_conceal_private_persons_data
@contact.update!(ident_type: Contact::PRIV, disclosed_attributes: %w[name])
patch api_v1_registrant_contact_path(@contact.uuid), { disclosed_attributes: [] }.to_json,
{ 'HTTP_AUTHORIZATION' => auth_token,
'Accept' => Mime::JSON,
'Content-Type' => Mime::JSON.to_s }
patch api_v1_registrant_contact_path(@contact.uuid),
params: { disclosed_attributes: [] },
as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
@contact.reload
@ -166,11 +159,10 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
assert_equal 'US-1234', @user.registrant_ident
assert_no_changes -> { @contact.disclosed_attributes } do
patch api_v1_registrant_contact_path(@contact.uuid), { disclosed_attributes: %w[name] }
.to_json,
'HTTP_AUTHORIZATION' => auth_token,
'Accept' => Mime::JSON,
'Content-Type' => Mime::JSON.to_s
patch api_v1_registrant_contact_path(@contact.uuid),
params: { disclosed_attributes: %w[name] },
as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
@contact.reload
end
assert_response :bad_request
@ -182,10 +174,9 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
end
def test_return_contact_details
patch api_v1_registrant_contact_path(@contact.uuid), { name: 'new name' }.to_json,
'HTTP_AUTHORIZATION' => auth_token,
'Accept' => Mime::JSON,
'Content-Type' => Mime::JSON.to_s
patch api_v1_registrant_contact_path(@contact.uuid), params: { name: 'new name' },
as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
assert_equal ({ id: @contact.uuid,
name: 'new name',
code: @contact.code,
@ -211,10 +202,9 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
end
def test_errors
patch api_v1_registrant_contact_path(@contact.uuid), { phone: 'invalid' }.to_json,
'HTTP_AUTHORIZATION' => auth_token,
'Accept' => Mime::JSON,
'Content-Type' => Mime::JSON.to_s
patch api_v1_registrant_contact_path(@contact.uuid), params: { phone: 'invalid' },
as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
assert_response :bad_request
assert_equal ({ errors: { phone: ['Phone nr is invalid'] } }), JSON.parse(response.body,
@ -224,11 +214,13 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
def test_unmanaged_contact_cannot_be_updated
assert_equal 'US-1234', @user.registrant_ident
@contact.update!(ident: '12345')
companies = Contact.where(ident_type: 'org')
companies.update_all(ident: '78964521')
companies.reload
patch api_v1_registrant_contact_path(@contact.uuid), { name: 'new name' }.to_json,
'HTTP_AUTHORIZATION' => auth_token,
'Accept' => Mime::JSON,
'Content-Type' => Mime::JSON.to_s
patch api_v1_registrant_contact_path(@contact.uuid), params: { name: 'new name' },
as: :json,
headers: { 'HTTP_AUTHORIZATION' => auth_token }
@contact.reload
assert_response :not_found
@ -236,7 +228,8 @@ class RegistrantApiV1ContactUpdateTest < ActionDispatch::IntegrationTest
end
def test_non_existent_contact
patch api_v1_registrant_contact_path('non-existent'), nil, 'HTTP_AUTHORIZATION' => auth_token
patch api_v1_registrant_contact_path('non-existent'),
headers: { 'HTTP_AUTHORIZATION' => auth_token }
assert_response :not_found
assert_equal ({ errors: [{ base: ['Not found'] }] }),
JSON.parse(response.body, symbolize_names: true)

View file

@ -5,7 +5,7 @@ class ContactAuditLogTest < ActionDispatch::IntegrationTest
contact = contacts(:john)
contact.legal_document_id = 1
assert_difference 'contact.versions.count' do
assert_difference 'contact.versions.count', 1 do
contact.save!
end
@ -13,4 +13,4 @@ class ContactAuditLogTest < ActionDispatch::IntegrationTest
assert_equal ({ legal_documents: [1] }).with_indifferent_access,
contact_version.children.with_indifferent_access
end
end
end

View file

@ -14,7 +14,7 @@ class DomainAuditLogTest < ActionDispatch::IntegrationTest
assert_equal registrant_id, domain.registrant_id
domain.legal_document_id = legal_document_id
assert_difference 'domain.versions.count' do
assert_difference 'domain.versions.count', 1 do
domain.save!
end
@ -26,4 +26,4 @@ class DomainAuditLogTest < ActionDispatch::IntegrationTest
assert_equal [legal_document_id], domain_version.children['legal_documents']
assert_equal [registrant_id], domain_version.children['registrant']
end
end
end

View file

@ -0,0 +1,98 @@
require 'test_helper'
class DummyEppController < Epp::BaseController
def internal_error
raise StandardError
end
end
class EppBaseTest < EppTestCase
def test_internal_error
Rails.application.routes.draw do
post 'epp/command/internal_error', to: 'dummy_epp#internal_error',
constraints: EppConstraint.new(:poll)
end
begin
assert_difference 'ApiLog::EppLog.count' do
post '/epp/command/internal_error', params: { frame: valid_request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_epp_response :command_failed
rescue
raise
ensure
Rails.application.reload_routes!
end
end
def test_validates_request_xml
invalid_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
</epp>
XML
post valid_command_path, params: { frame: invalid_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_epp_response :syntax_error
end
def test_anonymous_user
xml_of_epp_command_that_requires_authentication = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<info>
<domain:info xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{domains(:shop).name}</domain:name>
</domain:info>
</info>
</command>
</epp>
XML
post epp_info_path, params: { frame: xml_of_epp_command_that_requires_authentication },
headers: { 'HTTP_COOKIE' => 'session=non-existent' }
assert_epp_response :authorization_error
end
def test_non_authorized_user
session = epp_sessions(:api_bestnames)
user = session.user
user.update!(roles: [ApiUser::BILLING])
assert user.cannot?(:info, Domain)
xml_of_epp_command_that_requires_authorization = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<info>
<domain:info xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{domains(:shop).name}</domain:name>
</domain:info>
</info>
</command>
</epp>
XML
post epp_info_path, params: { frame: xml_of_epp_command_that_requires_authorization },
headers: { 'HTTP_COOKIE' => "session=#{session.session_id}" }
assert_epp_response :authorization_error
end
private
def valid_command_path
epp_poll_path
end
def valid_request_xml
<<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<hello/>
</epp>
XML
end
end

View file

@ -0,0 +1,22 @@
require 'test_helper'
class EppContactBaseTest < EppTestCase
def test_non_existent_contact
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<info>
<contact:info xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
<contact:id>non-existent</contact:id>
</contact:info>
</info>
</command>
</epp>
XML
post epp_info_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_epp_response :object_does_not_exist
end
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppContactCheckBaseTest < ActionDispatch::IntegrationTest
class EppContactCheckBaseTest < EppTestCase
setup do
@contact = contacts(:john)
end
@ -21,11 +21,11 @@ class EppContactCheckBaseTest < ActionDispatch::IntegrationTest
</epp>
XML
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_check_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, response_xml.css('result').size
assert_epp_response :completed_successfully
assert_equal 'john-001', response_xml.at_xpath('//contact:id', contact: xml_schema).text
end
@ -43,7 +43,8 @@ class EppContactCheckBaseTest < ActionDispatch::IntegrationTest
</epp>
XML
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_check_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '1', response_xml.at_xpath('//contact:id', contact: xml_schema)['avail']
@ -66,7 +67,8 @@ class EppContactCheckBaseTest < ActionDispatch::IntegrationTest
</epp>
XML
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_check_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '0', response_xml.at_xpath('//contact:id', contact: xml_schema)['avail']
@ -89,7 +91,8 @@ class EppContactCheckBaseTest < ActionDispatch::IntegrationTest
</epp>
XML
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_check_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal 3, response_xml.xpath('//contact:cd', contact: xml_schema).size

View file

@ -1,7 +1,11 @@
require 'test_helper'
class EppContactCreateBaseTest < ActionDispatch::IntegrationTest
def test_creates_new_contact_with_minimum_required_parameters
class EppContactCreateBaseTest < EppTestCase
def test_creates_new_contact_with_required_attributes
name = 'new'
email = 'new@registrar.test'
phone = '+1.2'
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
@ -9,7 +13,113 @@ class EppContactCreateBaseTest < ActionDispatch::IntegrationTest
<create>
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
<contact:postalInfo>
<contact:name>New</contact:name>
<contact:name>#{name}</contact:name>
</contact:postalInfo>
<contact:voice>#{phone}</contact:voice>
<contact:email>#{email}</contact:email>
</contact:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:ident type="priv" cc="US">any</eis:ident>
</eis:extdata>
</extension>
</command>
</epp>
XML
assert_difference 'Contact.count' do
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_epp_response :completed_successfully
contact = Contact.find_by(name: name)
assert_equal name, contact.name
assert_equal email, contact.email
assert_equal phone, contact.phone
assert_not_empty contact.code
end
def test_responces_error_with_email_error
name = 'new'
email = 'new@registrar@test'
phone = '+1.2'
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
<contact:postalInfo>
<contact:name>#{name}</contact:name>
</contact:postalInfo>
<contact:voice>#{phone}</contact:voice>
<contact:email>#{email}</contact:email>
</contact:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:ident type="priv" cc="US">any</eis:ident>
</eis:extdata>
</extension>
</command>
</epp>
XML
assert_no_difference 'Contact.count' do
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_epp_response :parameter_value_syntax_error
end
def test_respects_custom_code
name = 'new'
code = 'custom-id'
session = epp_sessions(:api_bestnames)
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
<contact:id>#{code}</contact:id>
<contact:postalInfo>
<contact:name>#{name}</contact:name>
</contact:postalInfo>
<contact:voice>+1.2</contact:voice>
<contact:email>any@any.test</contact:email>
</contact:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:ident type="priv" cc="US">any</eis:ident>
</eis:extdata>
</extension>
</command>
</epp>
XML
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => "session=#{session.session_id}" }
contact = Contact.find_by(name: name)
assert_equal "#{session.user.registrar.code}:#{code}".upcase, contact.code
end
def test_fails_when_required_attributes_are_missing
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
<contact:postalInfo>
<contact:name>\s</contact:name>
</contact:postalInfo>
<contact:voice>+123.4</contact:voice>
<contact:email>new@inbox.test</contact:email>
@ -24,17 +134,121 @@ class EppContactCreateBaseTest < ActionDispatch::IntegrationTest
</epp>
XML
assert_no_difference 'Contact.count' do
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_epp_response :required_parameter_missing
end
def test_does_not_save_address_when_address_processing_turned_off
name = 'new'
email = 'new@registrar.test'
phone = '+1.2'
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
<contact:postalInfo>
<contact:name>#{name}</contact:name>
<contact:addr>
<contact:street>123 Example</contact:street>
<contact:city>Tallinn</contact:city>
<contact:sp>FFF</contact:sp>
<contact:pc>123456</contact:pc>
<contact:cc>EE</contact:cc>
</contact:addr>
</contact:postalInfo>
<contact:voice>#{phone}</contact:voice>
<contact:email>#{email}</contact:email>
</contact:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:ident type="priv" cc="US">123</eis:ident>
</eis:extdata>
</extension>
</command>
</epp>
XML
assert_difference 'Contact.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
contact = Contact.last
assert_epp_response :completed_without_address
contact = Contact.find_by(name: name)
assert_equal name, contact.name
assert_equal email, contact.email
assert_equal phone, contact.phone
assert_not_empty contact.code
assert_equal 'New', contact.name
assert_equal 'new@inbox.test', contact.email
assert_equal '+123.4', contact.phone
assert_nil contact.city
assert_nil contact.street
assert_nil contact.zip
assert_nil contact.country_code
assert_nil contact.state
end
end
def test_saves_address_when_address_processing_turned_on
Setting.address_processing = true
name = 'new'
email = 'new@registrar.test'
phone = '+1.2'
street = '123 Example'
city = 'Tallinn'
state = 'Harjumaa'
zip = '123456'
country_code = 'EE'
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
<contact:postalInfo>
<contact:name>#{name}</contact:name>
<contact:addr>
<contact:street>#{street}</contact:street>
<contact:city>#{city}</contact:city>
<contact:sp>#{state}</contact:sp>
<contact:pc>#{zip}</contact:pc>
<contact:cc>#{country_code}</contact:cc>
</contact:addr>
</contact:postalInfo>
<contact:voice>#{phone}</contact:voice>
<contact:email>#{email}</contact:email>
</contact:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:ident type="priv" cc="US">123</eis:ident>
</eis:extdata>
</extension>
</command>
</epp>
XML
assert_difference 'Contact.count' do
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_epp_response :completed_successfully
contact = Contact.find_by(name: name)
assert_equal name, contact.name
assert_equal email, contact.email
assert_equal phone, contact.phone
assert_not_empty contact.code
assert_equal city, contact.city
assert_equal street, contact.street
assert_equal zip, contact.zip
assert_equal country_code, contact.country_code
assert_equal state, contact.state
end
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppContactDeleteBaseTest < ActionDispatch::IntegrationTest
class EppContactDeleteBaseTest < EppTestCase
def test_deletes_contact
contact = deletable_contact
@ -21,11 +21,10 @@ class EppContactDeleteBaseTest < ActionDispatch::IntegrationTest
XML
assert_difference 'Contact.count', -1 do
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_delete_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, response_xml.css('result').size
assert_epp_response :completed_successfully
end
def test_undeletable_cannot_be_deleted
@ -49,16 +48,16 @@ class EppContactDeleteBaseTest < ActionDispatch::IntegrationTest
XML
assert_no_difference 'Contact.count' do
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_delete_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
response_xml = Nokogiri::XML(response.body)
assert_equal '2305', response_xml.at_css('result')[:code]
assert_epp_response :object_association_prohibits_operation
end
private
def deletable_contact
Domain.update_all(registrant_id: contacts(:william))
Domain.update_all(registrant_id: contacts(:william).id)
DomainContact.delete_all
contacts(:john)
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppContactInfoBaseTest < ActionDispatch::IntegrationTest
class EppContactInfoBaseTest < EppTestCase
setup do
@contact = contacts(:john)
end
@ -29,11 +29,11 @@ class EppContactInfoBaseTest < ActionDispatch::IntegrationTest
</epp>
XML
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_info_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, response_xml.css('result').size
assert_epp_response :completed_successfully
assert_equal 'JOHN-001', response_xml.at_xpath('//contact:id', contact: xml_schema).text
assert_equal 'ok', response_xml.at_xpath('//contact:status', contact: xml_schema)['s']
assert_equal 'john@inbox.test', response_xml.at_xpath('//contact:email', contact: xml_schema)
@ -44,8 +44,12 @@ class EppContactInfoBaseTest < ActionDispatch::IntegrationTest
contact: xml_schema).text
end
def test_contact_not_found
assert_nil Contact.find_by(code: 'non-existing')
def test_hides_password_when_current_registrar_is_not_sponsoring
non_sponsoring_registrar = registrars(:goodnames)
@contact.update!(registrar: non_sponsoring_registrar)
# https://github.com/internetee/registry/issues/415
@contact.update_columns(code: @contact.code.upcase)
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
@ -53,17 +57,19 @@ class EppContactInfoBaseTest < ActionDispatch::IntegrationTest
<command>
<info>
<contact:info xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
<contact:id>non-existing</contact:id>
<contact:id>#{@contact.code}</contact:id>
</contact:info>
</info>
</command>
</epp>
XML
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_info_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' =>
'session=api_bestnames' }
assert_epp_response :completed_successfully
response_xml = Nokogiri::XML(response.body)
assert_equal '2303', response_xml.at_css('result')[:code]
assert_nil response_xml.at_xpath('//contact:authInfo', contact: xml_schema)
end
private
@ -71,4 +77,4 @@ class EppContactInfoBaseTest < ActionDispatch::IntegrationTest
def xml_schema
'https://epp.tld.ee/schema/contact-ee-1.1.xsd'
end
end
end

View file

@ -0,0 +1,24 @@
require 'test_helper'
class EppContactTransferBaseTest < EppTestCase
# https://github.com/internetee/registry/issues/676
def test_not_implemented
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<transfer op="request">
<contact:transfer xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
<contact:id>any</contact:id>
</contact:transfer>
</transfer>
</command>
</epp>
XML
post epp_transfer_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_epp_response :unimplemented
end
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppContactUpdateBaseTest < ActionDispatch::IntegrationTest
class EppContactUpdateBaseTest < EppTestCase
include ActionMailer::TestHelper
setup do
@ -37,12 +37,11 @@ class EppContactUpdateBaseTest < ActionDispatch::IntegrationTest
</epp>
XML
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
@contact.reload
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, response_xml.css('result').size
assert_epp_response :completed_successfully
assert_equal 'new name', @contact.name
assert_equal 'new-email@inbox.test', @contact.email
assert_equal '+123.4', @contact.phone
@ -71,7 +70,8 @@ class EppContactUpdateBaseTest < ActionDispatch::IntegrationTest
</epp>
XML
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_emails 1
end
@ -99,7 +99,8 @@ class EppContactUpdateBaseTest < ActionDispatch::IntegrationTest
</epp>
XML
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_no_emails
end
@ -130,7 +131,8 @@ class EppContactUpdateBaseTest < ActionDispatch::IntegrationTest
</epp>
XML
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_no_emails
end
@ -156,10 +158,171 @@ class EppContactUpdateBaseTest < ActionDispatch::IntegrationTest
</epp>
XML
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '2303', response_xml.at_css('result')[:code]
assert_epp_response :object_does_not_exist
end
def test_ident_code_cannot_be_updated
new_ident_code = '12345'
assert_not_equal new_ident_code, @contact.ident
# https://github.com/internetee/registry/issues/415
@contact.update_columns(code: @contact.code.upcase)
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<contact:update xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
<contact:id>#{@contact.code}</contact:id>
<contact:chg>
<contact:postalInfo>
</contact:postalInfo>
</contact:chg>
</contact:update>
</update>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:ident cc="#{@contact.ident_country_code}" type="#{@contact.ident_type}">#{new_ident_code}</eis:ident>
</eis:extdata>
</extension>
</command>
</epp>
XML
assert_no_changes -> { @contact.updated_at } do
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_epp_response :data_management_policy_violation
end
# https://github.com/internetee/registry/issues/576
def test_ident_type_and_ident_country_code_can_be_updated_when_absent
@contact.update_columns(ident: 'test', ident_type: nil, ident_country_code: nil)
# https://github.com/internetee/registry/issues/415
@contact.update_columns(code: @contact.code.upcase)
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<contact:update xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
<contact:id>#{@contact.code}</contact:id>
<contact:chg>
<contact:postalInfo/>
</contact:chg>
</contact:update>
</update>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:ident cc="US" type="priv">#{@contact.ident}</eis:ident>
</eis:extdata>
</extension>
</command>
</epp>
XML
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_epp_response :completed_successfully
end
def test_updates_address_when_address_processing_turned_on
@contact.update_columns(code: @contact.code.upcase)
Setting.address_processing = true
street = '123 Example'
city = 'Tallinn'
state = 'Harjumaa'
zip = '123456'
country_code = 'EE'
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<contact:update xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
<contact:id>#{@contact.code}</contact:id>
<contact:chg>
<contact:postalInfo>
<contact:addr>
<contact:street>#{street}</contact:street>
<contact:city>#{city}</contact:city>
<contact:sp>#{state}</contact:sp>
<contact:pc>#{zip}</contact:pc>
<contact:cc>#{country_code}</contact:cc>
</contact:addr>
</contact:postalInfo>
</contact:chg>
</contact:update>
</update>
</command>
</epp>
XML
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_epp_response :completed_successfully
@contact.reload
assert_equal city, @contact.city
assert_equal street, @contact.street
assert_equal zip, @contact.zip
assert_equal country_code, @contact.country_code
assert_equal state, @contact.state
end
def test_does_not_update_address_when_address_processing_turned_off
@contact.update_columns(code: @contact.code.upcase)
street = '123 Example'
city = 'Tallinn'
state = 'Harjumaa'
zip = '123456'
country_code = 'EE'
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<contact:update xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
<contact:id>#{@contact.code}</contact:id>
<contact:chg>
<contact:postalInfo>
<contact:addr>
<contact:street>#{street}</contact:street>
<contact:city>#{city}</contact:city>
<contact:sp>#{state}</contact:sp>
<contact:pc>#{zip}</contact:pc>
<contact:cc>#{country_code}</contact:cc>
</contact:addr>
</contact:postalInfo>
</contact:chg>
</contact:update>
</update>
</command>
</epp>
XML
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_epp_response :completed_without_address
@contact.reload
assert_nil @contact.city
assert_nil @contact.street
assert_nil @contact.zip
assert_nil @contact.country_code
assert_nil @contact.state
end
private
@ -167,6 +330,6 @@ class EppContactUpdateBaseTest < ActionDispatch::IntegrationTest
def make_contact_free_of_domains_where_it_acts_as_a_registrant(contact)
other_contact = contacts(:william)
assert_not_equal other_contact, contact
Domain.update_all(registrant_id: other_contact)
Domain.update_all(registrant_id: other_contact.id)
end
end
end

View file

@ -0,0 +1,22 @@
require 'test_helper'
class EppDomainBaseTest < EppTestCase
def test_non_existent_domain
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<info>
<domain:info xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>non-existent.test</domain:name>
</domain:info>
</info>
</command>
</epp>
XML
post epp_info_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_epp_response :object_does_not_exist
end
end

View file

@ -1,7 +1,7 @@
# encoding: UTF-8
require 'test_helper'
class EppDomainCheckAuctionTest < ApplicationIntegrationTest
class EppDomainCheckAuctionTest < EppTestCase
setup do
@auction = auctions(:one)
@idn_auction = auctions(:idn)
@ -28,11 +28,11 @@ class EppDomainCheckAuctionTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_check_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, response_xml.css('result').size
assert_epp_response :completed_successfully
assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
end
@ -53,11 +53,11 @@ class EppDomainCheckAuctionTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_check_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, response_xml.css('result').size
assert_epp_response :completed_successfully
assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
end
@ -78,11 +78,11 @@ class EppDomainCheckAuctionTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_check_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, response_xml.css('result').size
assert_epp_response :completed_successfully
assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
end
@ -103,11 +103,11 @@ class EppDomainCheckAuctionTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_check_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, response_xml.css('result').size
assert_epp_response :completed_successfully
assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
assert_equal 'Awaiting payment', response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
end
@ -128,11 +128,11 @@ class EppDomainCheckAuctionTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_check_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, response_xml.css('result').size
assert_epp_response :completed_successfully
assert_equal '1', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
assert_nil response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppDomainCheckBaseTest < ApplicationIntegrationTest
class EppDomainCheckBaseTest < EppTestCase
def test_returns_valid_response
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
@ -15,11 +15,11 @@ class EppDomainCheckBaseTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_check_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, response_xml.css('result').size
assert_epp_response :completed_successfully
assert_equal 'some.test', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
end
@ -37,7 +37,8 @@ class EppDomainCheckBaseTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_check_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '1', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
@ -60,7 +61,8 @@ class EppDomainCheckBaseTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_check_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '1', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
@ -81,7 +83,8 @@ class EppDomainCheckBaseTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_check_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
@ -104,7 +107,8 @@ class EppDomainCheckBaseTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_check_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
@ -127,7 +131,8 @@ class EppDomainCheckBaseTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_check_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
@ -150,7 +155,8 @@ class EppDomainCheckBaseTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_check_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
@ -173,7 +179,8 @@ class EppDomainCheckBaseTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_check_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal 3, response_xml.xpath('//domain:cd', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').size

View file

@ -1,7 +1,7 @@
# encoding: UTF-8
require 'test_helper'
class EppDomainCreateAuctionIdnTest < ApplicationIntegrationTest
class EppDomainCreateAuctionIdnTest < EppTestCase
def setup
super
@ -39,18 +39,15 @@ class EppDomainCreateAuctionIdnTest < ApplicationIntegrationTest
XML
assert_no_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
refute Domain.where(name: @idn_auction.domain).exists?
@idn_auction.reload
refute @idn_auction.domain_registered?
response_xml = Nokogiri::XML(response.body)
assert_equal '2003', response_xml.at_css('result')[:code]
assert_equal 'Required parameter missing; reserved>pw element is required',
response_xml.at_css('result msg').text
assert_epp_response :required_parameter_missing
end
def test_domain_with_unicode_idn_cannot_be_registered_without_registration_code
@ -77,18 +74,15 @@ class EppDomainCreateAuctionIdnTest < ApplicationIntegrationTest
XML
assert_no_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames'}
end
refute Domain.where(name: @idn_auction.domain).exists?
@idn_auction.reload
refute @idn_auction.domain_registered?
response_xml = Nokogiri::XML(response.body)
assert_equal '2003', response_xml.at_css('result')[:code]
assert_equal 'Required parameter missing; reserved>pw element is required',
response_xml.at_css('result msg').text
assert_epp_response :required_parameter_missing
end
def test_domain_with_ascii_idn_cannot_be_registered_without_winning_the_auction
@ -114,18 +108,15 @@ class EppDomainCreateAuctionIdnTest < ApplicationIntegrationTest
XML
assert_no_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames'}
end
refute Domain.where(name: @idn_auction.domain).exists?
@idn_auction.reload
refute @idn_auction.domain_registered?
response_xml = Nokogiri::XML(response.body)
assert_equal '2306', response_xml.at_css('result')[:code]
assert_equal 'Parameter value policy error: domain is at auction',
response_xml.at_css('result msg').text
assert_epp_response :parameter_value_policy_error
end
def test_domain_with_unicode_idn_cannot_be_registered_without_winning_the_auction
@ -151,55 +142,15 @@ class EppDomainCreateAuctionIdnTest < ApplicationIntegrationTest
XML
assert_no_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames'}
end
refute Domain.where(name: @idn_auction.domain).exists?
@idn_auction.reload
refute @idn_auction.domain_registered?
response_xml = Nokogiri::XML(response.body)
assert_equal '2306', response_xml.at_css('result')[:code]
assert_equal 'Parameter value policy error: domain is at auction',
response_xml.at_css('result msg').text
end
def test_domain_with_unicode_idn_cannot_be_registered_without_winning_the_auction
@idn_auction.started!
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>püramiid.test</domain:name>
<domain:registrant>#{contacts(:john).code}</domain:registrant>
</domain:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
assert_no_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
end
refute Domain.where(name: @idn_auction.domain).exists?
@idn_auction.reload
refute @idn_auction.domain_registered?
response_xml = Nokogiri::XML(response.body)
assert_equal '2306', response_xml.at_css('result')[:code]
assert_equal 'Parameter value policy error: domain is at auction',
response_xml.at_css('result msg').text
assert_epp_response :parameter_value_policy_error
end
def test_registers_unicode_domain_with_correct_registration_code_when_payment_is_received
@ -229,16 +180,14 @@ class EppDomainCreateAuctionIdnTest < ApplicationIntegrationTest
XML
assert_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames'}
end
@idn_auction.reload
assert @idn_auction.domain_registered?
assert Domain.where(name: @idn_auction.domain).exists?
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
assert_epp_response :completed_successfully
end
def test_registers_ascii_domain_with_correct_registration_code_when_payment_is_received
@ -268,15 +217,13 @@ class EppDomainCreateAuctionIdnTest < ApplicationIntegrationTest
XML
assert_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames'}
end
@idn_auction.reload
assert @idn_auction.domain_registered?
assert Domain.where(name: @idn_auction.domain).exists?
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
assert_epp_response :completed_successfully
end
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppDomainCreateAuctionTest < ApplicationIntegrationTest
class EppDomainCreateAuctionTest < EppTestCase
setup do
@auction = auctions(:one)
Domain.release_to_auction = true
@ -31,11 +31,10 @@ class EppDomainCreateAuctionTest < ApplicationIntegrationTest
XML
assert_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
assert_epp_response :completed_successfully
end
def test_registers_domain_with_correct_registration_code_after_another_auction_when_payment_is_received
@ -70,11 +69,10 @@ class EppDomainCreateAuctionTest < ApplicationIntegrationTest
XML
assert_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
assert_epp_response :completed_successfully
end
def test_registers_domain_with_correct_registration_code_when_payment_is_received
@ -104,15 +102,13 @@ class EppDomainCreateAuctionTest < ApplicationIntegrationTest
XML
assert_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
@auction.reload
assert @auction.domain_registered?
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
assert_epp_response :completed_successfully
end
def test_domain_cannot_be_registered_without_registration_code
@ -139,12 +135,10 @@ class EppDomainCreateAuctionTest < ApplicationIntegrationTest
XML
assert_no_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
response_xml = Nokogiri::XML(response.body)
assert_equal '2003', response_xml.at_css('result')[:code]
assert_equal 'Required parameter missing; reserved>pw element is required',
response_xml.at_css('result msg').text
assert_epp_response :required_parameter_missing
end
def test_domain_cannot_be_registered_with_wrong_registration_code
@ -174,12 +168,10 @@ class EppDomainCreateAuctionTest < ApplicationIntegrationTest
XML
assert_no_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
response_xml = Nokogiri::XML(response.body)
assert_equal '2202', response_xml.at_css('result')[:code]
assert_equal 'Invalid authorization information; invalid reserved>pw value',
response_xml.at_css('result msg').text
assert_epp_response :invalid_authorization_information
end
def test_domain_cannot_be_registered_when_payment_is_not_received
@ -208,12 +200,10 @@ class EppDomainCreateAuctionTest < ApplicationIntegrationTest
XML
assert_no_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
response_xml = Nokogiri::XML(response.body)
assert_equal '2003', response_xml.at_css('result')[:code]
assert_equal 'Required parameter missing; reserved>pw element required for reserved domains',
response_xml.at_css('result msg').text
assert_epp_response :required_parameter_missing
end
def test_domain_cannot_be_registered_when_at_auction
@ -238,11 +228,9 @@ class EppDomainCreateAuctionTest < ApplicationIntegrationTest
XML
assert_no_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
response_xml = Nokogiri::XML(response.body)
assert_equal '2306', response_xml.at_css('result')[:code]
assert_equal 'Parameter value policy error: domain is at auction',
response_xml.at_css('result msg').text
assert_epp_response :parameter_value_policy_error
end
end

View file

@ -1,15 +1,51 @@
require 'test_helper'
class EppDomainCreateBaseTest < ApplicationIntegrationTest
def test_domain_can_be_registered_with_required_attributes_only
class EppDomainCreateBaseTest < EppTestCase
def test_not_registers_domain_without_legaldoc
now = Time.zone.parse('2010-07-05')
travel_to now
name = "new.#{dns_zones(:one).origin}"
contact = contacts(:john)
registrant = contact.becomes(Registrant)
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>new.test</domain:name>
<domain:registrant>john-001</domain:registrant>
<domain:name>#{name}</domain:name>
<domain:registrant>#{registrant.code}</domain:registrant>
</domain:create>
</create>
</command>
</epp>
XML
assert_no_difference 'Domain.count' do
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_epp_response :required_parameter_missing
end
def test_registers_new_domain_with_required_attributes
now = Time.zone.parse('2010-07-05')
travel_to now
name = "new.#{dns_zones(:one).origin}"
contact = contacts(:john)
registrant = contact.becomes(Registrant)
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{name}</domain:name>
<domain:registrant>#{registrant.code}</domain:registrant>
</domain:create>
</create>
<extension>
@ -22,15 +58,343 @@ class EppDomainCreateBaseTest < ApplicationIntegrationTest
XML
assert_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
domain = Domain.last
assert_equal 'new.test', domain.name
assert_equal contacts(:john).becomes(Registrant), domain.registrant
assert_epp_response :completed_successfully
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
domain = Domain.find_by(name: name)
assert_equal name, domain.name
assert_equal registrant, domain.registrant
assert_equal [contact], domain.admin_contacts
assert_equal [contact], domain.tech_contacts
assert_not_empty domain.transfer_code
default_registration_period = 1.year + 1.day
assert_equal now + default_registration_period, domain.expire_time
end
def test_registers_domain_without_legaldoc_if_optout
now = Time.zone.parse('2010-07-05')
travel_to now
name = "new.#{dns_zones(:one).origin}"
contact = contacts(:john)
registrant = contact.becomes(Registrant)
registrar = registrant.registrar
registrar.legaldoc_optout = true
registrar.save(validate: false)
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{name}</domain:name>
<domain:registrant>#{registrant.code}</domain:registrant>
</domain:create>
</create>
</command>
</epp>
XML
assert_difference 'Domain.count' do
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_epp_response :completed_successfully
domain = Domain.find_by(name: name)
assert_equal name, domain.name
assert_equal registrant, domain.registrant
end
def test_does_not_registers_domain_without_legaldoc_if_mandatory
now = Time.zone.parse('2010-07-05')
travel_to now
name = "new.#{dns_zones(:one).origin}"
contact = contacts(:john)
registrant = contact.becomes(Registrant)
registrar = registrant.registrar
assert registrar.legaldoc_mandatory?
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{name}</domain:name>
<domain:registrant>#{registrant.code}</domain:registrant>
</domain:create>
</create>
</command>
</epp>
XML
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_epp_response :required_parameter_missing
Setting.legal_document_is_mandatory = false
assert_not registrar.legaldoc_mandatory?
assert_not Setting.legal_document_is_mandatory
assert_difference 'Domain.count' do
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
end
def test_registers_reserved_domain_with_registration_code
reserved_domain = reserved_domains(:one)
registration_code = reserved_domain.registration_code
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{reserved_domain.name}</domain:name>
<domain:registrant>#{contacts(:john).code}</domain:registrant>
</domain:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
<eis:reserved>
<eis:pw>#{registration_code}</eis:pw>
</eis:reserved>
</eis:extdata>
</extension>
</command>
</epp>
XML
assert_difference 'Domain.count' do
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_epp_response :completed_successfully
reserved_domain.reload
assert_not_equal registration_code, reserved_domain.registration_code
end
def test_respects_custom_transfer_code
name = "new.#{dns_zones(:one).origin}"
transfer_code = 'custom-transfer-code'
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{name}</domain:name>
<domain:registrant>#{contacts(:john).code}</domain:registrant>
<domain:authInfo>
<domain:pw>#{transfer_code}</domain:pw>
</domain:authInfo>
</domain:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_epp_response :completed_successfully
assert_equal transfer_code, Domain.find_by(name: name).transfer_code
end
def test_blocked_domain_cannot_be_registered
blocked_domain = 'blocked.test'
assert BlockedDomain.find_by(name: blocked_domain)
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{blocked_domain}</domain:name>
<domain:registrant>#{contacts(:john).code}</domain:registrant>
</domain:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
assert_no_difference 'Domain.count' do
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_epp_response :data_management_policy_violation
end
def test_blocked_punicode_domain_cannot_be_registered
blocked_domain = 'blockedäöüõ.test'
assert BlockedDomain.find_by(name: blocked_domain)
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{SimpleIDN.to_ascii('blockedäöüõ.test')}</domain:name>
<domain:registrant>#{contacts(:john).code}</domain:registrant>
</domain:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
assert_no_difference 'Domain.count' do
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_epp_response :data_management_policy_violation
end
def test_reserved_domain_cannot_be_registered_with_wrong_registration_code
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{reserved_domains(:one).name}</domain:name>
<domain:registrant>#{contacts(:john).code}</domain:registrant>
</domain:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
<eis:reserved>
<eis:pw>wrong</eis:pw>
</eis:reserved>
</eis:extdata>
</extension>
</command>
</epp>
XML
assert_no_difference 'Domain.count' do
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_epp_response :invalid_authorization_information
end
def test_reserved_domain_cannot_be_registered_without_registration_code
reserved_domain = reserved_domains(:one)
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{reserved_domain.name}</domain:name>
<domain:registrant>#{contacts(:john).code}</domain:registrant>
</domain:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
assert_no_difference 'Domain.count' do
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_epp_response :required_parameter_missing
end
def test_insufficient_funds
session = epp_sessions(:api_bestnames)
session.user.registrar.accounts.first.update!(balance: 0)
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>new.test</domain:name>
<domain:registrant>#{contacts(:john).code}</domain:registrant>
</domain:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
assert_no_difference 'Domain.count' do
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => "session=#{session.session_id}" }
end
assert_epp_response :billing_failure
end
def test_no_price
assert_nil Billing::Price.find_by(duration: '2 months')
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>new.test</domain:name>
<domain:period unit="m">2</domain:period>
<domain:registrant>john-001</domain:registrant>
</domain:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
assert_no_difference 'Domain.count' do
post epp_create_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_epp_response :billing_failure
end
end

View file

@ -1,35 +0,0 @@
require 'test_helper'
class EppDomainCreateNameserversTest < ApplicationIntegrationTest
# Glue record requirement
def test_nameserver_ip_address_is_required_if_hostname_is_under_the_same_domain
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>new.test</domain:name>
<domain:ns>
<domain:hostAttr>
<domain:hostName>ns1.new.test</domain:hostName>
</domain:hostAttr>
</domain:ns>
<domain:registrant>john-001</domain:registrant>
</domain:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">test</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
assert_no_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_equal '2003', Nokogiri::XML(response.body).at_css('result')[:code]
end
end

View file

@ -1,142 +0,0 @@
require 'test_helper'
class EppDomainCreateReservedTest < ApplicationIntegrationTest
setup do
@reserved_domain = reserved_domains(:one)
end
def test_registers_reserved_domain_with_correct_registration_code
assert_equal 'reserved.test', @reserved_domain.name
assert_equal 'reserved-001', @reserved_domain.registration_code
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>reserved.test</domain:name>
<domain:registrant>john-001</domain:registrant>
</domain:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
<eis:reserved>
<eis:pw>reserved-001</eis:pw>
</eis:reserved>
</eis:extdata>
</extension>
</command>
</epp>
XML
assert_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
end
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
end
def test_registering_reserved_domain_regenerates_registration_code
assert_equal 'reserved.test', @reserved_domain.name
assert_equal 'reserved-001', @reserved_domain.registration_code
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>reserved.test</domain:name>
<domain:registrant>john-001</domain:registrant>
</domain:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
<eis:reserved>
<eis:pw>reserved-001</eis:pw>
</eis:reserved>
</eis:extdata>
</extension>
</command>
</epp>
XML
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
@reserved_domain.reload
assert_not_equal 'reserved-001', @reserved_domain.registration_code
end
def test_domain_cannot_be_registered_with_wrong_registration_code
assert_equal 'reserved.test', @reserved_domain.name
assert_equal 'reserved-001', @reserved_domain.registration_code
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>reserved.test</domain:name>
<domain:registrant>john-001</domain:registrant>
</domain:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
<eis:reserved>
<eis:pw>wrong</eis:pw>
</eis:reserved>
</eis:extdata>
</extension>
</command>
</epp>
XML
assert_no_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
end
response_xml = Nokogiri::XML(response.body)
assert_equal '2202', response_xml.at_css('result')[:code]
assert_equal 'Invalid authorization information; invalid reserved>pw value',
response_xml.at_css('result msg').text
end
def test_domain_cannot_be_registered_without_registration_code
assert_equal 'reserved.test', @reserved_domain.name
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>reserved.test</domain:name>
<domain:registrant>john-001</domain:registrant>
</domain:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
assert_no_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
end
response_xml = Nokogiri::XML(response.body)
assert_equal '2003', response_xml.at_css('result')[:code]
assert_equal 'Required parameter missing; reserved>pw element required for reserved domains',
response_xml.at_css('result msg').text
end
end

View file

@ -1,64 +0,0 @@
require 'test_helper'
class EppDomainCreateTransferCodeTest < ApplicationIntegrationTest
setup do
travel_to Time.zone.parse('2010-07-05')
end
def test_generates_default
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>brandnew.test</domain:name>
<domain:period unit="y">1</domain:period>
<domain:registrant>john-001</domain:registrant>
</domain:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
post '/epp/command/create', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
refute_empty Domain.find_by(name: 'brandnew.test').transfer_code
assert_equal '1000', Nokogiri::XML(response.body).at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
end
def test_honors_custom
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<create>
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>brandnew.test</domain:name>
<domain:period unit="y">1</domain:period>
<domain:registrant>john-001</domain:registrant>
<domain:authInfo>
<domain:pw>1058ad73</domain:pw>
</domain:authInfo>
</domain:create>
</create>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
post '/epp/command/create', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_equal '1058ad73', Domain.find_by(name: 'brandnew.test').transfer_code
assert_equal '1000', Nokogiri::XML(response.body).at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
end
end

View file

@ -1,16 +1,16 @@
require 'test_helper'
class EppDomainDeleteBaseTest < ActionDispatch::IntegrationTest
class EppDomainDeleteBaseTest < EppTestCase
include ActionMailer::TestHelper
setup do
@domain = domains(:shop)
@original_confirmation_setting = Setting.request_confirmation_on_domain_deletion_enabled
@original_domain_delete_confirmation = Setting.request_confirmation_on_domain_deletion_enabled
ActionMailer::Base.deliveries.clear
end
teardown do
Setting.request_confirmation_on_domain_deletion_enabled = @original_confirmation_setting
Setting.request_confirmation_on_domain_deletion_enabled = @original_domain_delete_confirmation
end
def test_bypasses_domain_and_registrant_and_contacts_validation
@ -34,10 +34,9 @@ class EppDomainDeleteBaseTest < ActionDispatch::IntegrationTest
</epp>
XML
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_includes Domain.find_by(name: 'invalid.test').statuses, DomainStatus::PENDING_DELETE_CONFIRMATION
assert_equal '1001', Nokogiri::XML(response.body).at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
assert_epp_response :completed_successfully_action_pending
end
def test_discarded_domain_cannot_be_deleted
@ -63,9 +62,9 @@ class EppDomainDeleteBaseTest < ActionDispatch::IntegrationTest
XML
assert_no_difference 'Domain.count' do
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_equal '2105', Nokogiri::XML(response.body).at_css('result')[:code]
assert_epp_response :object_status_prohibits_operation
end
def test_requests_registrant_confirmation_when_required
@ -90,14 +89,13 @@ class EppDomainDeleteBaseTest < ActionDispatch::IntegrationTest
</epp>
XML
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
@domain.reload
assert @domain.registrant_verification_asked?
assert @domain.pending_delete_confirmation?
assert_emails 1
response_xml = Nokogiri::XML(response.body)
assert_equal '1001', response_xml.at_css('result')[:code]
assert_epp_response :completed_successfully_action_pending
end
def test_skips_registrant_confirmation_when_not_required
@ -122,14 +120,13 @@ class EppDomainDeleteBaseTest < ActionDispatch::IntegrationTest
</epp>
XML
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
@domain.reload
assert_not @domain.registrant_verification_asked?
assert_not @domain.pending_delete_confirmation?
assert_no_emails
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_epp_response :completed_successfully
end
def test_skips_registrant_confirmation_when_required_but_already_verified_by_registrar
@ -154,18 +151,18 @@ class EppDomainDeleteBaseTest < ActionDispatch::IntegrationTest
</epp>
XML
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
@domain.reload
assert_not @domain.registrant_verification_asked?
assert_not @domain.pending_delete_confirmation?
assert_no_emails
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_epp_response :completed_successfully
end
def test_legal_document_is_required
def test_legal_document_is_optional
assert_equal 'shop.test', @domain.name
Setting.request_confirmation_on_domain_deletion_enabled = false
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
@ -180,12 +177,9 @@ class EppDomainDeleteBaseTest < ActionDispatch::IntegrationTest
</epp>
XML
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '2003', response_xml.at_css('result')[:code]
assert_equal 'Required parameter missing: extension > extdata > legalDocument [legal_document]',
response_xml.at_css('result msg').text
assert_epp_response :completed_successfully
end
def test_domain_cannot_be_deleted_when_explicitly_prohibited_by_registrar
@ -210,38 +204,8 @@ class EppDomainDeleteBaseTest < ActionDispatch::IntegrationTest
</epp>
XML
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '2304', response_xml.at_css('result')[:code]
assert_equal 'Domain status prohibits operation', response_xml.at_css('result msg').text
assert_epp_response :object_status_prohibits_operation
end
def test_domain_not_found
assert_nil Domain.find_by(name: 'non-existing.test')
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<delete>
<domain:delete xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>non-existing.test</domain:name>
</domain:delete>
</delete>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">dGVzdCBmYWlsCg==</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
response_xml = Nokogiri::XML(response.body)
assert_equal '2303', response_xml.at_css('result')[:code]
assert_equal 'Domain not found', response_xml.at_css('result msg').text
end
end
end

View file

@ -1,32 +0,0 @@
require 'test_helper'
class EppDomainRenewTest < ApplicationIntegrationTest
self.use_transactional_fixtures = false
setup do
travel_to Time.zone.parse('2010-07-05')
end
def test_domain_cannot_be_renewed_when_invalid
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<renew>
<domain:renew xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>invalid.test</domain:name>
<domain:curExpDate>2010-07-05</domain:curExpDate>
<domain:period unit="m">1</domain:period>
</domain:renew>
</renew>
</command>
</epp>
XML
assert_no_changes -> { domains(:invalid).valid_to } do
post '/epp/command/renew', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
end
assert_equal '2304', Nokogiri::XML(response.body).at_css('result')[:code],
Nokogiri::XML(response.body).css('result').text
end
end

View file

@ -1,54 +0,0 @@
require 'test_helper'
class EppDomainUpdateTest < ApplicationIntegrationTest
def setup
@domain = domains(:shop)
end
def test_update_domain
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>shop.test</domain:name>
<domain:chg>
<domain:authInfo>
<domain:pw>f0ff7d17b0</domain:pw>
</domain:authInfo>
</domain:chg>
</domain:update>
</update>
</command>
</epp>
XML
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
@domain.reload
assert_equal 'f0ff7d17b0', @domain.transfer_code
assert_equal '1000', Nokogiri::XML(response.body).at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
end
def test_discarded_domain_cannot_be_updated
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>shop.test</domain:name>
</domain:update>
</update>
</command>
</epp>
XML
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
assert_equal '2105', Nokogiri::XML(response.body).at_css('result')[:code]
travel_back
end
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppDomainInfoBaseTest < ApplicationIntegrationTest
class EppDomainInfoBaseTest < EppTestCase
def test_returns_valid_response
assert_equal 'john-001', contacts(:john).code
domains(:shop).update_columns(statuses: [DomainStatus::OK],
@ -21,11 +21,11 @@ class EppDomainInfoBaseTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_info_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, response_xml.css('result').size
assert_epp_response :completed_successfully
assert_equal 'shop.test', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
assert_equal 'ok', response_xml.at_xpath('//domain:status', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['s']
assert_equal 'john-001', response_xml.at_xpath('//domain:registrant', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
@ -50,7 +50,8 @@ class EppDomainInfoBaseTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_info_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '65078d5', response_xml.at_xpath('//domain:authInfo/domain:pw', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
@ -77,7 +78,8 @@ class EppDomainInfoBaseTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_goodnames'
post epp_info_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
response_xml = Nokogiri::XML(response.body)
assert_equal '65078d5', response_xml.at_xpath('//domain:authInfo/domain:pw', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
@ -100,33 +102,11 @@ class EppDomainInfoBaseTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_goodnames'
post epp_info_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
response_xml = Nokogiri::XML(response.body)
assert_nil response_xml.at_xpath('//domain:authInfo/domain:pw',
'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')
end
def test_returns_not_found_error_when_domain_is_not_registered
assert DNS::DomainName.new('not-registered.test').not_registered?
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<info>
<domain:info xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>not-registered.test</domain:name>
</domain:info>
</info>
</command>
</epp>
XML
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
response_xml = Nokogiri::XML(response.body)
assert_equal '2303', response_xml.at_css('result')[:code]
assert_equal 'Domain not found', response_xml.at_css('result msg').text
end
end

View file

@ -0,0 +1,170 @@
require 'test_helper'
class EppDomainRenewBaseTest < EppTestCase
self.use_transactional_tests = false
def test_renews_domain
travel_to Time.zone.parse('2010-07-05')
domain = domains(:shop)
original_valid_to = domain.valid_to
default_renewal_period = 1.year
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<renew>
<domain:renew xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{domain.name}</domain:name>
<domain:curExpDate>#{domain.expire_time.to_date}</domain:curExpDate>
<domain:period unit="y">1</domain:period>
</domain:renew>
</renew>
</command>
</epp>
XML
post epp_renew_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
domain.reload
assert_epp_response :completed_successfully
assert_equal original_valid_to + default_renewal_period, domain.valid_to
end
def test_domain_cannot_be_renewed_when_invalid
domain = domains(:invalid)
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<renew>
<domain:renew xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{domain.name}</domain:name>
<domain:curExpDate>#{domain.valid_to.to_date}</domain:curExpDate>
<domain:period unit="m">1</domain:period>
</domain:renew>
</renew>
</command>
</epp>
XML
assert_no_changes -> { domain.valid_to } do
post epp_renew_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
domain.reload
end
assert_epp_response :object_status_prohibits_operation
end
def test_domain_cannot_be_renewed_when_belongs_to_another_registrar
domain = domains(:metro)
session = epp_sessions(:api_bestnames)
assert_not_equal session.user.registrar, domain.registrar
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<renew>
<domain:renew xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{domain.name}</domain:name>
<domain:curExpDate>#{domain.valid_to.to_date}</domain:curExpDate>
<domain:period unit="m">1</domain:period>
</domain:renew>
</renew>
</command>
</epp>
XML
assert_no_changes -> { domain.valid_to } do
post epp_renew_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => "session=#{session.session_id}" }
domain.reload
end
assert_epp_response :authorization_error
end
def test_insufficient_funds
domain = domains(:shop)
session = epp_sessions(:api_bestnames)
session.user.registrar.accounts.first.update!(balance: 0)
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<renew>
<domain:renew xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{domain.name}</domain:name>
<domain:curExpDate>#{domain.expire_time.to_date}</domain:curExpDate>
<domain:period unit="y">1</domain:period>
</domain:renew>
</renew>
</command>
</epp>
XML
assert_no_difference -> { domain.valid_to } do
post epp_renew_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => "session=#{session.session_id}" }
domain.reload
end
assert_epp_response :billing_failure
end
def test_no_price
domain = domains(:shop)
assert_nil Billing::Price.find_by(duration: '2 months')
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<renew>
<domain:renew xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{domain.name}</domain:name>
<domain:curExpDate>#{domain.expire_time.to_date}</domain:curExpDate>
<domain:period unit="m">2</domain:period>
</domain:renew>
</renew>
</command>
</epp>
XML
assert_no_changes -> { domain.valid_to } do
post epp_renew_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
domain.reload
end
assert_epp_response :billing_failure
end
def test_fails_when_provided_expiration_date_is_wrong
domain = domains(:shop)
provided_expiration_date = Date.parse('2010-07-06')
assert_not_equal provided_expiration_date, domain.valid_to
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<renew>
<domain:renew xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{domain.name}</domain:name>
<domain:curExpDate>#{provided_expiration_date}</domain:curExpDate>
</domain:renew>
</renew>
</command>
</epp>
XML
assert_no_changes -> { domain.valid_to } do
post epp_renew_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
domain.reload
end
assert_epp_response :parameter_value_policy_error
end
end

View file

@ -1,24 +0,0 @@
require 'test_helper'
class EppDomainTransferBaseTest < ApplicationIntegrationTest
def test_non_existent_domain
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<transfer op="request">
<domain:transfer xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>non-existent.test</domain:name>
<domain:authInfo>
<domain:pw>any</domain:pw>
</domain:authInfo>
</domain:transfer>
</transfer>
</command>
</epp>
XML
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
assert_equal '2303', Nokogiri::XML(response.body).at_css('result')[:code]
end
end

View file

@ -1,11 +1,11 @@
require 'test_helper'
class EppDomainTransferQueryTest < ApplicationIntegrationTest
class EppDomainTransferQueryTest < EppTestCase
def test_returns_domain_transfer_details
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
post epp_transfer_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
xml_doc = Nokogiri::XML(response.body)
assert_equal '1000', xml_doc.at_css('result')[:code]
assert_equal 1, xml_doc.css('result').size
assert_epp_response :completed_successfully
assert_equal 'shop.test', xml_doc.xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
assert_equal 'serverApproved', xml_doc.xpath('//domain:trStatus', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
assert_equal 'goodnames', xml_doc.xpath('//domain:reID', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
@ -29,14 +29,17 @@ class EppDomainTransferQueryTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_equal '2201', Nokogiri::XML(response.body).at_css('result')[:code]
post epp_transfer_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_epp_response :invalid_authorization_information
end
def test_no_domain_transfer
domains(:shop).transfers.delete_all
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_equal '2303', Nokogiri::XML(response.body).at_css('result')[:code]
post epp_transfer_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_epp_response :object_does_not_exist
end
private

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppDomainTransferRequestTest < ApplicationIntegrationTest
class EppDomainTransferRequestTest < EppTestCase
def setup
@domain = domains(:shop)
@new_registrar = registrars(:goodnames)
@ -13,25 +13,28 @@ class EppDomainTransferRequestTest < ApplicationIntegrationTest
end
def test_transfers_domain_at_once
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
assert_equal '1000', Nokogiri::XML(response.body).at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
post epp_transfer_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
assert_epp_response :completed_successfully
end
def test_creates_new_domain_transfer
assert_difference -> { @domain.transfers.size } do
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
post epp_transfer_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
end
end
def test_approves_automatically_if_auto_approval_is_enabled
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
post epp_transfer_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
assert_equal 'serverApproved', Nokogiri::XML(response.body).xpath('//domain:trStatus', 'domain' =>
'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
end
def test_assigns_new_registrar
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
post epp_transfer_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
@domain.reload
assert_equal @new_registrar, @domain.registrar
end
@ -39,7 +42,8 @@ class EppDomainTransferRequestTest < ApplicationIntegrationTest
def test_regenerates_transfer_code
@old_transfer_code = @domain.transfer_code
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
post epp_transfer_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
@domain.reload
refute_equal @domain.transfer_code, @old_transfer_code
@ -49,54 +53,59 @@ class EppDomainTransferRequestTest < ApplicationIntegrationTest
@old_registrar = @domain.registrar
assert_difference -> { @old_registrar.notifications.count } do
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
post epp_transfer_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
end
end
def test_duplicates_registrant_admin_and_tech_contacts
assert_difference -> { @new_registrar.contacts.size }, 3 do
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
post epp_transfer_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
end
end
def test_reuses_identical_contact
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
post epp_transfer_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
assert_equal 1, @new_registrar.contacts.where(name: 'William').size
end
def test_saves_legal_document
assert_difference -> { @domain.legal_documents(true).size } do
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
assert_difference -> { @domain.legal_documents.reload.size } do
post epp_transfer_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
end
end
def test_non_transferable_domain
@domain.update!(statuses: [DomainStatus::SERVER_TRANSFER_PROHIBITED])
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
post epp_transfer_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
domains(:shop).reload
assert_equal registrars(:bestnames), domains(:shop).registrar
assert_equal '2304', Nokogiri::XML(response.body).at_css('result')[:code]
assert_epp_response :object_status_prohibits_operation
end
def test_discarded_domain_cannot_be_transferred
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
post epp_transfer_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
@domain.reload
assert_equal registrars(:bestnames), @domain.registrar
assert_equal '2105', Nokogiri::XML(response.body).at_css('result')[:code]
travel_back
assert_epp_response :object_is_not_eligible_for_transfer
end
def test_same_registrar
assert_no_difference -> { @domain.transfers.size } do
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
post epp_transfer_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_equal '2002', Nokogiri::XML(response.body).at_css('result')[:code]
assert_epp_response :use_error
end
def test_wrong_transfer_code
@ -116,10 +125,12 @@ class EppDomainTransferRequestTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
post epp_transfer_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
@domain.reload
assert_epp_response :invalid_authorization_information
refute_equal @new_registrar, @domain.registrar
assert_equal '2201', Nokogiri::XML(response.body).at_css('result')[:code]
end
private

View file

@ -0,0 +1,511 @@
require 'test_helper'
class EppDomainUpdateBaseTest < EppTestCase
include ActionMailer::TestHelper
setup do
@domain = domains(:shop)
@original_registrant_change_verification =
Setting.request_confrimation_on_registrant_change_enabled
ActionMailer::Base.deliveries.clear
end
teardown do
Setting.request_confrimation_on_registrant_change_enabled =
@original_registrant_change_verification
end
def test_update_domain
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>shop.test</domain:name>
<domain:chg>
<domain:authInfo>
<domain:pw>f0ff7d17b0</domain:pw>
</domain:authInfo>
</domain:chg>
</domain:update>
</update>
</command>
</epp>
XML
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
@domain.reload
assert_equal 'f0ff7d17b0', @domain.transfer_code
assert_epp_response :completed_successfully
end
def test_discarded_domain_cannot_be_updated
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>shop.test</domain:name>
</domain:update>
</update>
</command>
</epp>
XML
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_epp_response :object_status_prohibits_operation
end
def test_does_not_return_server_delete_prohibited_status_when_pending_update_status_is_set
@domain.update!(statuses: [DomainStatus::SERVER_DELETE_PROHIBITED,
DomainStatus::PENDING_UPDATE])
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{@domain.name}</domain:name>
</domain:update>
</update>
</command>
</epp>
XML
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_epp_response :object_status_prohibits_operation
response_xml = Nokogiri::XML(response.body)
assert_equal DomainStatus::PENDING_UPDATE, response_xml.at_xpath('//domain:status', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
end
def test_requires_verification_from_current_registrant_when_provided_registrant_is_a_new_one
Setting.request_confrimation_on_registrant_change_enabled = true
new_registrant = contacts(:william).becomes(Registrant)
assert_not_equal new_registrant, @domain.registrant
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{@domain.name}</domain:name>
<domain:chg>
<domain:registrant>#{new_registrant.code}</domain:registrant>
</domain:chg>
</domain:update>
</update>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
@domain.reload
assert_epp_response :completed_successfully_action_pending
assert_not_equal new_registrant, @domain.registrant
assert @domain.registrant_verification_asked?
assert_includes @domain.statuses, DomainStatus::PENDING_UPDATE
assert_verification_and_notification_emails
end
def test_requires_verification_from_current_registrant_when_not_yet_verified_by_registrar
Setting.request_confrimation_on_registrant_change_enabled = true
new_registrant = contacts(:william)
assert_not_equal new_registrant, @domain.registrant
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{@domain.name}</domain:name>
<domain:chg>
<domain:registrant verified="no">#{new_registrant.code}</domain:registrant>
</domain:chg>
</domain:update>
</update>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
@domain.reload
assert_epp_response :completed_successfully_action_pending
assert_not_equal new_registrant, @domain.registrant
assert @domain.registrant_verification_asked?
assert_includes @domain.statuses, DomainStatus::PENDING_UPDATE
assert_verification_and_notification_emails
end
def test_updates_registrant_when_legaldoc_is_not_mandatory
Setting.request_confrimation_on_registrant_change_enabled = true
new_registrant = contacts(:william)
assert_not_equal new_registrant, @domain.registrant
@domain.registrar.legaldoc_optout = true
@domain.registrar.save(validate: false)
@domain.registrar.reload
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{@domain.name}</domain:name>
<domain:chg>
<domain:registrant verified="no">#{new_registrant.code}</domain:registrant>
</domain:chg>
</domain:update>
</update>
</command>
</epp>
XML
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
@domain.reload
assert_epp_response :completed_successfully_action_pending
assert_not_equal new_registrant, @domain.registrant
assert @domain.registrant_verification_asked?
assert_includes @domain.statuses, DomainStatus::PENDING_UPDATE
assert_verification_and_notification_emails
end
def test_dows_not_update_registrant_when_legaldoc_is_mandatory
Setting.request_confrimation_on_registrant_change_enabled = true
old_value = Setting.legal_document_is_mandatory
Setting.legal_document_is_mandatory = true
new_registrant = contacts(:william)
assert_not_equal new_registrant, @domain.registrant
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{@domain.name}</domain:name>
<domain:chg>
<domain:registrant verified="no">#{new_registrant.code}</domain:registrant>
</domain:chg>
</domain:update>
</update>
</command>
</epp>
XML
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_epp_response :required_parameter_missing
Setting.legal_document_is_mandatory = old_value
end
def test_skips_verification_when_provided_registrant_is_the_same_as_current_one
Setting.request_confrimation_on_registrant_change_enabled = true
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{@domain.name}</domain:name>
<domain:chg>
<domain:registrant>#{@domain.registrant.code}</domain:registrant>
</domain:chg>
</domain:update>
</update>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
@domain.reload
assert_epp_response :completed_successfully
assert_not @domain.registrant_verification_asked?
refute_includes @domain.statuses, DomainStatus::PENDING_UPDATE
assert_no_emails
end
def test_skips_verification_when_registrant_changed_with_dispute_password
Setting.request_confrimation_on_registrant_change_enabled = true
dispute = disputes(:expired)
dispute.update!(starts_at: Time.zone.now, expires_at: Time.zone.now + 5.days, closed: nil)
new_registrant = contacts(:william)
assert @domain.disputed?
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{@domain.name}</domain:name>
<domain:chg>
<domain:registrant>#{new_registrant.code}</domain:registrant>
</domain:chg>
</domain:update>
</update>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
<eis:reserved>
<eis:pw>#{dispute.password}</eis:pw>
</eis:reserved>
</eis:extdata>
</extension>
</command>
</epp>
XML
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
@domain.reload
assert_epp_response :completed_successfully
assert new_registrant, @domain.registrant
assert_not @domain.registrant_verification_asked?
assert_not @domain.disputed?
assert_no_emails
end
def test_skips_verification_when_disabled
Setting.request_confrimation_on_registrant_change_enabled = false
new_registrant = contacts(:william).becomes(Registrant)
assert_not_equal new_registrant, @domain.registrant
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{@domain.name}</domain:name>
<domain:chg>
<domain:registrant>#{new_registrant.code}</domain:registrant>
</domain:chg>
</domain:update>
</update>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
@domain.reload
assert_epp_response :completed_successfully
assert_equal new_registrant, @domain.registrant
assert_not @domain.registrant_verification_asked?
refute_includes @domain.statuses, DomainStatus::PENDING_UPDATE
assert_no_emails
end
def test_skips_verification_from_current_registrant_when_already_verified_by_registrar
Setting.request_confrimation_on_registrant_change_enabled = true
new_registrant = contacts(:william).becomes(Registrant)
assert_not_equal new_registrant, @domain.registrant
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{@domain.name}</domain:name>
<domain:chg>
<domain:registrant verified="yes">#{new_registrant.code}</domain:registrant>
</domain:chg>
</domain:update>
</update>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
@domain.reload
assert_epp_response :completed_successfully
assert_equal new_registrant, @domain.registrant
assert_not @domain.registrant_verification_asked?
refute_includes @domain.statuses, DomainStatus::PENDING_UPDATE
assert_no_emails
end
def test_clears_force_delete_when_registrar_changed
Setting.request_confrimation_on_registrant_change_enabled = true
new_registrant = contacts(:william).becomes(Registrant)
@domain.schedule_force_delete(type: :fast_track)
assert_not_equal new_registrant, @domain.registrant
assert @domain.force_delete_scheduled?
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{@domain.name}</domain:name>
<domain:chg>
<domain:registrant verified="yes">#{new_registrant.code}</domain:registrant>
</domain:chg>
</domain:update>
</update>
<extension>
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
</eis:extdata>
</extension>
</command>
</epp>
XML
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
@domain.reload
assert_epp_response :completed_successfully
assert_equal new_registrant, @domain.registrant
assert_not @domain.registrant_verification_asked?
refute @domain.force_delete_scheduled?
refute_includes @domain.statuses, DomainStatus::PENDING_UPDATE
assert_no_emails
end
def test_deactivates_domain_when_all_name_servers_are_removed
assert @domain.active?
assert_equal 2, @domain.nameservers.count
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>#{@domain.name}</domain:name>
<domain:rem>
<domain:ns>
<domain:hostAttr>
<domain:hostName>#{nameservers(:shop_ns1).hostname}</domain:hostName>
</domain:hostAttr>
<domain:hostAttr>
<domain:hostName>#{nameservers(:shop_ns2).hostname}</domain:hostName>
</domain:hostAttr>
</domain:ns>
</domain:rem>
</domain:update>
</update>
</command>
</epp>
XML
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
@domain.reload
assert_epp_response :completed_successfully
assert @domain.inactive?
end
def test_update_domain_allows_add_of_client_hold
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>shop.test</domain:name>
<domain:add>
<domain:status s="clientHold" lang="en">Test</domain:status>
</domain:add>
</domain:update>
</update>
</command>
</epp>
XML
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
@domain.reload
assert_epp_response :completed_successfully
assert_includes(@domain.statuses, DomainStatus::CLIENT_HOLD)
end
def test_update_domain_allows_remove_of_client_hold
@domain.update!(statuses: [DomainStatus::CLIENT_HOLD, DomainStatus::FORCE_DELETE,
DomainStatus::SERVER_RENEW_PROHIBITED,
DomainStatus::SERVER_TRANSFER_PROHIBITED])
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<command>
<update>
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>shop.test</domain:name>
<domain:rem>
<domain:status s="clientHold" lang="en">Test</domain:status>
</domain:rem>
</domain:update>
</update>
</command>
</epp>
XML
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
@domain.reload
assert_epp_response :completed_successfully
assert_not_includes(@domain.statuses, DomainStatus::CLIENT_HOLD)
end
private
def assert_verification_and_notification_emails
assert_emails 2
end
end

View file

@ -0,0 +1,18 @@
require 'test_helper'
class EppHelloTest < EppTestCase
def test_anonymous_user_is_able_to_access
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
<hello/>
</epp>
XML
get epp_hello_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=non-existent' }
response_xml = Nokogiri::XML(response.body)
assert_equal 'EPP server (EIS)', response_xml.at_css('greeting > svID').text
end
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppLoginCredentialsTest < ApplicationIntegrationTest
class EppLoginCredentialsTest < EppTestCase
def test_correct_credentials
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
@ -17,18 +17,17 @@ class EppLoginCredentialsTest < ApplicationIntegrationTest
<objURI>https://epp.tld.ee/schema/domain-eis-1.0.xsd</objURI>
<objURI>https://epp.tld.ee/schema/contact-ee-1.1.xsd</objURI>
<objURI>urn:ietf:params:xml:ns:host-1.0</objURI>
<objURI>urn:ietf:params:xml:ns:keyrelay-1.0</objURI>
</svcs>
</login>
</command>
</epp>
XML
post '/epp/session/login', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=new_session_id' }
post epp_login_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=new_session_id' }
assert EppSession.find_by(session_id: 'new_session_id')
assert_equal users(:api_bestnames), EppSession.find_by(session_id: 'new_session_id').user
assert Nokogiri::XML(response.body).at_css('result[code="1000"]')
assert_equal 1, Nokogiri::XML(response.body).css('result').size
assert_epp_response :completed_successfully
end
def test_already_logged_in
@ -51,14 +50,15 @@ class EppLoginCredentialsTest < ApplicationIntegrationTest
<objURI>https://epp.tld.ee/schema/domain-eis-1.0.xsd</objURI>
<objURI>https://epp.tld.ee/schema/contact-ee-1.1.xsd</objURI>
<objURI>urn:ietf:params:xml:ns:host-1.0</objURI>
<objURI>urn:ietf:params:xml:ns:keyrelay-1.0</objURI>
</svcs>
</login>
</command>
</epp>
XML
post '/epp/session/login', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=any_random_string' }
assert Nokogiri::XML(response.body).at_css('result[code="2501"]')
post epp_login_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=any_random_string' }
assert_epp_response :authentication_error_server_closing_connection
end
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppLoginPasswordChangeTest < ActionDispatch::IntegrationTest
class EppLoginPasswordChangeTest < EppTestCase
def test_password_change
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
@ -18,16 +18,15 @@ class EppLoginPasswordChangeTest < ActionDispatch::IntegrationTest
<objURI>https://epp.tld.ee/schema/domain-eis-1.0.xsd</objURI>
<objURI>https://epp.tld.ee/schema/contact-ee-1.1.xsd</objURI>
<objURI>urn:ietf:params:xml:ns:host-1.0</objURI>
<objURI>urn:ietf:params:xml:ns:keyrelay-1.0</objURI>
</svcs>
</login>
</command>
</epp>
XML
post '/epp/session/login', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=new_session_id' }
post epp_login_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=new_session_id' }
assert_equal 'new-password', users(:api_bestnames).plain_text_password
assert_equal '1000', Nokogiri::XML(response.body).at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
assert_epp_response :completed_successfully
end
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppLoginSessionLimitTest < ApplicationIntegrationTest
class EppLoginSessionLimitTest < EppTestCase
setup do
travel_to Time.zone.parse('2010-07-05')
EppSession.delete_all
@ -14,11 +14,10 @@ class EppLoginSessionLimitTest < ApplicationIntegrationTest
end
assert_difference 'EppSession.count' do
post '/epp/session/login', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=new_session_id' }
post epp_login_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=new_session_id' }
end
assert Nokogiri::XML(response.body).at_css('result[code="1000"]')
assert_equal 1, Nokogiri::XML(response.body).css('result').size
assert_epp_response :completed_successfully
end
def test_reached
@ -29,10 +28,10 @@ class EppLoginSessionLimitTest < ApplicationIntegrationTest
end
assert_no_difference 'EppSession.count' do
post '/epp/session/login', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=new_session_id' }
post epp_login_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=new_session_id' }
end
assert Nokogiri::XML(response.body).at_css('result[code="2501"]')
assert_epp_response :authentication_error_server_closing_connection
end
private
@ -53,7 +52,6 @@ class EppLoginSessionLimitTest < ApplicationIntegrationTest
<objURI>https://epp.tld.ee/schema/domain-eis-1.0.xsd</objURI>
<objURI>https://epp.tld.ee/schema/contact-ee-1.1.xsd</objURI>
<objURI>urn:ietf:params:xml:ns:host-1.0</objURI>
<objURI>urn:ietf:params:xml:ns:keyrelay-1.0</objURI>
</svcs>
</login>
</command>

View file

@ -1,25 +1,28 @@
require 'test_helper'
class EppLogoutTest < ApplicationIntegrationTest
class EppLogoutTest < EppTestCase
def test_success_response
post '/epp/session/logout', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert Nokogiri::XML(response.body).at_css('result[code="1500"]')
assert_equal 1, Nokogiri::XML(response.body).css('result').size
post epp_logout_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_epp_response :completed_successfully_ending_session
end
def test_ends_current_session
post '/epp/session/logout', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
post epp_logout_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_nil EppSession.find_by(session_id: 'api_bestnames')
end
def test_keeps_other_sessions_intact
post '/epp/session/logout', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
post epp_logout_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert EppSession.find_by(session_id: 'api_goodnames')
end
def test_anonymous_user
post '/epp/session/logout', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=non-existent' }
assert Nokogiri::XML(response.body).at_css('result[code="2201"]')
post epp_logout_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=non-existent' }
assert_epp_response :authorization_error
end
private

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppPollTest < ApplicationIntegrationTest
class EppPollTest < EppTestCase
setup do
@notification = notifications(:complete)
end
@ -15,11 +15,11 @@ class EppPollTest < ApplicationIntegrationTest
</command>
</epp>
XML
post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_poll_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
xml_doc = Nokogiri::XML(response.body)
assert_equal 1301.to_s, xml_doc.at_css('result')[:code]
assert_equal 1, xml_doc.css('result').size
assert_epp_response :completed_successfully_ack_to_dequeue
assert_equal 2.to_s, xml_doc.at_css('msgQ')[:count]
assert_equal @notification.id.to_s, xml_doc.at_css('msgQ')[:id]
assert_equal Time.zone.parse('2010-07-05').utc.xmlschema, xml_doc.at_css('msgQ qDate').text
@ -37,7 +37,8 @@ class EppPollTest < ApplicationIntegrationTest
</command>
</epp>
XML
post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_poll_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
xml_doc = Nokogiri::XML(response.body)
namespace = 'https://epp.tld.ee/schema/changePoll-1.0.xsd'
@ -61,11 +62,10 @@ class EppPollTest < ApplicationIntegrationTest
</command>
</epp>
XML
post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_poll_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
xml_doc = Nokogiri::XML(response.body)
assert_equal 1300.to_s, xml_doc.at_css('result')[:code]
assert_equal 1, xml_doc.css('result').size
assert_epp_response :completed_successfully_no_messages
end
def test_mark_as_read
@ -80,13 +80,13 @@ class EppPollTest < ApplicationIntegrationTest
</epp>
XML
post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_poll_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
notification.reload
xml_doc = Nokogiri::XML(response.body)
assert notification.read?
assert_equal 1000.to_s, xml_doc.at_css('result')[:code]
assert_equal 1, xml_doc.css('result').size
assert_epp_response :completed_successfully
assert_equal 1.to_s, xml_doc.at_css('msgQ')[:count]
assert_equal notification.id.to_s, xml_doc.at_css('msgQ')[:id]
end
@ -102,12 +102,12 @@ class EppPollTest < ApplicationIntegrationTest
</command>
</epp>
XML
post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_poll_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
notification.reload
xml_doc = Nokogiri::XML(response.body)
assert notification.unread?
assert_equal 2303.to_s, xml_doc.at_css('result')[:code]
assert_epp_response :object_does_not_exist
end
def test_notification_not_found
@ -119,9 +119,9 @@ class EppPollTest < ApplicationIntegrationTest
</command>
</epp>
XML
post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
post epp_poll_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
xml_doc = Nokogiri::XML(response.body)
assert_equal 2303.to_s, xml_doc.at_css('result')[:code]
assert_epp_response :object_does_not_exist
end
end
end

View file

@ -0,0 +1,19 @@
require 'test_helper'
class RegistrantAreaContactsIntegrationTest < ApplicationIntegrationTest
setup do
@domain = domains(:shop)
@registrant = users(:registrant)
sign_in @registrant
end
def test_can_view_other_domain_contacts
secondary_contact = contacts(:jane)
visit registrant_domain_path(@domain)
assert_text secondary_contact.name
click_link secondary_contact.name
assert_text @domain.name
assert_text secondary_contact.email
end
end

View file

@ -0,0 +1,25 @@
require 'test_helper'
class RegistrantAreaDomainsIntegrationTest < ApplicationIntegrationTest
setup do
sign_in users(:registrant)
end
def test_downloads_list_as_csv
get registrant_domains_path(format: :csv)
assert_response :ok
assert_equal "#{Mime[:csv]}; charset=utf-8", response.headers['Content-Type']
assert_equal "attachment; filename=\"domains.csv\"; filename*=UTF-8''domains.csv", response.headers['Content-Disposition']
assert_not_empty response.body
end
def test_downloads_list_as_pdf
get registrant_domains_path(format: :pdf)
assert_response :ok
assert_equal Mime[:pdf], response.headers['Content-Type']
assert_equal "attachment; filename=\"domains.pdf\"; filename*=UTF-8''domains.pdf", response.headers['Content-Disposition']
assert_not_empty response.body
end
end

View file

@ -6,9 +6,9 @@ class RegistrantAreaIdCardSignInTest < ApplicationIntegrationTest
end
def test_succeeds
post_via_redirect registrant_id_card_sign_in_path, nil,
'SSL_CLIENT_S_DN_CN' => 'DOE,JOHN,1234',
'SSL_CLIENT_I_DN_C' => 'US'
post registrant_id_card_sign_in_path, headers: { 'SSL_CLIENT_S_DN_CN' => 'DOE,JOHN,1234',
'SSL_CLIENT_I_DN_C' => 'US' }
follow_redirect!
assert_response :ok
assert_equal registrant_root_path, path
@ -16,7 +16,7 @@ class RegistrantAreaIdCardSignInTest < ApplicationIntegrationTest
end
def test_fails_when_certificate_is_absent
post_via_redirect registrant_id_card_sign_in_path, nil, 'SSL_CLIENT_S_DN_CN' => ''
post registrant_id_card_sign_in_path, headers: { 'SSL_CLIENT_S_DN_CN' => '' }
assert_response :ok
assert_equal registrant_id_card_sign_in_path, path

View file

@ -0,0 +1,25 @@
require 'test_helper'
class RegistrarAreaContactsIntegrationTest < ApplicationIntegrationTest
setup do
sign_in users(:api_bestnames)
end
def test_downloads_list_as_csv
get registrar_contacts_path(format: :csv)
assert_response :ok
assert_equal "#{Mime[:csv]}; charset=utf-8", response.headers['Content-Type']
assert_equal "attachment; filename=\"contacts.csv\"; filename*=UTF-8''contacts.csv", response.headers['Content-Disposition']
assert_not_empty response.body
end
def test_downloads_list_as_pdf
get registrar_contacts_path(format: :pdf)
assert_response :ok
assert_equal Mime[:pdf], response.headers['Content-Type']
assert_equal "attachment; filename=\"contacts.pdf\"; filename*=UTF-8''contacts.pdf", response.headers['Content-Disposition']
assert_not_empty response.body
end
end

View file

@ -0,0 +1,20 @@
require 'test_helper'
class RegistrarAreaDomainsIntegrationTest < ApplicationIntegrationTest
setup do
sign_in users(:api_bestnames)
end
def test_downloads_list_as_csv
now = Time.zone.parse('2010-07-05 08:00')
travel_to now
get registrar_domains_path(format: :csv)
assert_response :ok
assert_equal "#{Mime[:csv]}; charset=utf-8", response.headers['Content-Type']
assert_equal %(attachment; filename="Domains_#{l(now, format: :filename)}.csv"; filename*=UTF-8''Domains_#{l(now, format: :filename)}.csv),
response.headers['Content-Disposition']
assert_not_empty response.body
end
end

View file

@ -1,39 +1,45 @@
require 'test_helper'
class PaymentCallbackTest < ApplicationSystemTestCase
class PaymentCallbackTest < ApplicationIntegrationTest
def setup
super
@user = users(:api_bestnames)
sign_in @user
@payment_order = payment_orders(:everypay_issued)
@invoice = invoices(:one)
@invoice.update!(account_activity: nil, total: 12)
end
def test_every_pay_callback_returns_status_200
invoice = payable_invoice
assert_matching_bank_transaction_exists(invoice)
request_params = every_pay_request_params.merge(invoice_id: invoice.id)
post "/registrar/pay/callback/every_pay", request_params
request_params = every_pay_request_params
post "/registrar/pay/callback/#{@payment_order.id}", params: request_params
assert_response :ok
end
def test_invoice_is_marked_as_paid
request_params = every_pay_request_params
post "/registrar/pay/callback/#{@payment_order.id}", params: request_params
assert @payment_order.invoice.paid?
end
def failure_log_is_created_if_unsuccessful_payment
request_params = every_pay_request_params.dup
request_params['payment_state'] = 'cancelled'
request_params['transaction_result'] = 'failed'
post "/registrar/pay/callback/#{@payment_order.id}", params: request_params
@payment_order.reload
assert @payment_order.cancelled?
assert_includes @payment_order.notes, 'Payment state: cancelled'
end
private
def payable_invoice
invoice = invoices(:one)
invoice.update!(account_activity: nil)
invoice
end
def assert_matching_bank_transaction_exists(invoice)
assert BankTransaction.find_by(
description: invoice.order,
currency: invoice.currency,
iban: invoice.seller_iban
), 'Matching bank transaction should exist'
end
def every_pay_request_params
{
nonce: "392f2d7748bc8cb0d14f263ebb7b8932",
@ -56,4 +62,4 @@ class PaymentCallbackTest < ApplicationSystemTestCase
payment_method: "every_pay"
}
end
end
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class PaymentReturnTest < ApplicationSystemTestCase
class PaymentReturnTest < ApplicationIntegrationTest
def setup
super
@ -8,6 +8,9 @@ class PaymentReturnTest < ApplicationSystemTestCase
sign_in @user
@invoice = invoices(:one)
@invoice.update!(account_activity: nil, total: 12)
@everypay_order = payment_orders(:everypay_issued)
@banklink_order = payment_orders(:banklink_issued)
end
def every_pay_request_params
@ -57,33 +60,78 @@ class PaymentReturnTest < ApplicationSystemTestCase
}
end
def test_every_pay_return_creates_activity_redirects_to_invoice_path
request_params = every_pay_request_params.merge(invoice_id: @invoice.id)
def test_successful_bank_payment_marks_invoice_as_paid
@invoice.update!(account_activity: nil)
request_params = bank_link_request_params
post "/registrar/pay/return/every_pay", request_params
post "/registrar/pay/return/#{@banklink_order.id}", params: request_params
@banklink_order.reload
assert @banklink_order.invoice.paid?
end
def test_every_pay_return_creates_activity_redirects_to_invoice_path
request_params = every_pay_request_params
post "/registrar/pay/return/#{@everypay_order.id}", params: request_params
assert_equal(302, response.status)
assert_redirected_to(registrar_invoice_path(@invoice))
end
def test_Every_Pay_return_raises_RecordNotFound
request_params = every_pay_request_params.merge(invoice_id: "178907")
def test_every_pay_return_raises_record_not_found
request_params = every_pay_request_params
assert_raises(ActiveRecord::RecordNotFound) do
post "/registrar/pay/return/every_pay", request_params
post '/registrar/pay/return/123456', params: request_params
end
end
def test_bank_link_return_redirects_to_invoice_paths
request_params = bank_link_request_params.merge(invoice_id: @invoice.id)
request_params = bank_link_request_params
post "/registrar/pay/return/seb", request_params
post "/registrar/pay/return/#{@banklink_order.id}", params: request_params
assert_equal(302, response.status)
assert_redirected_to(registrar_invoice_path(@invoice))
end
def test_bank_link_return
request_params = bank_link_request_params.merge(invoice_id: "178907")
request_params = bank_link_request_params
assert_raises(ActiveRecord::RecordNotFound) do
post "/registrar/pay/return/seb", request_params
post '/registrar/pay/return/123456', params: request_params
end
end
def test_marks_as_paid_and_adds_notes_if_failed_to_bind
request_params = bank_link_request_params
post "/registrar/pay/return/#{@banklink_order.id}", params: request_params
post "/registrar/pay/return/#{@banklink_order.id}", params: request_params
@banklink_order.reload
assert @banklink_order.notes.present?
assert @banklink_order.paid?
assert_includes @banklink_order.notes, 'Failed to bind'
end
def test_failed_bank_link_payment_creates_brief_error_explanation
request_params = bank_link_request_params.dup
request_params['VK_SERVICE'] = '1911'
post "/registrar/pay/return/#{@banklink_order.id}", params: request_params
@banklink_order.reload
assert_includes @banklink_order.notes, 'Bank responded with code 1911'
end
def test_failed_every_pay_payment_creates_brief_error_explanation
request_params = every_pay_request_params.dup
request_params['payment_state'] = 'cancelled'
request_params['transaction_result'] = 'failed'
post "/registrar/pay/return/#{@everypay_order.id}", params: request_params
@everypay_order.reload
assert_includes @everypay_order.notes, 'Payment state: cancelled'
end
end

View file

@ -13,7 +13,7 @@ class RegistrarAreaInvoicesIntegrationTest < ApplicationIntegrationTest
assert_response :ok
assert_equal 'application/pdf', response.headers['Content-Type']
assert_equal 'attachment; filename="invoice-1.pdf"', response.headers['Content-Disposition']
assert_equal "attachment; filename=\"invoice-1.pdf\"; filename*=UTF-8''invoice-1.pdf", response.headers['Content-Disposition']
assert_not_empty response.body
end
end
end

View file

@ -13,8 +13,8 @@ class RegistrarAreaSettingsBalanceAutoReloadIntegrationTest < ActionDispatch::In
threshold = 10
assert_nil @registrar.settings['balance_auto_reload']
patch registrar_settings_balance_auto_reload_path, { type: { amount: amount,
threshold: threshold } }
patch registrar_settings_balance_auto_reload_path, params: { type: { amount: amount,
threshold: threshold } }
@registrar.reload
assert_equal amount, @registrar.settings['balance_auto_reload']['type']['amount']

View file

@ -3,12 +3,18 @@ require 'test_helper'
class RegistrarAreaIdCardSignInTest < ApplicationIntegrationTest
setup do
@user = users(:api_bestnames)
@original_registrar_area_ip_whitelist = Setting.registrar_ip_whitelist_enabled
end
teardown do
Setting.registrar_ip_whitelist_enabled = @original_registrar_area_ip_whitelist
end
def test_signs_in_a_user_when_id_card_owner_is_found
assert_equal '1234', @user.identity_code
post_via_redirect registrar_id_card_sign_in_path, nil, 'SSL_CLIENT_S_DN_CN' => 'DOE,JOHN,1234'
post registrar_id_card_sign_in_path, headers: { 'SSL_CLIENT_S_DN_CN' => 'DOE,JOHN,1234' }
follow_redirect!
assert_response :ok
assert_equal registrar_root_path, path
@ -16,8 +22,8 @@ class RegistrarAreaIdCardSignInTest < ApplicationIntegrationTest
end
def test_does_not_sign_in_a_user_when_id_card_owner_is_not_found
post_via_redirect registrar_id_card_sign_in_path, nil,
'SSL_CLIENT_S_DN_CN' => 'DOE,JOHN,unacceptable-personal-code'
post registrar_id_card_sign_in_path,
headers: { 'SSL_CLIENT_S_DN_CN' => 'DOE,JOHN,unacceptable-personal-code' }
assert_nil controller.current_registrar_user
assert_equal registrar_id_card_sign_in_path, path
@ -31,20 +37,18 @@ class RegistrarAreaIdCardSignInTest < ApplicationIntegrationTest
Setting.registrar_ip_whitelist_enabled = true
post registrar_id_card_sign_in_path, nil, 'SSL_CLIENT_S_DN_CN' => 'DOE,JOHN,1234',
'REMOTE_ADDR' => '127.0.0.2'
post registrar_id_card_sign_in_path, headers: { 'SSL_CLIENT_S_DN_CN' => 'DOE,JOHN,1234',
'REMOTE_ADDR' => '127.0.0.2' }
assert_equal registrar_id_card_sign_in_path, path
assert_equal 'Access denied from IP 127.0.0.2', response.body
get registrar_root_path
assert_redirected_to new_registrar_user_session_path
Setting.registrar_ip_whitelist_enabled = false
end
def test_does_not_sign_in_a_user_when_certificate_is_absent
post_via_redirect registrar_id_card_sign_in_path, nil, 'SSL_CLIENT_S_DN_CN' => ''
post registrar_id_card_sign_in_path, headers: { 'SSL_CLIENT_S_DN_CN' => '' }
assert_nil controller.current_registrar_user
assert_equal registrar_id_card_sign_in_path, path

View file

@ -0,0 +1,23 @@
require 'test_helper'
class ReppV1AuctionsTest < ActionDispatch::IntegrationTest
setup do
@auction = auctions(:one)
@auction.update!(uuid: '1b3ee442-e8fe-4922-9492-8fcb9dccc69c',
domain: 'auction.test',
status: Auction.statuses[:started])
end
def test_get_index
get repp_v1_auctions_path
response_json = JSON.parse(response.body, symbolize_names: true)
assert response_json[:count] == 1
expected_response = [{ domain_name: @auction.domain,
punycode_domain_name: @auction.domain }]
assert_equal expected_response, response_json[:auctions]
end
end

View file

@ -0,0 +1,117 @@
require 'test_helper'
class ReppV1RetainedDomainsTest < ActionDispatch::IntegrationTest
# Uses magical fixtures, will fail once fixtures inside are changed:
# test/fixtures/blocked_domains.yml
# test/fixtures/reserved_domains.yml
def test_get_index
get repp_v1_retained_domains_path
response_json = JSON.parse(response.body, symbolize_names: true)
assert response_json[:count] == 3
expected_objects = [{ name: 'blocked.test',
status: 'blocked',
punycode_name: 'blocked.test' },
{ name: 'blockedäöüõ.test',
status: 'blocked',
punycode_name: 'xn--blocked-cxa7mj0e.test' },
{ name: 'reserved.test',
status: 'reserved',
punycode_name: 'reserved.test' }]
assert_equal response_json[:domains], expected_objects
end
def test_get_index_with_type_parameter
get repp_v1_retained_domains_path({ 'type' => 'reserved' })
response_json = JSON.parse(response.body, symbolize_names: true)
assert response_json[:count] == 1
expected_objects = [{ name: 'reserved.test',
status: 'reserved',
punycode_name: 'reserved.test' }]
assert_equal response_json[:domains], expected_objects
end
def test_get_index_disputed_type
dispute = Dispute.new(domain_name: 'disputed.test', starts_at: Time.zone.today, password: 'disputepw')
dispute.save
get repp_v1_retained_domains_path({ 'type' => 'disputed' })
response_json = JSON.parse(response.body, symbolize_names: true)
assert response_json[:count] == 1
expected_objects = [{ name: 'disputed.test',
status: 'disputed',
punycode_name: 'disputed.test' }]
assert_equal response_json[:domains], expected_objects
end
# A disputed domain can be also reserved, and according
# to business rules it should appear on the list twice.
def test_domain_can_appear_twice_if_it_is_disputed_and_reserved
dispute = Dispute.new(domain_name: 'reserved.test', starts_at: Time.zone.today, password: 'disputepw')
dispute.save
get repp_v1_retained_domains_path
response_json = JSON.parse(response.body, symbolize_names: true)
assert response_json[:count] == 4
expected_objects = [{ name: 'blocked.test',
status: 'blocked',
punycode_name: 'blocked.test' },
{ name: 'blockedäöüõ.test',
status: 'blocked',
punycode_name: 'xn--blocked-cxa7mj0e.test' },
{ name: 'reserved.test',
status: 'reserved',
punycode_name: 'reserved.test' },
{ name: 'reserved.test',
status: 'disputed',
punycode_name: 'reserved.test' }]
assert_equal response_json[:domains], expected_objects
end
def test_etags_cache
get repp_v1_retained_domains_path({ 'type' => 'reserved' })
etag = response.headers['ETag']
get repp_v1_retained_domains_path({ 'type' => 'reserved' }),
headers: { 'If-None-Match' => etag }
assert_equal response.status, 304
assert_equal response.body, ''
end
def test_etags_cache_valid_for_type_only
get repp_v1_retained_domains_path({ 'type' => 'blocked' })
etag = response.headers['ETag']
get repp_v1_retained_domains_path, headers: { 'If-None-Match' => etag }
assert_equal response.status, 200
response_json = JSON.parse(response.body, symbolize_names: true)
assert response_json[:count] == 3
end
def test_cors_preflight
process :options, repp_v1_retained_domains_path, headers: { 'Origin' => 'https://example.com' }
assert_equal('https://example.com', response.headers['Access-Control-Allow-Origin'])
assert_equal('POST, GET, PUT, PATCH, DELETE, OPTIONS',
response.headers['Access-Control-Allow-Methods'])
assert_equal('Origin, Content-Type, Accept, Authorization, Token, Auth-Token, Email, ' \
'X-User-Token, X-User-Email',
response.headers['Access-Control-Allow-Headers'])
assert_equal('3600', response.headers['Access-Control-Max-Age'])
assert_equal('', response.body)
end
end

View file

@ -1,61 +0,0 @@
require 'test_helper'
class RegenerateRegistrarReferenceNumbersTaskTest < ActiveSupport::TestCase
def test_regenerates_registrar_reference_numbers_to_estonian_format
registrar = registrars(:bestnames)
registrar.update_column(:reference_no, 'RF1111')
capture_io { run_task }
registrar.reload
assert_not registrar.reference_no.start_with?('RF')
end
def test_bypasses_registrar_validation
registrar = registrars(:invalid)
registrar.update_column(:reference_no, 'RF1111')
assert registrar.invalid?
capture_io { run_task }
registrar.reload
assert_not registrar.reference_no.start_with?('RF')
end
def test_does_not_regenerate_when_the_task_is_run_again
registrar = registrars(:bestnames)
registrar.update!(reference_no: '1111')
capture_io { run_task }
registrar.reload
assert_equal '1111', registrar.reference_no
end
def test_keeps_iso_reference_number_on_the_invoice_unchanged
registrar = registrars(:bestnames)
registrar.update_column(:reference_no, 'RF1111')
invoice = invoices(:one)
invoice.update!(reference_no: 'RF2222')
capture_io { run_task }
invoice.reload
assert_equal 'RF2222', invoice.reference_no
end
def test_output
registrar = registrars(:bestnames)
registrar.update_column(:reference_no, 'RF1111')
assert_output "Registrars processed: 1\n" do
run_task
end
end
private
def run_task
Rake::Task['data_migrations:regenerate_registrar_reference_numbers'].execute
end
end

View file

@ -0,0 +1,154 @@
require "test_helper"
class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
setup do
@invoice = invoices(:one)
@user = registrars(:bestnames)
travel_to Time.zone.parse('2010-08-06')
end
def teardown
Setting.directo_monthly_number_min = 309901
Setting.directo_monthly_number_max = 309999
Setting.directo_monthly_number_last = 309901
end
def test_directo_json_sends_customer_as_hash
@invoice.update!(buyer_country_code: @user.address_country_code)
json_output = @invoice.as_directo_json
assert json_output['customer'].is_a? Hash
assert_equal @user.accounting_customer_code, json_output['customer']['code']
assert_equal @user.address_country_code, json_output['customer']['destination']
end
def test_xml_is_include_transaction_date
@invoice.update(total: @invoice.account_activity.bank_transaction.sum)
@invoice.account_activity.bank_transaction.update(paid_at: Time.zone.now)
response = <<-XML
<?xml version="1.0" encoding="UTF-8"?>
<results>
<Result Type="0" Desc="OK" docid="1" doctype="ARVE" submit="Invoices"/>
</results>
XML
stub_request(:post, ENV['directo_invoice_url']).with do |request|
request.body.include? 'TransactionDate'
end.to_return(status: 200, body: response)
assert_nothing_raised do
DirectoInvoiceForwardJob.run(monthly: false, dry: false)
end
assert_not_empty @invoice.directo_records.first.request
end
def test_fails_if_directo_bounds_exceedable
activity = account_activities(:one)
price = billing_prices(:create_one_year)
activity.update!(activity_type: 'create', price: price)
Setting.directo_monthly_number_max = 30991
assert_raises 'RuntimeError' do
DirectoInvoiceForwardJob.run(monthly: true, dry: false)
end
end
def test_monthly_summary_is_delivered_in_estonian
activity = account_activities(:one)
price = billing_prices(:create_one_year)
activity.update!(activity_type: 'create', price: price)
@user.update(language: 'et')
response = <<-XML
<?xml version="1.0" encoding="UTF-8"?>
<results>
<Result Type="0" Desc="OK" docid="309902" doctype="ARVE" submit="Invoices"/>
</results>
XML
stub_request(:post, ENV['directo_invoice_url']).with do |request|
body = CGI.unescape(request.body)
(body.include? '.test registreerimine: 1 aasta(t)') &&
(body.include? 'Domeenide ettemaks') &&
(body.include? '309902')
end.to_return(status: 200, body: response)
assert_difference 'Setting.directo_monthly_number_last' do
DirectoInvoiceForwardJob.run(monthly: true, dry: false)
end
end
def test_monthly_summary_is_delivered_in_english
activity = account_activities(:one)
price = billing_prices(:create_one_year)
activity.update(activity_type: 'create', price: price)
@user.update(language: 'en')
response = <<-XML
<?xml version="1.0" encoding="UTF-8"?>
<results>
<Result Type="0" Desc="OK" docid="309902" doctype="ARVE" submit="Invoices"/>
</results>
XML
stub_request(:post, ENV['directo_invoice_url']).with do |request|
body = CGI.unescape(request.body)
(body.include? 'test registration') &&
(body.include? 'Domains prepayment') &&
(body.include? '309902')
end.to_return(status: 200, body: response)
assert_difference 'Setting.directo_monthly_number_last' do
DirectoInvoiceForwardJob.run(monthly: true, dry: false)
end
end
def test_multi_year_purchases_have_duration_assigned
activity = account_activities(:one)
price = billing_prices(:create_one_year)
price.update(duration: '3 years')
activity.update(activity_type: 'create', price: price)
response = <<-XML
<?xml version="1.0" encoding="UTF-8"?>
<results>
<Result Type="0" Desc="OK" docid="309902" doctype="ARVE" submit="Invoices"/>
</results>
XML
stub_request(:post, ENV['directo_invoice_url']).with do |request|
body = CGI.unescape(request.body)
(body.include? 'StartDate') && (body.include? 'EndDate')
end.to_return(status: 200, body: response)
assert_difference 'Setting.directo_monthly_number_last' do
DirectoInvoiceForwardJob.run(monthly: true, dry: false)
end
end
def test_monthly_duration_products_are_present_in_summary
activity = account_activities(:one)
price = billing_prices(:create_one_month)
activity.update(activity_type: 'create', price: price)
response = <<-XML
<?xml version="1.0" encoding="UTF-8"?>
<results>
<Result Type="0" Desc="OK" docid="309902" doctype="ARVE" submit="Invoices"/>
</results>
XML
stub_request(:post, ENV['directo_invoice_url']).with do |request|
body = CGI.unescape(request.body)
body.include? 'month(s)'
end.to_return(status: 200, body: response)
assert_difference 'Setting.directo_monthly_number_last' do
DirectoInvoiceForwardJob.run(monthly: true, dry: false)
end
end
end

View file

@ -0,0 +1,70 @@
require "test_helper"
class DisputeStatusUpdateJobTest < ActiveSupport::TestCase
setup do
travel_to Time.zone.parse('2010-10-05')
@logger = Rails.logger
end
def test_nothing_is_raised
assert_nothing_raised do
DisputeStatusUpdateJob.run(logger: @logger)
end
end
def test_whois_data_added_when_dispute_activated
dispute = disputes(:future)
DisputeStatusUpdateJob.run(logger: @logger)
whois_record = Whois::Record.find_by(name: dispute.domain_name)
assert whois_record.present?
assert_includes whois_record.json['status'], 'disputed'
end
def test_on_expiry_unregistered_domain_is_sent_to_auction
dispute = disputes(:active)
dispute.update!(starts_at: Time.zone.today - 3.years - 1.day)
DisputeStatusUpdateJob.run(logger: @logger)
dispute.reload
assert dispute.closed
whois_record = Whois::Record.find_by(name: dispute.domain_name)
assert_equal ['AtAuction'], whois_record.json['status']
end
def test_registered_domain_whois_data_is_added
Dispute.create(domain_name: 'shop.test', starts_at: '2010-07-05')
travel_to Time.zone.parse('2010-07-05')
DisputeStatusUpdateJob.run(logger: @logger)
whois_record = Whois::Record.find_by(name: 'shop.test')
assert_includes whois_record.json['status'], 'disputed'
end
def test_registered_domain_whois_data_is_removed
travel_to Time.zone.parse('2010-07-05')
domain = domains(:shop)
domain.update(valid_to: Time.zone.parse('2015-07-05').to_s(:db),
outzone_at: Time.zone.parse('2015-07-06').to_s(:db),
delete_date: nil,
force_delete_date: nil)
# Dispute status is added automatically if starts_at is not in future
Dispute.create(domain_name: 'shop.test', starts_at: Time.zone.parse('2010-07-05'))
domain.reload
whois_record = Whois::Record.find_by(name: 'shop.test')
assert_includes whois_record.json['status'], 'disputed'
# Dispute status is removed night time day after it's ended
travel_to Time.zone.parse('2010-07-05') + 3.years + 1.day
DisputeStatusUpdateJob.run(logger: @logger)
whois_record.reload
assert_not whois_record.json['status'].include? 'disputed'
end
end

View file

@ -1,17 +1,11 @@
require "test_helper"
class DomainDeleteConfirmJobTest < ActiveSupport::TestCase
def setup
super
setup do
@legal_doc_path = 'test/fixtures/files/legaldoc.pdf'
@domain = domains(:shop)
@new_registrant = contacts(:william)
@user = users(:api_bestnames)
@domain.update!(pending_json: { new_registrant_id: @new_registrant.id,
new_registrant_name: @new_registrant.name,
new_registrant_email: @new_registrant.email,
current_user_id: @user.id })
end
def teardown
@ -19,6 +13,11 @@ class DomainDeleteConfirmJobTest < ActiveSupport::TestCase
end
def test_rejected_registrant_verification_notifies_registrar
@domain.update!(pending_json: { new_registrant_id: @new_registrant.id,
new_registrant_name: @new_registrant.name,
new_registrant_email: @new_registrant.email,
current_user_id: @user.id })
DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED)
last_registrar_notification = @domain.registrar.notifications.last
@ -27,10 +26,57 @@ class DomainDeleteConfirmJobTest < ActiveSupport::TestCase
end
def test_accepted_registrant_verification_notifies_registrar
@domain.update!(pending_json: { new_registrant_id: @new_registrant.id,
new_registrant_name: @new_registrant.name,
new_registrant_email: @new_registrant.email,
current_user_id: @user.id })
DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED)
last_registrar_notification = @domain.registrar.notifications.last
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
assert_equal(last_registrar_notification.text, 'Registrant confirmed domain deletion: shop.test')
end
def test_marks_domain_as_pending_delete_after_acceptance
epp_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<epp>\n <command>\n <delete>\n" \
" <delete verified=\"no\">\n <name>#{@domain.name}</name>\n </delete>\n </delete>\n <extension>\n" \
" <extdata>\n <legalDocument type=\"pdf\">#{@legal_doc_path}</legalDocument>\n" \
" </extdata>\n </extension>\n <clTRID>20alla-1594212240</clTRID>\n </command>\n</epp>\n"
@domain.registrant_verification_asked!(epp_xml, @user.id)
@domain.pending_delete!
@domain.reload
assert @domain.registrant_delete_confirmable?(@domain.registrant_verification_token)
assert_equal @user.id, @domain.pending_json['current_user_id']
DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED)
@domain.reload
assert @domain.statuses.include? DomainStatus::PENDING_DELETE
assert @domain.statuses.include? DomainStatus::SERVER_HOLD
assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE_CONFIRMATION
end
def test_clears_pending_flags_after_delete_denial
epp_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<epp>\n <command>\n <delete>\n" \
" <delete verified=\"no\">\n <name>#{@domain.name}</name>\n </delete>\n </delete>\n <extension>\n" \
" <extdata>\n <legalDocument type=\"pdf\">#{@legal_doc_path}</legalDocument>\n" \
" </extdata>\n </extension>\n <clTRID>20alla-1594212240</clTRID>\n </command>\n</epp>\n"
@domain.registrant_verification_asked!(epp_xml, @user.id)
@domain.pending_delete!
@domain.reload
assert @domain.registrant_delete_confirmable?(@domain.registrant_verification_token)
assert_equal @user.id, @domain.pending_json['current_user_id']
DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED)
@domain.reload
assert_equal ['ok'], @domain.statuses
assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE_CONFIRMATION
assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE
end
end

Some files were not shown because too many files have changed in this diff Show more