Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
  • Loading branch information
soulxu committed Jun 13, 2024
1 parent 63e627e commit a3770a3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions contrib/qat/private_key_providers/test/ops_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ namespace {

class TestCallbacks : public Envoy::Ssl::PrivateKeyConnectionCallbacks {
public:
void onPrivateKeyMethodComplete() override{
void onPrivateKeyMethodComplete() override { is_completed_ = true; };

};
bool is_completed_{false};
};

class FakeSingletonManager : public Singleton::Manager {
Expand Down Expand Up @@ -127,13 +127,16 @@ TEST_F(QatProviderRsaTest, TestRsaPkcs1Signing) {
// to complete() function.
QatContext* ctx = static_cast<QatContext*>(libqat_->getQatContextPointer());
EXPECT_NE(ctx, nullptr);
op.registerCallback(ctx);

ctx->setOpStatus(CPA_STATUS_RETRY);
res_ = privateKeyCompleteForTest(&op, ctx, nullptr, nullptr, max_out_len_);
EXPECT_EQ(res_, ssl_private_key_retry);

libqat_->triggerDecrypt();
ctx->setOpStatus(CPA_STATUS_SUCCESS);
dispatcher_->run(Event::Dispatcher::RunType::NonBlock);
EXPECT_TRUE(cb.is_completed_);

res_ = privateKeyCompleteForTest(&op, ctx, out_, &out_len_, max_out_len_);
EXPECT_EQ(res_, ssl_private_key_success);
Expand All @@ -160,13 +163,16 @@ TEST_F(QatProviderRsaTest, TestRsaPSSSigning) {
// to complete() function.
QatContext* ctx = static_cast<QatContext*>(libqat_->getQatContextPointer());
EXPECT_NE(ctx, nullptr);
op.registerCallback(ctx);

ctx->setOpStatus(CPA_STATUS_RETRY);
res_ = privateKeyCompleteForTest(&op, ctx, nullptr, nullptr, max_out_len_);
EXPECT_EQ(res_, ssl_private_key_retry);

libqat_->triggerDecrypt();
ctx->setOpStatus(CPA_STATUS_SUCCESS);
dispatcher_->run(Event::Dispatcher::RunType::NonBlock);
EXPECT_TRUE(cb.is_completed_);

res_ = privateKeyCompleteForTest(&op, ctx, out_, &out_len_, max_out_len_);
EXPECT_EQ(res_, ssl_private_key_success);
Expand Down Expand Up @@ -203,13 +209,16 @@ TEST_F(QatProviderRsaTest, TestRsaDecryption) {

QatContext* ctx = static_cast<QatContext*>(libqat_->getQatContextPointer());
EXPECT_NE(ctx, nullptr);
op.registerCallback(ctx);

ctx->setOpStatus(CPA_STATUS_RETRY);
res_ = privateKeyCompleteForTest(&op, ctx, nullptr, nullptr, max_out_len_);
EXPECT_EQ(res_, ssl_private_key_retry);

libqat_->triggerDecrypt();
ctx->setOpStatus(CPA_STATUS_SUCCESS);
dispatcher_->run(Event::Dispatcher::RunType::NonBlock);
EXPECT_TRUE(cb.is_completed_);

res_ = privateKeyCompleteForTest(&op, ctx, out_, &out_len_, max_out_len_);
EXPECT_EQ(res_, ssl_private_key_success);
Expand Down

0 comments on commit a3770a3

Please sign in to comment.