#include "components/trusted_vault/test/fake_security_domains_server.h"
#include "base/base64url.h"
#include "base/logging.h"
#include "base/rand_util.h"
#include "components/trusted_vault/proto_string_bytes_conversion.h"
#include "components/trusted_vault/securebox.h"
#include "components/trusted_vault/trusted_vault_crypto.h"
#include "components/trusted_vault/trusted_vault_server_constants.h"
#include "net/http/http_status_code.h"
namespace trusted_vault {
namespace {
const char kServerPathPrefix[] = …;
const int kSharedKeyLength = …;
std::unique_ptr<net::test_server::HttpResponse> CreateErrorResponse(
net::HttpStatusCode response_code) { … }
std::unique_ptr<net::test_server::HttpResponse>
CreateHttpResponseForSuccessfulJoinSecurityDomainsRequest(int current_epoch) { … }
bool ValidateJoinSecurityDomainsRequest(
const trusted_vault_pb::JoinSecurityDomainsRequest& request) { … }
bool VerifySharedKeys(
const trusted_vault_pb::JoinSecurityDomainsRequest& request,
const std::vector<std::vector<uint8_t>>& trusted_vault_keys) { … }
std::string GetPublicKeyFromGetSecurityDomainMemberRequestURL(
const GURL& request_url,
const GURL& server_url) { … }
}
FakeSecurityDomainsServer::State::State() = default;
FakeSecurityDomainsServer::State::State(State&& other) = default;
FakeSecurityDomainsServer::State& FakeSecurityDomainsServer::State::operator=(
State&& other) = default;
FakeSecurityDomainsServer::State::~State() = default;
GURL FakeSecurityDomainsServer::GetServerURL(GURL base_url) { … }
FakeSecurityDomainsServer::FakeSecurityDomainsServer(GURL base_url)
: … { … }
FakeSecurityDomainsServer::~FakeSecurityDomainsServer() = default;
void FakeSecurityDomainsServer::AddObserver(Observer* observer) { … }
void FakeSecurityDomainsServer::RemoveObserver(Observer* observer) { … }
std::unique_ptr<net::test_server::HttpResponse>
FakeSecurityDomainsServer::HandleRequest(
const net::test_server::HttpRequest& http_request) { … }
std::vector<uint8_t> FakeSecurityDomainsServer::RotateTrustedVaultKey(
const std::vector<uint8_t>& last_trusted_vault_key) { … }
void FakeSecurityDomainsServer::ResetData() { … }
void FakeSecurityDomainsServer::ResetDataToState(
const std::vector<std::vector<uint8_t>>& keys,
int last_key_version) { … }
void FakeSecurityDomainsServer::RequirePublicKeyToAvoidRecoverabilityDegraded(
const std::vector<uint8_t>& public_key) { … }
int FakeSecurityDomainsServer::GetMemberCount() const { … }
std::vector<std::vector<uint8_t>>
FakeSecurityDomainsServer::GetAllTrustedVaultKeys() const { … }
bool FakeSecurityDomainsServer::AllMembersHaveKey(
const std::vector<uint8_t>& trusted_vault_key) const { … }
int FakeSecurityDomainsServer::GetCurrentEpoch() const { … }
bool FakeSecurityDomainsServer::IsRecoverabilityDegraded() const { … }
bool FakeSecurityDomainsServer::ReceivedInvalidRequest() const { … }
std::unique_ptr<net::test_server::HttpResponse>
FakeSecurityDomainsServer::HandleJoinSecurityDomainsRequest(
const net::test_server::HttpRequest& http_request) { … }
std::unique_ptr<net::test_server::HttpResponse>
FakeSecurityDomainsServer::HandleGetSecurityDomainMemberRequest(
const net::test_server::HttpRequest& http_request) { … }
std::unique_ptr<net::test_server::HttpResponse>
FakeSecurityDomainsServer::HandleGetSecurityDomainRequest(
const net::test_server::HttpRequest& http_request) { … }
}