Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check scan required based on wildcard in talismancr
- Loading branch information
Showing
14 changed files
with
87 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,30 @@ | ||
package detector | ||
|
||
import ( | ||
"talisman/utility" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"talisman/gitrepo" | ||
"talisman/talismanrc" | ||
"testing" | ||
) | ||
|
||
func TestShouldReturnCorrectFileHash(t *testing.T) { | ||
checksumSomeFile := utility.CollectiveSHA256Hash([]string{"some_file.pem"}) | ||
checksumTestSomeFile := utility.CollectiveSHA256Hash([]string{"test/some_file.pem"}) | ||
assert.Equal(t, checksumSomeFile, "87139cc4d975333b25b6275f97680604add51b84eb8f4a3b9dcbbc652e6f27ac", "Should be equal to some_file.pem hash value") | ||
assert.Equal(t, checksumTestSomeFile, "25bd31a28bf9d4e06327f1c4a5cab2260574ae508803f66adcc393350e994866", "Should be equal to test/some_file.pem hash value") | ||
} | ||
func TestChecksumCompare_IsScanNotRequired(t *testing.T) { | ||
|
||
t.Run("should return false if talismanrc is empty", func(t *testing.T) { | ||
ignoreConfig := talismanrc.NewTalismanRC(nil) | ||
cc := NewChecksumCompare([]gitrepo.Addition{}, []gitrepo.Addition{}, ignoreConfig) | ||
|
||
required := cc.IsScanNotRequired(gitrepo.Addition{}) | ||
|
||
assert.False(t, required) | ||
}) | ||
|
||
t.Run("should return false if talismanrc is empty", func(t *testing.T) { | ||
ignoreConfig := talismanrc.NewTalismanRC(nil) | ||
cc := NewChecksumCompare([]gitrepo.Addition{}, []gitrepo.Addition{}, ignoreConfig) | ||
|
||
required := cc.IsScanNotRequired(gitrepo.Addition{}) | ||
|
||
assert.False(t, required) | ||
}) | ||
|
||
func TestShouldReturnEmptyFileHashWhenNoPathsPassed(t *testing.T) { | ||
checksum := utility.CollectiveSHA256Hash([]string{}) | ||
assert.Equal(t, checksum, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "Should be equal to empty hash value when no paths passed") | ||
} |
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
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
Oops, something went wrong.