Browse Source

Fix validates :sign_count of WebauthnCredential (#14806)

master
kawaguchi 3 years ago
committed by GitHub
parent
commit
5d3c8baa9a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions
  1. +1
    -1
      app/models/webauthn_credential.rb
  2. +2
    -2
      spec/models/webauthn_credentials_spec.rb

+ 1
- 1
app/models/webauthn_credential.rb View File

@ -18,5 +18,5 @@ class WebauthnCredential < ApplicationRecord
validates :external_id, uniqueness: true
validates :nickname, uniqueness: { scope: :user_id }
validates :sign_count,
numericality: { only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 2**32 - 1 }
numericality: { only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 2**63 - 1 }
end

+ 2
- 2
spec/models/webauthn_credentials_spec.rb View File

@ -69,8 +69,8 @@ RSpec.describe WebauthnCredential, type: :model do
expect(webauthn_credential).to model_have_error_on_field(:sign_count)
end
it 'is invalid if sign_count is greater 2**32 - 1' do
webauthn_credential = Fabricate.build(:webauthn_credential, sign_count: 2**32)
it 'is invalid if sign_count is greater 2**63 - 1' do
webauthn_credential = Fabricate.build(:webauthn_credential, sign_count: 2**63)
webauthn_credential.valid?

Loading…
Cancel
Save