Commit 1c278fd9 authored by James Lopez's avatar James Lopez

update applications controllers to log audit events. Added specs.

parent c180f007
...@@ -22,6 +22,8 @@ class Admin::ApplicationsController < Admin::ApplicationController ...@@ -22,6 +22,8 @@ class Admin::ApplicationsController < Admin::ApplicationController
@application = Doorkeeper::Application.new(application_params) @application = Doorkeeper::Application.new(application_params)
if @application.save if @application.save
log_audit_event
flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create]) flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create])
redirect_to admin_application_url(@application) redirect_to admin_application_url(@application)
else else
......
...@@ -21,6 +21,8 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController ...@@ -21,6 +21,8 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
@application.owner = current_user @application.owner = current_user
if @application.save if @application.save
log_audit_event
flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create]) flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create])
redirect_to oauth_application_url(@application) redirect_to oauth_application_url(@application)
else else
......
...@@ -38,6 +38,7 @@ describe Admin::ApplicationsController do ...@@ -38,6 +38,7 @@ describe Admin::ApplicationsController do
expect(response).to redirect_to(admin_application_path(application)) expect(response).to redirect_to(admin_application_path(application))
expect(application).to have_attributes(create_params.except(:uid, :owner_type)) expect(application).to have_attributes(create_params.except(:uid, :owner_type))
expect(SecurityEvent.count).to eq(1)
end end
it 'renders the application form on errors' do it 'renders the application form on errors' do
......
...@@ -25,5 +25,16 @@ describe Oauth::ApplicationsController do ...@@ -25,5 +25,16 @@ describe Oauth::ApplicationsController do
expect(response).to redirect_to(profile_path) expect(response).to redirect_to(profile_path)
end end
end end
describe 'POST #create' do
it 'logs the audit event' do
sign_in(user)
application = build(:oauth_application)
application_attributes = application.attributes.merge(scopes: [])
expect { post :create, doorkeeper_application: application_attributes }.to change{ SecurityEvent.count }.by(1)
end
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment