#include "anonymous_tokens/cpp/client/anonymous_tokens_rsa_bssa_client.h"
#include <memory>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/time/time.h"
#include "anonymous_tokens/cpp/crypto/constants.h"
#include "anonymous_tokens/cpp/crypto/rsa_blind_signer.h"
#include "anonymous_tokens/cpp/shared/proto_utils.h"
#include "anonymous_tokens/cpp/shared/status_utils.h"
#include "anonymous_tokens/cpp/testing/proto_utils.h"
#include "anonymous_tokens/cpp/testing/utils.h"
#include "anonymous_tokens/proto/anonymous_tokens.pb.h"
#include <openssl/base.h>
#include <openssl/rsa.h>
namespace anonymous_tokens {
namespace {
SizeIs;
absl::StatusOr<std::pair<RSABlindSignaturePublicKey, RSAPrivateKey>>
CreateClientTestKey(absl::string_view use_case = "TEST_USE_CASE",
int key_version = 1,
MessageMaskType mask_type = AT_MESSAGE_MASK_CONCAT,
int message_mask_size = 32,
bool enable_public_metadata = false) { … }
absl::StatusOr<std::vector<PlaintextMessageWithPublicMetadata>> CreateInput(
absl::Span<const std::string> messages,
absl::Span<const std::string> public_metadata = { … }
absl::StatusOr<AnonymousTokensSignResponse> CreateResponse(
const AnonymousTokensSignRequest& request, const RSAPrivateKey& private_key,
bool enable_public_metadata = false) { … }
TEST(CreateAnonymousTokensRsaBssaClientTest, Success) { … }
TEST(CreateAnonymousTokensRsaBssaClientTest, InvalidUseCase) { … }
TEST(CreateAnonymousTokensRsaBssaClientTest, NotAUseCase) { … }
TEST(CreateAnonymousTokensRsaBssaClientTest, InvalidKeyVersion) { … }
TEST(CreateAnonymousTokensRsaBssaClientTest, InvalidMessageMaskType) { … }
TEST(CreateAnonymousTokensRsaBssaClientTest,
MessageMaskConcatInvalidMessageMaskSize) { … }
TEST(CreateAnonymousTokensRsaBssaClientTest,
MessageMaskNoMaskInvalidMessageMaskSize) { … }
class AnonymousTokensRsaBssaClientTest : public testing::Test { … };
TEST_F(AnonymousTokensRsaBssaClientTest, SuccessOneMessage) { … }
TEST_F(AnonymousTokensRsaBssaClientTest, SuccessMultipleMessages) { … }
TEST_F(AnonymousTokensRsaBssaClientTest, SuccessMultipleMessagesNoMessageMask) { … }
TEST_F(AnonymousTokensRsaBssaClientTest, EnsureRandomTokens) { … }
TEST_F(AnonymousTokensRsaBssaClientTest, EmptyInput) { … }
TEST_F(AnonymousTokensRsaBssaClientTest, CreateRequestTwice) { … }
TEST_F(AnonymousTokensRsaBssaClientTest, ProcessResponseWithoutCreateRequest) { … }
TEST_F(AnonymousTokensRsaBssaClientTest, ProcessEmptyResponse) { … }
TEST_F(AnonymousTokensRsaBssaClientTest, ProcessResponseWithBadUseCase) { … }
TEST_F(AnonymousTokensRsaBssaClientTest, ProcessResponseWithBadKeyVersion) { … }
TEST_F(AnonymousTokensRsaBssaClientTest, ProcessResponseFromDifferentClient) { … }
class AnonymousTokensRsaBssaClientWithPublicMetadataTest
: public testing::Test { … };
TEST_F(AnonymousTokensRsaBssaClientWithPublicMetadataTest,
SuccessOneMessageWithPublicMetadata) { … }
TEST_F(AnonymousTokensRsaBssaClientWithPublicMetadataTest,
FailureWithEmptyPublicMetadata) { … }
TEST_F(AnonymousTokensRsaBssaClientWithPublicMetadataTest,
FailureWithWrongPublicMetadata) { … }
TEST_F(AnonymousTokensRsaBssaClientWithPublicMetadataTest,
FailureWithPublicMetadataSupportOff) { … }
TEST_F(AnonymousTokensRsaBssaClientWithPublicMetadataTest,
SuccessMultipleMessagesWithDistinctPublicMetadata) { … }
TEST_F(AnonymousTokensRsaBssaClientWithPublicMetadataTest,
SuccessMultipleMessagesWithRepeatedPublicMetadata) { … }
TEST_F(AnonymousTokensRsaBssaClientWithPublicMetadataTest,
SuccessMultipleMessagesWithEmptyStringPublicMetadata) { … }
TEST_F(AnonymousTokensRsaBssaClientWithPublicMetadataTest,
SuccessMultipleMessagesNoMessageMask) { … }
}
}