From a1ebab7588742109a86a2e1aa077499c9c1ab1bc Mon Sep 17 00:00:00 2001 From: MAG-AdamThorn Date: Wed, 29 Oct 2025 11:26:16 +0000 Subject: [PATCH] [OF-1805] feat: Add new GoogleGenAI Quota tier feature --- Library/include/CSP/Systems/Quota/Quota.h | 1 + Library/src/Systems/Quota/Quota.cpp | 7 +++ Tests/src/PublicAPITests/QuotaSystemTests.cpp | 58 +++++++++++++------ 3 files changed, 48 insertions(+), 18 deletions(-) diff --git a/Library/include/CSP/Systems/Quota/Quota.h b/Library/include/CSP/Systems/Quota/Quota.h index bd0b3587c..12dd96518 100644 --- a/Library/include/CSP/Systems/Quota/Quota.h +++ b/Library/include/CSP/Systems/Quota/Quota.h @@ -56,6 +56,7 @@ enum class TierFeatures OpenAI, Shopify, TicketedSpace, + GoogleGenAI, Invalid }; diff --git a/Library/src/Systems/Quota/Quota.cpp b/Library/src/Systems/Quota/Quota.cpp index 17879f420..f553a2e09 100644 --- a/Library/src/Systems/Quota/Quota.cpp +++ b/Library/src/Systems/Quota/Quota.cpp @@ -256,6 +256,8 @@ const csp::common::String TierFeatureEnumToString(const TierFeatures& Value) return "TotalUploadSizeInKilobytes"; case TierFeatures::SpaceOwner: return "SpaceOwner"; + case TierFeatures::GoogleGenAI: + return "GoogleGenAI"; case TierFeatures::Invalid: return "Invalid"; default: @@ -343,6 +345,11 @@ TierFeatures StringToTierFeatureEnum(const csp::common::String& Value) return TierFeatures::SpaceOwner; } + if (Value == "GoogleGenAI") + { + return TierFeatures::GoogleGenAI; + } + CSP_LOG_ERROR_FORMAT("QuotaSystem TierFeature not recognized: %s. Defaulting to Invalid", Value.c_str()); return TierFeatures::Invalid; } diff --git a/Tests/src/PublicAPITests/QuotaSystemTests.cpp b/Tests/src/PublicAPITests/QuotaSystemTests.cpp index e71e81e21..03957bd7b 100644 --- a/Tests/src/PublicAPITests/QuotaSystemTests.cpp +++ b/Tests/src/PublicAPITests/QuotaSystemTests.cpp @@ -62,6 +62,7 @@ CSP_PUBLIC_TEST(CSPEngine, QuotaSystemTests, TierFeatureEnumTesttoStringTest) EXPECT_EQ(TierFeatureEnumToString(csp::systems::TierFeatures::SpaceOwner), "SpaceOwner"); EXPECT_EQ(TierFeatureEnumToString(csp::systems::TierFeatures::TicketedSpace), "TicketedSpace"); EXPECT_EQ(TierFeatureEnumToString(csp::systems::TierFeatures::TotalUploadSizeInKilobytes), "TotalUploadSizeInKilobytes"); + EXPECT_EQ(TierFeatureEnumToString(csp::systems::TierFeatures::GoogleGenAI), "GoogleGenAI"); } CSP_PUBLIC_TEST(CSPEngine, QuotaSystemTests, StringToTierFeatureEnumTestTest) @@ -75,6 +76,7 @@ CSP_PUBLIC_TEST(CSPEngine, QuotaSystemTests, StringToTierFeatureEnumTestTest) EXPECT_EQ(StringToTierFeatureEnum("SpaceOwner"), csp::systems::TierFeatures::SpaceOwner); EXPECT_EQ(StringToTierFeatureEnum("TicketedSpace"), csp::systems::TierFeatures::TicketedSpace); EXPECT_EQ(StringToTierFeatureEnum("TotalUploadSizeInKilobytes"), csp::systems::TierFeatures::TotalUploadSizeInKilobytes); + EXPECT_EQ(StringToTierFeatureEnum("GoogleGenAI"), csp::systems::TierFeatures::GoogleGenAI); } CSP_PUBLIC_TEST(CSPEngine, QuotaSystemTests, GetTotalSpacesOwnedByUserTest) @@ -210,16 +212,9 @@ CSP_PUBLIC_TEST(CSPEngine, QuotaSystemTests, GetTierFeaturesQuota) auto UserSystem = SystemsManager.GetUserSystem(); auto QuotaSystem = SystemsManager.GetQuotaSystem(); - csp::common::Array ExpectedInfoArray - = { FeatureQuotaInfo(TierFeatures::SpaceOwner, TierNames::Basic, 3, PeriodEnum::Total, true), - FeatureQuotaInfo(TierFeatures::ScopeConcurrentUsers, TierNames::Basic, 5, PeriodEnum::Hours24, true), - FeatureQuotaInfo(TierFeatures::ObjectCaptureUpload, TierNames::Basic, 5, PeriodEnum::CalendarMonth, false), - FeatureQuotaInfo(TierFeatures::AudioVideoUpload, TierNames::Basic, -1, PeriodEnum::Total, false), - FeatureQuotaInfo(TierFeatures::TotalUploadSizeInKilobytes, TierNames::Basic, 10000000, PeriodEnum::Total, true), - FeatureQuotaInfo(TierFeatures::Agora, TierNames::Basic, 0, PeriodEnum::Total, false), - FeatureQuotaInfo(TierFeatures::OpenAI, TierNames::Basic, 0, PeriodEnum::Total, false), - FeatureQuotaInfo(TierFeatures::Shopify, TierNames::Basic, 0, PeriodEnum::Total, false), - FeatureQuotaInfo(TierFeatures::TicketedSpace, TierNames::Basic, 0, PeriodEnum::Total, false) }; + csp::common::Array TierFeaturesArray = { TierFeatures::SpaceOwner, TierFeatures::ScopeConcurrentUsers, + TierFeatures::ObjectCaptureUpload, TierFeatures::AudioVideoUpload, TierFeatures::TotalUploadSizeInKilobytes, TierFeatures::Agora, + TierFeatures::OpenAI, TierFeatures::Shopify, TierFeatures::TicketedSpace }; csp::common::String UserId; LogInAsNewTestUser(UserSystem, UserId); @@ -227,14 +222,44 @@ CSP_PUBLIC_TEST(CSPEngine, QuotaSystemTests, GetTierFeaturesQuota) auto [Result] = AWAIT_PRE(QuotaSystem, GetTierFeaturesQuota, RequestPredicate, TierNames::Basic); EXPECT_EQ(Result.GetResultCode(), csp::systems::EResultCode::Success); - EXPECT_EQ(Result.GetFeaturesQuotaInfo().Size(), ExpectedInfoArray.Size()); + + // Please note: In service of OF-1805 a new TierFeature 'GoogleGenAI' was added in CSP to the 'TierFeatures' enum. + // However, until this has also been added by the backend services, calls to 'GetTierFeaturesQuota()' will not return this feature. + // The following test has been temporaily modified to account for this. Once this work has been completed, and the backend + // services have added this tier feature, this test should be reverted to its original form (though with the addition of the new + // feature in the 'TierFeaturesArray' array). + bool IsGoogleGenAITierFeatureEnabled = false; for (size_t i = 0; i < Result.GetFeaturesQuotaInfo().Size(); i++) { - EXPECT_EQ(Result.GetFeaturesQuotaInfo()[i].FeatureName, ExpectedInfoArray[i].FeatureName); - EXPECT_EQ(Result.GetFeaturesQuotaInfo()[i].TierName, ExpectedInfoArray[i].TierName); - EXPECT_EQ(Result.GetFeaturesQuotaInfo()[i].Limit, ExpectedInfoArray[i].Limit); - EXPECT_EQ(Result.GetFeaturesQuotaInfo()[i].Period, ExpectedInfoArray[i].Period); + if (Result.GetFeaturesQuotaInfo()[i].FeatureName == TierFeatures::GoogleGenAI) + { + IsGoogleGenAITierFeatureEnabled = true; + break; + } + } + + if (IsGoogleGenAITierFeatureEnabled) + { + EXPECT_EQ(Result.GetFeaturesQuotaInfo().Size(), TierFeaturesArray.Size() + 1); + } + else + { + EXPECT_EQ(Result.GetFeaturesQuotaInfo().Size(), TierFeaturesArray.Size()); + } + + // We do not validate the full FeatureQuotaInfo object here as its data is subject to change. + for (size_t i = 0; i < Result.GetFeaturesQuotaInfo().Size(); i++) + { + if (IsGoogleGenAITierFeatureEnabled) + { + if (i == Result.GetFeaturesQuotaInfo().Size() - 1) + { + EXPECT_EQ(Result.GetFeaturesQuotaInfo()[i].FeatureName, TierFeatures::GoogleGenAI); + break; + } + } + EXPECT_EQ(Result.GetFeaturesQuotaInfo()[i].FeatureName, TierFeaturesArray[i]); } } @@ -245,9 +270,6 @@ CSP_PUBLIC_TEST(CSPEngine, QuotaSystemTests, GetConcurrentUsersInSpace) auto QuotaSystem = SystemsManager.GetQuotaSystem(); auto SpaceSystem = SystemsManager.GetSpaceSystem(); - csp::common::Array TierFeaturesArray = { TierFeatures::SpaceOwner, TierFeatures::ObjectCaptureUpload, - TierFeatures::AudioVideoUpload, TierFeatures::OpenAI, TierFeatures::TicketedSpace }; - const char* TestSpaceName = "CSP-UNITTEST-SPACE-MAG"; const char* TestSpaceDescription = "CSP-UNITTEST-SPACEDESC-MAG";