Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Commit

Permalink
Fix grader bug due to result setting madness
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Claudius committed Jun 14, 2017
1 parent 4a0b9db commit 73049e9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/ssh_scan/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ def error
end

def grade=(grade)
@compliance_grade = grade
@compliance[:grade] = grade
end

def grade
@compliance_grade
@compliance[:grade]
end

def to_hash
Expand Down
3 changes: 1 addition & 2 deletions lib/ssh_scan/scan_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,7 @@ def scan(opts)
result.set_compliance = policy_mgr.compliance_results

if result.compliance_policy
grader = SSHScan::Grader.new(result)
result.grade = grader.grade
result.grade = SSHScan::Grader.new(result).grade
end
end
end
Expand Down
21 changes: 21 additions & 0 deletions spec/ssh_scan/result_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,25 @@
expect(result.compliance_references).to eql(compliance[:references])
end
end

context "when setting grade" do
it "should allow setting of the grade information" do
compliance = {
:policy => "Test Policy",
:compliant => true,
:recommendations => ["do this", "do that"],
:references => ["https://reference.example.com"],
}
result = SSHScan::Result.new()
result.set_compliance = compliance
result.grade = "D"

expect(result.compliance_policy).to eql(compliance[:policy])
expect(result.compliant?).to eql(compliance[:compliant])
expect(result.compliance_recommendations).to eql(compliance[:recommendations])
expect(result.compliance_references).to eql(compliance[:references])
expect(result.grade).to eql("D")
end
end

end

0 comments on commit 73049e9

Please sign in to comment.