Merge pull request #9880 from demarches-simplifiees/api_token_store_last_used_ips
API: stocke les ips utilisées pour accéder à l'API
This commit is contained in:
commit
6f7d786783
6 changed files with 36 additions and 1 deletions
|
@ -157,4 +157,24 @@ describe APIToken, type: :model do
|
|||
it { is_expected.to be_nil }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#store_new_ip' do
|
||||
let(:api_token) { APIToken.generate(administrateur).first }
|
||||
let(:ip) { '192.168.0.1' }
|
||||
|
||||
subject do
|
||||
api_token.store_new_ip(ip)
|
||||
api_token.stored_ips
|
||||
end
|
||||
|
||||
context 'when none ip is stored' do
|
||||
it { is_expected.to eq([IPAddr.new(ip)]) }
|
||||
end
|
||||
|
||||
context 'when the ip is already stored' do
|
||||
before { api_token.update!(stored_ips: [ip]) }
|
||||
|
||||
it { is_expected.to eq([IPAddr.new(ip)]) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue