Skip to content

Commit

Permalink
Adjusted code after review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fhoeborn committed Mar 25, 2024
1 parent 9af3a79 commit a334d0b
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 20 deletions.
4 changes: 1 addition & 3 deletions checks/evaluation/permissive_license_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ func TestPermissiveLicense(t *testing.T) {
t.Parallel()
dl := scut.TestDetailLogger{}
got := PermissiveLicense(tt.name, tt.findings, &dl)
if !scut.ValidateTestReturn(t, tt.name, &tt.result, &got, &dl) {
t.Errorf("got %v, expected %v", got, tt.result)
}
scut.ValidateTestReturn(t, tt.name, &tt.result, &got, &dl)
})
}
}
4 changes: 1 addition & 3 deletions checks/permissive_license_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ func TestPermissiveLicenseFileSubdirectory(t *testing.T) {

res := PermissiveLicense(&req)

if !scut.ValidateTestReturn(t, tt.name, &tt.expected, &res, &dl) {
t.Fail()
}
scut.ValidateTestReturn(t, tt.name, &tt.expected, &res, &dl)

ctrl.Finish()
})
Expand Down
16 changes: 8 additions & 8 deletions e2e/license_permissive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ var _ = Describe("E2E TEST:"+checks.CheckLicense, func() {
}
result := checks.PermissiveLicense(&req)

Expect(scut.ValidateTestReturn(nil, "license found", &expected, &result,
&dl)).Should(BeTrue())
scut.ValidateTestReturn(GinkgoTB(), "license found", &expected, &result,
&dl)
})
It("Should return permissive license check works at commitSHA", func() {
dl := scut.TestDetailLogger{}
Expand All @@ -77,8 +77,8 @@ var _ = Describe("E2E TEST:"+checks.CheckLicense, func() {
}
result := checks.PermissiveLicense(&req)

Expect(scut.ValidateTestReturn(nil, "license found", &expected, &result,
&dl)).Should(BeTrue())
scut.ValidateTestReturn(GinkgoTB(), "license found", &expected, &result,
&dl)
})
It("Should return permissive license check works - GitLab", func() {
skipIfTokenIsNot(gitlabPATTokenType, "GitLab only")
Expand All @@ -103,8 +103,8 @@ var _ = Describe("E2E TEST:"+checks.CheckLicense, func() {
}
result := checks.PermissiveLicense(&req)

Expect(scut.ValidateTestReturn(nil, "license found", &expected, &result,
&dl)).Should(BeTrue())
scut.ValidateTestReturn(GinkgoTB(), "license found", &expected, &result,
&dl)
})
It("Should return permissive license check works at commitSHA - GitLab", func() {
skipIfTokenIsNot(gitlabPATTokenType, "GitLab only")
Expand All @@ -129,8 +129,8 @@ var _ = Describe("E2E TEST:"+checks.CheckLicense, func() {
}
result := checks.PermissiveLicense(&req)

Expect(scut.ValidateTestReturn(nil, "license found", &expected, &result,
&dl)).Should(BeTrue())
scut.ValidateTestReturn(GinkgoTB(), "license found", &expected, &result,
&dl)
})
})
})
2 changes: 1 addition & 1 deletion probes/hasPermissiveLicense/def.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ implementation: >
The implementation checks whether a permissive license is present
outcome:
- If a license file is found and is permissive, the probe returns a single OutcomePositive.
- If a license file is missing the probe returns a single OutcomeNotApplicable.
- If a license file is missing the probe returns a single OutcomeNegative.
- If the license is not permissive, the probe returns a single OutcomeNegative.
remediation:
effort: High
Expand Down
4 changes: 2 additions & 2 deletions probes/hasPermissiveLicense/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ func Run(raw *checker.RawResults) ([]finding.Finding, string, error) {
return nil, "", fmt.Errorf("%w: raw", uerror.ErrNil)
}

if raw.LicenseResults.LicenseFiles == nil || len(raw.LicenseResults.LicenseFiles) == 0 {
if len(raw.LicenseResults.LicenseFiles) == 0 {
f, err := finding.NewWith(fs, Probe,
"project does not have a license file", nil,
finding.OutcomeNotApplicable)
finding.OutcomeNegative)
if err != nil {
return nil, Probe, fmt.Errorf("create finding: %w", err)
}
Expand Down
6 changes: 3 additions & 3 deletions probes/hasPermissiveLicense/impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func Test_Run(t *testing.T) {
},
},
outcomes: []finding.Outcome{
finding.OutcomeNotApplicable,
finding.OutcomeNegative,
},
},
{
Expand All @@ -94,7 +94,7 @@ func Test_Run(t *testing.T) {
},
},
outcomes: []finding.Outcome{
finding.OutcomeNotApplicable,
finding.OutcomeNegative,
},
},
{
Expand All @@ -105,7 +105,7 @@ func Test_Run(t *testing.T) {
},
},
outcomes: []finding.Outcome{
finding.OutcomeNotApplicable,
finding.OutcomeNegative,
},
},
}
Expand Down

0 comments on commit a334d0b

Please sign in to comment.