chromium/third_party/anonymous_tokens/src/anonymous_tokens/cpp/client/anonymous_tokens_rsa_bssa_client_test.cc

// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#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;

// Returns a fixed public private key pair by calling GetStrongRsaKeys4096().
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) {}

// Creates the input consisting on plaintext messages and public metadata that
// can be passed to the AnonymousTokensRsaBssaClient.
absl::StatusOr<std::vector<PlaintextMessageWithPublicMetadata>> CreateInput(
    absl::Span<const std::string> messages,
    absl::Span<const std::string> public_metadata = {}

// Creates the server response for anonymous tokens request by using
// RsaBlindSigner.
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) {}

}  // namespace
}  // namespace anonymous_tokens