-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
660 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
class Record < ApplicationRecord | ||
belongs_to :feedback | ||
|
||
def update_from_hash(raw_record) | ||
self.source_ip = raw_record.dig('row', 'source_ip') | ||
self.count = raw_record.dig('row', 'count').to_i | ||
self.policy_evaluated = raw_record.dig('row', 'policy_evaluated') | ||
self.identifiers = raw_record['identifiers'] | ||
self.auth_results = raw_record['auth_results'] | ||
|
||
save | ||
end | ||
|
||
def dkim_valid? | ||
auth_results.dig('dkim', 'result') == 'pass' | ||
end | ||
|
||
def spf_valid? | ||
auth_results.dig('spf', 'result') == 'pass' | ||
end | ||
|
||
def fully_valid? | ||
dkim_valid? && spf_valid? | ||
end | ||
|
||
def partially_valid? | ||
dkim_valid? || spf_valid? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
db/migrate/20240210225602_add_policy_published_to_feedback.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddPolicyPublishedToFeedback < ActiveRecord::Migration[7.1] | ||
def change | ||
add_column :feedbacks, :policy_published, :json | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20240211142524_change_feedback_report_i_dto_string.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class ChangeFeedbackReportIDtoString < ActiveRecord::Migration[7.1] | ||
def change | ||
change_column :feedbacks, :report_id, :string | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class CreateRecords < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :records do |t| | ||
t.belongs_to :feedback, null: false, foreign_key: true | ||
t.string :source_ip | ||
t.integer :count | ||
t.json :policy_evaluated | ||
t.json :identifiers | ||
t.json :auth_results | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe DomainsController do | ||
context 'with an unauthenticated user' do | ||
describe 'GET /' do | ||
before do | ||
get :index | ||
end | ||
|
||
it { is_expected.to respond_with(200) } | ||
end | ||
|
||
describe 'GET /domains/:id' do | ||
before do | ||
get :show, params: { id: Domain.create!(name: 'controller.domain').id } | ||
end | ||
|
||
it { is_expected.to respond_with(200) } | ||
it { is_expected.to use_before_action(:set_domain) } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe HomeController do | ||
describe 'GET /' do | ||
context 'with an unauthenticated user' do | ||
before do | ||
get :index | ||
end | ||
|
||
it { is_expected.to respond_with(200) } | ||
end | ||
end | ||
end |
Oops, something went wrong.