-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: replace debug logs with returning errors
- Loading branch information
1 parent
eca0c53
commit 144ea0e
Showing
10 changed files
with
81 additions
and
88 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,23 +5,25 @@ | |
package utils | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
mocks "github.com/defenseunicorns/zarf/src/test/mocks" | ||
"github.com/go-git/go-git/v5/plumbing/transport/http" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestCredentialParser(t *testing.T) { | ||
credentialsFile := &mocks.MockReadCloser{ | ||
MockData: []byte( | ||
`https://wayne:[email protected]/ | ||
t.Parallel() | ||
|
||
data := `https://wayne:[email protected]/ | ||
bad line | ||
<really bad="line"/> | ||
https://wayne:p%40ss%20word%[email protected] | ||
http://google.com`, | ||
), | ||
} | ||
http://google.com` | ||
path := filepath.Join(t.TempDir(), "file") | ||
err := os.WriteFile(path, []byte(data), 0o644) | ||
require.NoError(t, err) | ||
|
||
expectedCreds := []Credential{ | ||
{ | ||
|
@@ -47,15 +49,15 @@ http://google.com`, | |
}, | ||
} | ||
|
||
gitCredentials := credentialParser(credentialsFile) | ||
gitCredentials, err := credentialParser(path) | ||
require.NoError(t, err) | ||
require.Equal(t, expectedCreds, gitCredentials) | ||
} | ||
|
||
func TestNetRCParser(t *testing.T) { | ||
t.Parallel() | ||
|
||
netrcFile := &mocks.MockReadCloser{ | ||
MockData: []byte( | ||
`# top of file comment | ||
data := `# top of file comment | ||
machine github.com | ||
login wayne | ||
password password | ||
|
@@ -70,9 +72,10 @@ machine google.com #comment password fun and login info! | |
default | ||
login anonymous | ||
password password`, | ||
), | ||
} | ||
password password` | ||
path := filepath.Join(t.TempDir(), "file") | ||
err := os.WriteFile(path, []byte(data), 0o644) | ||
require.NoError(t, err) | ||
|
||
expectedCreds := []Credential{ | ||
{ | ||
|
@@ -105,6 +108,7 @@ default | |
}, | ||
} | ||
|
||
netrcCredentials := netrcParser(netrcFile) | ||
netrcCredentials, err := netrcParser(path) | ||
require.NoError(t, err) | ||
require.Equal(t, expectedCreds, netrcCredentials) | ||
} |
This file was deleted.
Oops, something went wrong.