Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for cryptography api #719

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

KentHsu
Copy link
Contributor

@KentHsu KentHsu commented May 24, 2024

Description

  • Implement below in Dapr gRPC client

    • encrypt/decrypt request iterator and response generator and add tests
    • encrypt/decrypt methods in grpc client and add tests
  • Implement below in Dapr gRPC aio client

    • encrypt/decrypt request asynchronous iterator and response asynchronous generator and add tests
    • encrypt/decrypt methods in grpc aio client and add tests
  • Add cryptography examples follow go-sdk crypto example

Issue reference

Please reference the issue this PR will close: #548

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

Signed-off-by: KentHsu <chiahaohsu9@gmail.com>
Signed-off-by: KentHsu <chiahaohsu9@gmail.com>
Signed-off-by: KentHsu <chiahaohsu9@gmail.com>
@KentHsu KentHsu requested review from a team as code owners May 24, 2024 06:43
@KentHsu KentHsu changed the title Implement support cryptography api Implement support for cryptography api May 29, 2024
@elena-kolevska
Copy link
Contributor

Thank you very much for the PR Kent, I'll try to get to it asap.

Copy link
Member

@berndverst berndverst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome PR. Thanks @KentHsu

Can you run tox -e flake8 and tox -e ruff please?

The linter is failing at the moment.

That step runs tox -e flake8, tox -e type, tox -e mypy and tox -e ruff.

Copy link
Contributor

@elena-kolevska elena-kolevska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR @KentHsu, thank you! I have just a few nits.

# assert
self.assertEqual(req.__class__, api_v1.EncryptRequest)
self.assertEqual(req.payload.data, b'hello dapr')
self.assertEqual(req.payload.seq, 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also test the rasing of StopIteration after the appropriate number of iterations, for larger (and empty) files? Same for the async version.

EncryptDecryptFile(dapr)


def EncryptDecryptString(dapr: DaprClient):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nit: let's rename to encrypt_decrypt_string and encrypt_decrypt_file, to follow the PEP 8 style guide.

== APP == Running encrypt/decrypt operation on file
== APP == Wrote encrypted data to encrypted.out
== APP == Wrote decrypted data to decrypted.out.jpg
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please clean up the created resources in the end (the keys directory that was created and the .out files).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Crypto] Implement support for EncryptAlpha1/DecryptAlpha1 APIs
3 participants