azure-sdk-for-cpp/sdk/tables/azure-data-tables/test/ut/serializers_test.cpp
George Arama 20d9364a3d
Storage tables implementation (#5137)
* dss

* first pass at a client and tests

* constructors work

* working request, need to fix the response parsing

* basic tests working for service client

* refactored the constructors

* testproxy and tests

* format file

* got client and one API working

* list working

* all apis recorded

* new assets.json

* assets.json regen

* format json

* adding word to cspell

* fix build issues

* fix one more break

* typo

* clangs

* one more issue

* more fixezez

* regen recordings

* try again

* clangs

* clangs again

* new assets

* new test proxy

* regen tests based on new merge

* hmmm

* restore

* add debug env for test proxy

* resync cmake presets from main

* gor get and set working

* get stats

* table client and create

* delete

* get/set acls

* list tables

* some cleanup

* Create /update/merge/delete

* upsert

* query entities

* generated tests

* clangs

* some fixes

* some more errors

* cspells

* got transaction API working

* transactions working , need to parse response

* get data out of the response

* clangs

* batch1

* regen tests

* part 2

* batch3

* batch4

* clangs

* regen tests

* regen tests

* try again

* live only

* added some more tests for the transaction body

* small refactor for tests

* oops

* some oter update

* darn includes

* sddfsd

* erorr fix

* key clients

* sas

* small cleanup

* All tests passing

* test recordings

* clangs

* missing ENV for test

* attempt1

* retry

* couple recordings

* regen some tests

* clangs

* again

* again

* comments

* comments

* headers and footers

* some cleanjup

* Move folders step1

* revert assets and test resources in storage

* revert to main

* cspell

* readme

* comments

* revert ci.yml

* liveonly test

* clangs

* camke

* ci2

* try again

* fdssfs

* fdsfsd

* some cleanup

* dasda

* dsdsds

* asda

* assets

* comments

* a few more bits and pieces

* some other updates for cspell

* typo

* more docs

* spell

* another doc error

* clangs docs

* docs

* test cov

* dasdas

* hg

* stress test

* cspell

* Update sdk/storage/azure-storage-common/test/ut/CMakeLists.txt

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* Update sdk/storage/azure-storage-common/test/ut/shared_key_policy_lite_test.cpp

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* Update sdk/tables/azure-data-tables/CHANGELOG.md

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* Update sdk/tables/azure-data-tables/CMakeLists.txt

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* Update sdk/tables/azure-data-tables/test/stress/scenarios-matrix.yaml

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* Update sdk/tables/azure-data-tables/test/stress/Dockerfile

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* PR comments

* respurces cleanup

* cleanup 2

* respurce fix

* revddrt

* weqq

* oops

* try again

* Update sdk/tables/azure-data-tables/vcpkg/vcpkg.json

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* try

* test fix

* samples

* readmes

* readmes

* readmes

* api view settings

* qualify friends

* try

* moving usings

* refactor for API View tool

* some more

* clangs

* Update sdk/tables/README.md

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* Update sdk/core/azure-core/inc/azure/core/http/http.hpp

Co-authored-by: Ahson Khan <ahkha@microsoft.com>

* Update sdk/core/azure-core/src/http/transport_policy.cpp

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* Update sdk/tables/azure-data-tables/inc/azure/data/tables/rest_client.hpp

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* Update sdk/tables/azure-data-tables/CHANGELOG.md

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* Update sdk/tables/azure-data-tables/test/ut/CMakeLists.txt

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* Update sdk/tables/azure-data-tables/src/rest_client.cpp

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* some comments

* comments

* comments part N

* clang

* try now

* clang

* comments

* update file names

* update test to check for the final signature

* ccc

* rename shared key policy lite

* cleanup some includes

* add a couple more tests

* small update

* clang

* increase test limits

* xml transition

* service_version_policy

* shared creds and key policy lite

* switch to secondary policy

* code done

* remove last storage vestiges

* put back some code

* readme/changelog

* Update sdk/tables/azure-data-tables/src/serializers.cpp

Co-authored-by: Rick Winter <rick.winter@microsoft.com>

* Add the shared key policy for Larry

* Larry comments

* curlybracify the initializers

* Update sdk/core/azure-core-xml/inc/azure/core/xml/dll_import_export.hpp

Co-authored-by: Rick Winter <rick.winter@microsoft.com>

* Update sdk/core/azure-core-xml/vcpkg.json

Co-authored-by: Rick Winter <rick.winter@microsoft.com>

* Update sdk/tables/azure-data-tables/inc/azure/data/tables.hpp

Co-authored-by: Rick Winter <rick.winter@microsoft.com>

* Rick's comments one more namespace change for serializers

* whiteline

* typo

* oops

* includes and clangs

* cleanup

* jhfjdhjfd

* hjkjdhf

* daas

* Anton's comments

* clang

* revert some changes

* fdss

* Update sdk/core/azure-core-xml/CHANGELOG.md

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>

* everything works

* clangs and vcpkg test

* test remove azure-core-xml

* vcpkg json

* remove the code

* merge main

* saa

* wqw

* last comments

* clang

---------

Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com>
Co-authored-by: Ahson Khan <ahkha@microsoft.com>
Co-authored-by: Rick Winter <rick.winter@microsoft.com>
2024-01-12 11:04:43 -08:00

92 lines
4.0 KiB
C++

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "serializers_test.hpp"
#include <chrono>
#include <sstream>
#include <string>
#include <thread>
using namespace Azure::Data::Tables;
using namespace Azure::Data::Tables::Models;
using namespace Azure::Data::Tables::_detail;
namespace Azure { namespace Data { namespace Test {
TEST_F(SerializersTest, SetAccessPolicy)
{
auto policy = Azure::Data::Tables::Models::TableAccessPolicy();
SignedIdentifier identifier;
identifier.Id = "test";
identifier.StartsOn = Azure::DateTime(2023, 12, 1, 1, 1, 1);
identifier.ExpiresOn = Azure::DateTime(2023, 12, 2, 1, 1, 1);
identifier.Permissions = "r";
policy.SignedIdentifiers.emplace_back(identifier);
auto serialized = Serializers::SetAccessPolicy(policy);
auto data = Serializers::TableAccessPolicyFromXml(
std::vector<uint8_t>(serialized.begin(), serialized.end()));
EXPECT_EQ(data.SignedIdentifiers[0].Id, "test");
EXPECT_EQ(data.SignedIdentifiers[0].Permissions, "r");
EXPECT_EQ(data.SignedIdentifiers[0].StartsOn.Value(), Azure::DateTime(2023, 12, 1, 1, 1, 1));
EXPECT_EQ(data.SignedIdentifiers[0].ExpiresOn.Value(), Azure::DateTime(2023, 12, 2, 1, 1, 1));
}
TEST_F(SerializersTest, SetServiceProperties)
{
auto policy = Azure::Data::Tables::Models::SetServicePropertiesOptions();
policy.ServiceProperties.HourMetrics.Version = "1.0";
policy.ServiceProperties.HourMetrics.IsEnabled = true;
policy.ServiceProperties.HourMetrics.IncludeApis = true;
policy.ServiceProperties.HourMetrics.RetentionPolicyDefinition.Days = 1;
policy.ServiceProperties.HourMetrics.RetentionPolicyDefinition.IsEnabled = true;
policy.ServiceProperties.MinuteMetrics.Version = "1.0";
policy.ServiceProperties.MinuteMetrics.IsEnabled = true;
policy.ServiceProperties.MinuteMetrics.IncludeApis = true;
policy.ServiceProperties.MinuteMetrics.RetentionPolicyDefinition.Days = 1;
policy.ServiceProperties.MinuteMetrics.RetentionPolicyDefinition.IsEnabled = true;
policy.ServiceProperties.Logging.Version = "1.0";
policy.ServiceProperties.Logging.Delete = true;
policy.ServiceProperties.Logging.Read = true;
policy.ServiceProperties.Logging.Write = true;
policy.ServiceProperties.Logging.RetentionPolicyDefinition.Days = 1;
policy.ServiceProperties.Logging.RetentionPolicyDefinition.IsEnabled = true;
policy.ServiceProperties.Cors.emplace_back(CorsRule());
policy.ServiceProperties.Cors[0].AllowedOrigins = "*";
policy.ServiceProperties.Cors[0].AllowedMethods = "GET";
policy.ServiceProperties.Cors[0].AllowedHeaders = "*";
policy.ServiceProperties.Cors[0].ExposedHeaders = "*";
auto serialized = Serializers::SetServiceProperties(policy);
auto data = Serializers::ServicePropertiesFromXml(
std::vector<uint8_t>(serialized.begin(), serialized.end()));
EXPECT_EQ(data.HourMetrics.Version, "1.0");
EXPECT_EQ(data.HourMetrics.IsEnabled, true);
EXPECT_EQ(data.HourMetrics.IncludeApis.Value(), true);
EXPECT_EQ(data.HourMetrics.RetentionPolicyDefinition.Days.Value(), 1);
EXPECT_EQ(data.HourMetrics.RetentionPolicyDefinition.IsEnabled, true);
EXPECT_EQ(data.MinuteMetrics.Version, "1.0");
EXPECT_EQ(data.MinuteMetrics.IsEnabled, true);
EXPECT_EQ(data.MinuteMetrics.IncludeApis.Value(), true);
EXPECT_EQ(data.MinuteMetrics.RetentionPolicyDefinition.Days.Value(), 1);
EXPECT_EQ(data.MinuteMetrics.RetentionPolicyDefinition.IsEnabled, true);
EXPECT_EQ(data.Logging.Version, "1.0");
EXPECT_EQ(data.Logging.Delete, true);
EXPECT_EQ(data.Logging.Read, true);
EXPECT_EQ(data.Logging.Write, true);
EXPECT_EQ(data.Logging.RetentionPolicyDefinition.Days.Value(), 1);
EXPECT_EQ(data.Logging.RetentionPolicyDefinition.IsEnabled, true);
EXPECT_EQ(data.Cors[0].AllowedOrigins, "*");
EXPECT_EQ(data.Cors[0].AllowedMethods, "GET");
EXPECT_EQ(data.Cors[0].AllowedHeaders, "*");
EXPECT_EQ(data.Cors[0].ExposedHeaders, "*");
}
}}} // namespace Azure::Data::Test