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

Commit

Permalink
Fix bug/specs for grading
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Claudius committed Jan 19, 2018
1 parent fe56166 commit ceaabad
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 40 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
36 changes: 18 additions & 18 deletions spec/ssh_scan/grader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
it "should provide an F grade" do
result = SSHScan::Result.new()
result.set_compliance = {
:policy => "Test Result",
:compliant => false,
:recommendations => [
"policy" => "Test Result",
"compliant" => false,
"recommendations" => [
"Add these Key Exchange Algos: ecdh-sha2-nistp521,ecdh-sha2-nistp384,diffie-hellman-group-exchange-sha256",
"Add these MAC Algos: [email protected],[email protected],[email protected],[email protected]",
"Add these Encryption Ciphers: [email protected],[email protected]",
Expand All @@ -24,9 +24,9 @@
it "should provide an F grade" do
result = SSHScan::Result.new()
result.set_compliance = {
:policy => "Test Result",
:compliant => false,
:recommendations => [
"policy" => "Test Result",
"compliant" => false,
"recommendations" => [
"Add these Key Exchange Algos: ecdh-sha2-nistp521,ecdh-sha2-nistp384,diffie-hellman-group-exchange-sha256",
"Add these MAC Algos: [email protected],[email protected],[email protected],[email protected]",
"Add these Encryption Ciphers: [email protected],[email protected]",
Expand All @@ -40,9 +40,9 @@
it "should provide an D grade" do
result = SSHScan::Result.new()
result.set_compliance = {
:policy => "Test Result",
:compliant => false,
:recommendations => [
"policy" => "Test Result",
"compliant" => false,
"recommendations" => [
"Add these Key Exchange Algos: ecdh-sha2-nistp521,ecdh-sha2-nistp384,diffie-hellman-group-exchange-sha256",
"Add these MAC Algos: [email protected],[email protected],[email protected],[email protected]",
"Add these Encryption Ciphers: [email protected],[email protected]",
Expand All @@ -55,9 +55,9 @@
it "should provide an C grade" do
result = SSHScan::Result.new()
result.set_compliance = {
:policy => "Test Result",
:compliant => false,
:recommendations => [
"policy" => "Test Result",
"compliant" => false,
"recommendations" => [
"Add these Key Exchange Algos: ecdh-sha2-nistp521,ecdh-sha2-nistp384,diffie-hellman-group-exchange-sha256",
"Add these MAC Algos: [email protected],[email protected],[email protected],[email protected]",
]
Expand All @@ -69,9 +69,9 @@
it "should provide an B grade" do
result = SSHScan::Result.new()
result.set_compliance = {
:policy => "Test Result",
:compliant => false,
:recommendations => [
"policy" => "Test Result",
"compliant" => false,
"recommendations" => [
"Add these Key Exchange Algos: ecdh-sha2-nistp521,ecdh-sha2-nistp384,diffie-hellman-group-exchange-sha256",
]
}
Expand All @@ -82,9 +82,9 @@
it "should provide an A grade" do
result = SSHScan::Result.new()
result.set_compliance = {
:policy => "Test Result",
:compliant => false,
:recommendations => [
"policy" => "Test Result",
"compliant" => false,
"recommendations" => [
]
}
grader = SSHScan::Grader.new(result)
Expand Down
40 changes: 20 additions & 20 deletions spec/ssh_scan/result_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,49 +179,49 @@
context "when setting compliance" do
it "should allow setting of the compliance information" do
compliance = {
:policy => "Test Policy",
:compliant => true,
:recommendations => ["do this", "do that"],
:references => ["https://reference.example.com"],
"policy" => "Test Policy",
"compliant" => true,
"recommendations" => ["do this", "do that"],
"references" => ["https://reference.example.com"],
}
result = SSHScan::Result.new()
result.set_compliance = compliance

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.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.to_hash).to be_kind_of(Hash)
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"],
"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.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

context "when dealing with errors" do
it "should append errors " do
compliance = {
:policy => "Test Policy",
:compliant => true,
:recommendations => ["do this", "do that"],
:references => ["https://reference.example.com"],
"policy" => "Test Policy",
"compliant" => true,
"recommendations" => ["do this", "do that"],
"references" => ["https://reference.example.com"],
}
result = SSHScan::Result.new()
result.set_compliance = compliance
Expand Down

0 comments on commit ceaabad

Please sign in to comment.