[add] added maximum client and demo client protection

- default demo clients can no longer be modified/deleted when in demo mode
 - increased default demo reset to 60 minutes
This commit is contained in:
2021-02-25 12:52:23 -05:00
parent 472ae4c90f
commit 5868377210
7 changed files with 60 additions and 7 deletions

View File

@@ -160,6 +160,20 @@ RSpec.describe 'Clients', type: :request do
expect(response).to have_http_status(200)
end
end
context 'when sending a valid request to add another client above the MAX_CLIENTS limit' do
before do
clients_to_create = RynDNS::Application::MAX_CLIENTS - Client.count
create_list(:client, clients_to_create)
post '/admin/client', params: { name: 'extra_user' }, headers: api_key_header(admin_client)
end
it 'does not add another client and returns status code 429' do
expect(Client.count).to eq RynDNS::Application::MAX_CLIENTS
expect(response.body).to be_empty
expect(response).to have_http_status(429)
end
end
end
describe 'PUT /admin/client' do