Skip to content

Commit

Permalink
Remove unneeded step
Browse files Browse the repository at this point in the history
  • Loading branch information
kleewho committed Sep 18, 2023
1 parent 555db45 commit 2f6b5fc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 33 deletions.
35 changes: 3 additions & 32 deletions tests/contract/crypto_steps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,35 +71,6 @@ func legacyCodeWithCipherKeyAndRandomVector(ctx context.Context, cipherKey strin
return nil
}

func encryptedFileSuccessfullyDecryptedByLegacyCodeWithCipherKeyAndVector(ctx context.Context, cipherKey string, iv string) error {
riv := randomIv(iv)
cryptoState := getCryptoState(ctx)

cryptor, e := createCryptor("legacy", cipherKey, riv)
if e != nil {
return e
}
module := crypto.NewCryptoModule(cryptor, []crypto.Cryptor{cryptor})
if e != nil {
return e
}
if cryptoState.result != nil {
_, err := module.Decrypt(cryptoState.result)
if err != nil {
return err
}
} else if cryptoState.resultReader != nil {
_, err := module.DecryptStream(bufio.NewReader(cryptoState.resultReader))
if err != nil {
return err
}
} else {
return errors.New("no result")
}

return nil
}

func iDecryptFileAs(ctx context.Context, filename string, decryptionType string) error {

cryptoState := getCryptoState(ctx)
Expand Down Expand Up @@ -253,7 +224,7 @@ func successfullyDecryptAnEncryptedFileWithLegacyCode(ctx context.Context) error
_, e := utils.DecryptString(cryptoState.legacyCodeCipherKey, base64.StdEncoding.EncodeToString(cryptoState.result), cryptoState.legacyCodeRandomIv)
return e
} else if cryptoState.resultReader != nil {
buffer := &CloserBuffer{bytes.NewBuffer(nil)}
buffer := &closerBuffer{bytes.NewBuffer(nil)}

utils.DecryptFile(cryptoState.legacyCodeCipherKey, 0, cryptoState.resultReader, buffer)
_, e := io.ReadAll(buffer)
Expand All @@ -263,10 +234,10 @@ func successfullyDecryptAnEncryptedFileWithLegacyCode(ctx context.Context) error
}
}

type CloserBuffer struct {
type closerBuffer struct {
*bytes.Buffer
}

func (c *CloserBuffer) Close() error {
func (c *closerBuffer) Close() error {
return nil
}
1 change: 0 additions & 1 deletion tests/contract/steps_mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func MapSteps(ctx *godog.ScenarioContext) {
ctx.Step(`^the token string \'(.*)\'$`, theTokenString)

ctx.Step(`^Decrypted file content equal to the \'(.*)\' file content$`, decryptedFileContentEqualToFileContent)
ctx.Step(`^Encrypted file successfully decrypted by legacy code with \'(.*)\' cipher key and \'(.*)\' vector$`, encryptedFileSuccessfullyDecryptedByLegacyCodeWithCipherKeyAndVector)
ctx.Step(`^I decrypt \'(.*)\' file as \'(.*)\'$`, iDecryptFileAs)
ctx.Step(`^I decrypt \'(.*)\' file$`, iDecryptFile)
ctx.Step(`^I encrypt \'(.*)\' file as \'(.*)\'$`, iEncryptFileAs)
Expand Down

0 comments on commit 2f6b5fc

Please sign in to comment.