Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
refactor: Adjust tests to the project structure change
Browse files Browse the repository at this point in the history
feat: Introduce authentication by login & password
  • Loading branch information
B&R committed Oct 8, 2023
1 parent b75eebe commit 8af3d39
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pkg/actions/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestDownload(t *testing.T) {
Body: io.NopCloser(strings.NewReader("SOME GPG ENCRYPTED CONTENT THERE")),
}, nil)
api := pkgApi.NewBackupRepositoryApi("https://localhost").WithHttpClient(client)
crypto := pkgCtx.EncryptionOperationContext{
crypto := &pkgCtx.EncryptionOperationContext{
PublicKeyPath: "",
PrivateKeyPath: "",
Passphrase: "",
Expand All @@ -48,7 +48,7 @@ func TestDownload_FailsWhenHTTPCodeIsNotSuccess(t *testing.T) {
Body: io.NopCloser(strings.NewReader("Not authorized")),
}, nil)
api := pkgApi.NewBackupRepositoryApi("https://localhost").WithHttpClient(client)
crypto := pkgCtx.EncryptionOperationContext{
crypto := &pkgCtx.EncryptionOperationContext{
PublicKeyPath: "",
PrivateKeyPath: "",
Passphrase: "",
Expand All @@ -66,7 +66,7 @@ func TestDownload_FailsWhenShellCommandFails(t *testing.T) {
Body: io.NopCloser(strings.NewReader("SOME GPG ENCRYPTED CONTENT THERE")),
}, nil)
api := pkgApi.NewBackupRepositoryApi("https://localhost").WithHttpClient(client)
crypto := pkgCtx.EncryptionOperationContext{
crypto := &pkgCtx.EncryptionOperationContext{
PublicKeyPath: "",
PrivateKeyPath: "",
Passphrase: "",
Expand All @@ -91,7 +91,7 @@ func TestDownload_SuccessWithValidGPG(t *testing.T) {
Body: io.NopCloser(strings.NewReader(string(testFile))),
}, nil)
api := pkgApi.NewBackupRepositoryApi("https://localhost").WithHttpClient(client)
crypto := pkgCtx.EncryptionOperationContext{
crypto := &pkgCtx.EncryptionOperationContext{
PublicKeyPath: "",
PrivateKeyPath: "../../resources/test/gpg-key.asc",
Passphrase: "riotkit",
Expand Down
5 changes: 2 additions & 3 deletions pkg/context/encryption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ package context_test

import (
"github.com/riotkit-org/br-backup-maker/cmd/backupmaker"
context2 "github.com/riotkit-org/br-backup-maker/pkg/context"
"github.com/riotkit-org/br-backup-maker/pkg/context"
"github.com/stretchr/testify/assert"
"testing"
)

func TestGPGOperationContext_GetDecryptionCommand_GetEncryptionCommmand_DoesNotReturnCommandWhenGPGDisabled(t *testing.T) {
ctx := backupmaker.CliParameters{
ActionType: "make",
Crypto: context2.EncryptionOperationContext{
Crypto: context.EncryptionOperationContext{
PublicKeyPath: "",
PrivateKeyPath: "",
Passphrase: "riotkit",
Expand Down
2 changes: 1 addition & 1 deletion pkg/crypto/gpg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestWithMissingKey(t *testing.T) {
// as the server was reporting time to times issue with missing GPG footer, while GPG header was sent by the client. The issue was seen only in automatic tests
func TestValidBufferingLeadsToValidHeaderAndFooter(t *testing.T) {
for i := 1; i <= 50; i++ {
c := exec.Command("/bin/sh", "-c", "cat ../resources/test/bin-generator.sh | ../.build/backup-maker crypto encrypt -k ../resources/test/gpg-key.asc -p riotkit")
c := exec.Command("/bin/sh", "-c", "cat ../../resources/test/bin-generator.sh | ../../.build/backup-maker crypto encrypt -k ../../resources/test/gpg-key.asc -p riotkit")
output, err := c.Output()
assert.Nil(t, err)
assert.Contains(t, string(output), "-----BEGIN PGP MESSAGE-----")
Expand Down

0 comments on commit 8af3d39

Please sign in to comment.