Skip to content

Commit

Permalink
feat: add support to encrypt tgz base64
Browse files Browse the repository at this point in the history
  • Loading branch information
Sashwat-K committed May 6, 2024
1 parent b2aa707 commit 1a39fdf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions contract/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ func HpcrTgz(folderPath string) (string, error) {
return tgzBase64, nil
}

// HpcrTgzEncrypted - function to generate encrypted tgz
func HpcrTgzEncrypted(folderPath, encryptionCertificate string) (string, string, error) {
tgzBase64, err := HpcrTgz(folderPath)
if err != nil {
return "", "", err
}

return Encrypter(tgzBase64, encryptionCertificate)
}

// HpcrContractSignedEncrypted - function to generate Signed and Encrypted contract
func HpcrContractSignedEncrypted(contract, encryptionCertificate, privateKey string) (string, error) {
if contract == "" || privateKey == "" {
Expand Down
10 changes: 10 additions & 0 deletions contract/contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@ func TestHpcrTgz(t *testing.T) {
assert.NoError(t, err)
}

func TestHpcrTgzEncrypted(t *testing.T) {
result, _, err := HpcrTgzEncrypted(sampleComposeFolderPath, "")
if err != nil {
fmt.Println(err)
}

assert.Contains(t, result, "hyper-protect-basic.")
assert.NoError(t, err)
}

// Testcase to check if HpcrContractSignedEncrypted() is able to generate
func TestHpcrContractSignedEncrypted(t *testing.T) {

Expand Down

0 comments on commit 1a39fdf

Please sign in to comment.