#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/modules/credentialmanagement/credential_manager_type_converters.h"
#include "base/compiler_specific.h"
#include "base/containers/span.h"
#include "mojo/public/cpp/bindings/type_converter.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/webauthn/authenticator.mojom-blink.h"
#include "third_party/blink/public/mojom/webid/federated_auth_request.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_arraybuffer_arraybufferview.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_client_inputs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_client_outputs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_large_blob_inputs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_large_blob_outputs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_prf_inputs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_prf_outputs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_prf_values.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_supplemental_pub_keys_inputs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_authentication_extensions_supplemental_pub_keys_outputs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_cable_authentication_data.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_identity_credential_request_options_context.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_identity_provider_request_options.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_public_key_credential_request_options.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_remote_desktop_client_override.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_typed_array.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace mojo {
V8Context;
RpContext;
const uint8_t kSample[] = …;
static blink::V8UnionArrayBufferOrArrayBufferView* arrayBufferOrView(
const uint8_t* data,
size_t size);
static Vector<uint8_t> vectorOf(const uint8_t* data, size_t size);
TEST(CredentialManagerTypeConvertersTest, RpContextTest) { … }
TEST(CredentialManagerTypeConvertersTest,
AuthenticationExtensionsClientOutputs_appidNotSet) { … }
TEST(CredentialManagerTypeConvertersTest,
AuthenticationExtensionsClientOutputs_appidSetTrue) { … }
#if BUILDFLAG(IS_ANDROID)
TEST(CredentialManagerTypeConvertersTest,
AuthenticationExtensionsClientOutputs_userVerificationMethods) {
auto mojo_type =
blink::mojom::blink::AuthenticationExtensionsClientOutputs::New();
mojo_type->echo_user_verification_methods = true;
mojo_type->user_verification_methods =
Vector<blink::mojom::blink::UvmEntryPtr>();
mojo_type->user_verification_methods->emplace_back(
blink::mojom::blink::UvmEntry::New(1,
2,
3));
mojo_type->user_verification_methods->emplace_back(
blink::mojom::blink::UvmEntry::New(4,
5,
6));
auto* blink_type =
ConvertTo<blink::AuthenticationExtensionsClientOutputs*>(mojo_type);
EXPECT_TRUE(blink_type->hasUvm());
EXPECT_THAT(blink_type->uvm(),
::testing::ElementsAre(Vector<uint32_t>{1, 2, 3},
Vector<uint32_t>{4, 5, 6}));
}
#endif
MATCHER_P(DOMArrayBufferEqualTo, vector, "") { … }
MATCHER_P(UnionDOMArrayBufferOrViewEqualTo, vector, "") { … }
TEST(CredentialManagerTypeConvertersTest,
AuthenticationExtensionsClientOutputs_largeBlobEmpty) { … }
TEST(CredentialManagerTypeConvertersTest,
AuthenticationExtensionsClientOutputs_largeBlobRead) { … }
TEST(CredentialManagerTypeConvertersTest,
AuthenticationExtensionsClientOutputs_largeBlobWritten) { … }
TEST(CredentialManagerTypeConvertersTest,
AuthenticationExtensionsClientOutputs_credBlob) { … }
TEST(CredentialManagerTypeConvertersTest,
AuthenticationExtensionsClientOutputs_supplementalPubKeys) { … }
TEST(CredentialManagerTypeConvertersTest,
AuthenticationExtensionsClientOutputs_prf) { … }
TEST(CredentialManagerTypeConvertersTest,
AuthenticationExtensionsClientOutputs_prfWithSecond) { … }
TEST(CredentialManagerTypeConvertersTest,
PublicKeyCredentialRequestOptions_extensions) { … }
TEST(CredentialManagerTypeConvertersTest,
AuthenticationExtensionsClientInputsTest_appid) { … }
#if BUILDFLAG(IS_ANDROID)
TEST(CredentialManagerTypeConvertersTest,
AuthenticationExtensionsClientInputsTest_uvm) {
blink::AuthenticationExtensionsClientInputs* blink_type =
blink::AuthenticationExtensionsClientInputs::Create();
blink_type->setUvm(true);
blink::mojom::blink::AuthenticationExtensionsClientInputsPtr mojo_type =
ConvertTo<blink::mojom::blink::AuthenticationExtensionsClientInputsPtr>(
*blink_type);
ASSERT_EQ(mojo_type->user_verification_methods, true);
}
#endif
TEST(CredentialManagerTypeConvertersTest,
AuthenticationExtensionsClientInputsTest_largeBlobWrite) { … }
TEST(CredentialManagerTypeConvertersTest,
AuthenticationExtensionsClientInputsTest_largeBlobRead) { … }
TEST(CredentialManagerTypeConvertersTest,
AuthenticationExtensionsClientInputsTest_hasCredBlob) { … }
blink::RemoteDesktopClientOverride* blinkRemoteDesktopOverride(String origin) { … }
blink::mojom::blink::RemoteDesktopClientOverridePtr mojoRemoteDesktopOverride(
String origin_string) { … }
const char* kSampleOrigin = …;
TEST(CredentialManagerTypeConvertersTest,
AuthenticationExtensionsClientInputsTest_remoteDesktopClientOverride) { … }
TEST(CredentialManagerTypeConvertersTest,
AuthenticationExtensionsClientInputsTest_supplementalPubKeys) { … }
TEST(CredentialManagerTypeConvertersTest,
AuthenticationExtensionsClientInputsTest_prfInputs) { … }
static blink::V8UnionArrayBufferOrArrayBufferView* arrayBufferOrView(
const uint8_t* data,
size_t size) { … }
static Vector<uint8_t> vectorOf(const uint8_t* data, size_t size) { … }
TEST(CredentialManagerTypeConvertersTest, NoClientId) { … }
}