mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 05:04:22 +01:00
adding report-format to tests since we dont parse flags
This commit is contained in:
1 parent
3211cfbbb1
commit
f3eac0c958
1 file changed
+63
-45
+63
-45
@@ -29,136 +29,152 @@ func TestAudit(t *testing.T) {
|
|||||||
{
|
{
|
||||||
description: "test local repo one aws leak",
|
description: "test local repo one aws leak",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
Report: "../test_data/test_local_repo_one_aws_leak.json.got",
|
Report: "../test_data/test_local_repo_one_aws_leak.json.got",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_local_repo_one_aws_leak.json",
|
wantPath: "../test_data/test_local_repo_one_aws_leak.json",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo one aws leak threaded",
|
description: "test local repo one aws leak threaded",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
Threads: runtime.GOMAXPROCS(0),
|
Threads: runtime.GOMAXPROCS(0),
|
||||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
Report: "../test_data/test_local_repo_one_aws_leak.json.got",
|
Report: "../test_data/test_local_repo_one_aws_leak.json.got",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_local_repo_one_aws_leak.json",
|
wantPath: "../test_data/test_local_repo_one_aws_leak.json",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test non existent repo",
|
description: "test non existent repo",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/no_repo_here",
|
RepoPath: "../test_data/test_repos/no_repo_here",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
emptyRepo: true,
|
emptyRepo: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo one aws leak whitelisted",
|
description: "test local repo one aws leak whitelisted",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
Config: "../test_data/test_configs/aws_key_whitelist_python_files.toml",
|
ReportFormat: "json",
|
||||||
|
Config: "../test_data/test_configs/aws_key_whitelist_python_files.toml",
|
||||||
},
|
},
|
||||||
wantEmpty: true,
|
wantEmpty: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo two leaks",
|
description: "test local repo two leaks",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_2",
|
RepoPath: "../test_data/test_repos/test_repo_2",
|
||||||
Report: "../test_data/test_local_repo_two_leaks.json.got",
|
Report: "../test_data/test_local_repo_two_leaks.json.got",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_local_repo_two_leaks.json",
|
wantPath: "../test_data/test_local_repo_two_leaks.json",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo two leaks globally whitelisted",
|
description: "test local repo two leaks globally whitelisted",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_2",
|
RepoPath: "../test_data/test_repos/test_repo_2",
|
||||||
Config: "../test_data/test_configs/aws_key_global_whitelist_file.toml",
|
Config: "../test_data/test_configs/aws_key_global_whitelist_file.toml",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantEmpty: true,
|
wantEmpty: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo two leaks whitelisted",
|
description: "test local repo two leaks whitelisted",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_2",
|
RepoPath: "../test_data/test_repos/test_repo_2",
|
||||||
Config: "../test_data/test_configs/aws_key_whitelist_files.toml",
|
Config: "../test_data/test_configs/aws_key_whitelist_files.toml",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantEmpty: true,
|
wantEmpty: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo three leaks dev branch",
|
description: "test local repo three leaks dev branch",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_3",
|
RepoPath: "../test_data/test_repos/test_repo_3",
|
||||||
Report: "../test_data/test_local_repo_three_leaks.json.got",
|
Report: "../test_data/test_local_repo_three_leaks.json.got",
|
||||||
Config: "../test_data/test_configs/aws_key.toml",
|
Config: "../test_data/test_configs/aws_key.toml",
|
||||||
Branch: "dev",
|
Branch: "dev",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_local_repo_three_leaks.json",
|
wantPath: "../test_data/test_local_repo_three_leaks.json",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo branch does not exist",
|
description: "test local repo branch does not exist",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_3",
|
RepoPath: "../test_data/test_repos/test_repo_3",
|
||||||
Branch: "nobranch",
|
Branch: "nobranch",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantEmpty: true,
|
wantEmpty: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo one aws leak single commit",
|
description: "test local repo one aws leak single commit",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
Report: "../test_data/test_local_repo_one_aws_leak_commit.json.got",
|
Report: "../test_data/test_local_repo_one_aws_leak_commit.json.got",
|
||||||
Commit: "6557c92612d3b35979bd426d429255b3bf9fab74",
|
Commit: "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_local_repo_one_aws_leak_commit.json",
|
wantPath: "../test_data/test_local_repo_one_aws_leak_commit.json",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo one aws leak AND leak on python files",
|
description: "test local repo one aws leak AND leak on python files",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
Report: "../test_data/test_local_repo_one_aws_leak_and_file_leak.json.got",
|
Report: "../test_data/test_local_repo_one_aws_leak_and_file_leak.json.got",
|
||||||
Config: "../test_data/test_configs/aws_key_file_regex.toml",
|
Config: "../test_data/test_configs/aws_key_file_regex.toml",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_local_repo_one_aws_leak_and_file_leak.json",
|
wantPath: "../test_data/test_local_repo_one_aws_leak_and_file_leak.json",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test owner path",
|
description: "test owner path",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
OwnerPath: "../test_data/test_repos/",
|
OwnerPath: "../test_data/test_repos/",
|
||||||
Report: "../test_data/test_local_owner_aws_leak.json.got",
|
Report: "../test_data/test_local_owner_aws_leak.json.got",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_local_owner_aws_leak.json",
|
wantPath: "../test_data/test_local_owner_aws_leak.json",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test entropy",
|
description: "test entropy",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
Report: "../test_data/test_entropy.json.got",
|
Report: "../test_data/test_entropy.json.got",
|
||||||
Config: "../test_data/test_configs/entropy.toml",
|
Config: "../test_data/test_configs/entropy.toml",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_entropy.json",
|
wantPath: "../test_data/test_entropy.json",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test entropy and regex",
|
description: "test entropy and regex",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
Report: "../test_data/test_regex_entropy.json.got",
|
Report: "../test_data/test_regex_entropy.json.got",
|
||||||
Config: "../test_data/test_configs/regex_entropy.toml",
|
Config: "../test_data/test_configs/regex_entropy.toml",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_regex_entropy.json",
|
wantPath: "../test_data/test_regex_entropy.json",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo four entropy alternative config",
|
description: "test local repo four entropy alternative config",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_4",
|
RepoPath: "../test_data/test_repos/test_repo_4",
|
||||||
Report: "../test_data/test_local_repo_four_alt_config_entropy.json.got",
|
Report: "../test_data/test_local_repo_four_alt_config_entropy.json.got",
|
||||||
RepoConfig: true,
|
RepoConfig: true,
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_local_repo_four_alt_config_entropy.json",
|
wantPath: "../test_data/test_local_repo_four_alt_config_entropy.json",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo four entropy alternative config",
|
description: "test local repo four entropy alternative config",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
Report: "../test_data/test_regex_whitelist.json.got",
|
Report: "../test_data/test_regex_whitelist.json.got",
|
||||||
Config: "../test_data/test_configs/aws_key_aws_whitelisted.toml",
|
Config: "../test_data/test_configs/aws_key_aws_whitelisted.toml",
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantEmpty: true,
|
wantEmpty: true,
|
||||||
},
|
},
|
||||||
@@ -222,9 +238,10 @@ func TestAuditUncommited(t *testing.T) {
|
|||||||
{
|
{
|
||||||
description: "test audit local one leak",
|
description: "test audit local one leak",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
Report: "../test_data/test_local_repo_one_aws_leak_uncommitted.json.got",
|
Report: "../test_data/test_local_repo_one_aws_leak_uncommitted.json.got",
|
||||||
Uncommited: true,
|
Uncommited: true,
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantPath: "../test_data/test_local_repo_one_aws_leak_uncommitted.json",
|
wantPath: "../test_data/test_local_repo_one_aws_leak_uncommitted.json",
|
||||||
fileToChange: "server.test.py",
|
fileToChange: "server.test.py",
|
||||||
@@ -233,8 +250,9 @@ func TestAuditUncommited(t *testing.T) {
|
|||||||
{
|
{
|
||||||
description: "test audit local no leak",
|
description: "test audit local no leak",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
RepoPath: "../test_data/test_repos/test_repo_1",
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
Uncommited: true,
|
Uncommited: true,
|
||||||
|
ReportFormat: "json",
|
||||||
},
|
},
|
||||||
wantEmpty: true,
|
wantEmpty: true,
|
||||||
fileToChange: "server.test.py",
|
fileToChange: "server.test.py",
|
||||||
|
|||||||
Reference in new issue
Block a user