mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 01:47:18 +02:00
parent
1784980e6c
commit
fd58024226
2 changed files with 13 additions and 3 deletions
|
@ -11,12 +11,16 @@ class ApiUser < User
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.min_password_length # Must precede .validates
|
||||||
|
6
|
||||||
|
end
|
||||||
|
|
||||||
# TODO: should have max request limit per day?
|
# TODO: should have max request limit per day?
|
||||||
belongs_to :registrar
|
belongs_to :registrar
|
||||||
has_many :certificates
|
has_many :certificates
|
||||||
|
|
||||||
validates :username, :password, :registrar, :roles, presence: true
|
validates :username, :password, :registrar, :roles, presence: true
|
||||||
validates :password, length: { minimum: 6 }
|
validates :password, length: { minimum: min_password_length }
|
||||||
validates :username, uniqueness: true
|
validates :username, uniqueness: true
|
||||||
|
|
||||||
# TODO: probably cache, because it's requested on every EPP
|
# TODO: probably cache, because it's requested on every EPP
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe ApiUser do
|
RSpec.describe ApiUser do
|
||||||
context 'class methods' do
|
context 'class methods' do
|
||||||
before do
|
before do
|
||||||
Fabricate(:api_user, identity_code: '')
|
Fabricate(:api_user, identity_code: '')
|
||||||
|
@ -26,7 +26,7 @@ describe ApiUser do
|
||||||
@api_user.valid?
|
@api_user.valid?
|
||||||
@api_user.errors.full_messages.should match_array([
|
@api_user.errors.full_messages.should match_array([
|
||||||
"Password Password is missing",
|
"Password Password is missing",
|
||||||
"Password is too short (minimum is 6 characters)",
|
"Password is too short (minimum is #{ApiUser.min_password_length} characters)",
|
||||||
"Registrar Registrar is missing",
|
"Registrar Registrar is missing",
|
||||||
"Username Username is missing",
|
"Username Username is missing",
|
||||||
"Roles is missing"
|
"Roles is missing"
|
||||||
|
@ -68,4 +68,10 @@ describe ApiUser do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '::min_password_length', db: false do
|
||||||
|
it 'returns minimum password length' do
|
||||||
|
expect(described_class.min_password_length).to eq(6)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue