From db37a23744d223bd05b30db81de24a5ed2be19c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Manciot?= Date: Wed, 6 May 2026 09:18:14 +0200 Subject: [PATCH 1/2] feat: refactor LicenseKey to use trial field instead of metadata for trial status --- .../app/softnetwork/elastic/licensing/package.scala | 5 +++-- .../softnetwork/elastic/licensing/LicenseKeySpec.scala | 9 ++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/licensing/src/main/scala/app/softnetwork/elastic/licensing/package.scala b/licensing/src/main/scala/app/softnetwork/elastic/licensing/package.scala index 9a061fac..4c75d44b 100644 --- a/licensing/src/main/scala/app/softnetwork/elastic/licensing/package.scala +++ b/licensing/src/main/scala/app/softnetwork/elastic/licensing/package.scala @@ -102,11 +102,12 @@ package object licensing { metadata: Map[String, String] = Map.empty, quota: Option[Quota] = None, usage: Option[LicenseUsage] = None, - platform: Option[Platform] = None + platform: Option[Platform] = None, + trial: Boolean = false ) { /** Whether this is a trial license (Pro trial via API key). */ - def isTrial: Boolean = metadata.get("trial").contains("true") + def isTrial: Boolean = trial /** Days remaining until expiration, or None if no expiry. Positive = not yet expired. */ def daysRemaining: Option[Long] = daysRemainingAt(java.time.Instant.now()) diff --git a/licensing/src/test/scala/app/softnetwork/elastic/licensing/LicenseKeySpec.scala b/licensing/src/test/scala/app/softnetwork/elastic/licensing/LicenseKeySpec.scala index 372d4cfc..22442acd 100644 --- a/licensing/src/test/scala/app/softnetwork/elastic/licensing/LicenseKeySpec.scala +++ b/licensing/src/test/scala/app/softnetwork/elastic/licensing/LicenseKeySpec.scala @@ -87,13 +87,13 @@ class LicenseKeySpec extends AnyFlatSpec with Matchers { key.metadata shouldBe empty } - "isTrial" should "return true when trial metadata is set" in { + "isTrial" should "return true when trial field is set" in { val key = LicenseKey( id = "org-123", licenseType = LicenseType.Pro, features = Set(Feature.MaterializedViews), expiresAt = Some(Instant.now().plus(Duration.ofDays(30))), - metadata = Map("trial" -> "true") + trial = true ) key.isTrial shouldBe true } @@ -103,13 +103,12 @@ class LicenseKeySpec extends AnyFlatSpec with Matchers { id = "org-123", licenseType = LicenseType.Pro, features = Set(Feature.MaterializedViews), - expiresAt = Some(Instant.now().plus(Duration.ofDays(365))), - metadata = Map("trial" -> "false") + expiresAt = Some(Instant.now().plus(Duration.ofDays(365))) ) key.isTrial shouldBe false } - it should "return false when trial metadata is absent" in { + it should "return false when trial defaults to false" in { LicenseKey.Community.isTrial shouldBe false } From 953b9ecc4ad72f1c2cbad0fd622bad3f9b7f8d0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Manciot?= Date: Wed, 6 May 2026 10:19:18 +0200 Subject: [PATCH 2/2] feat: update LicenseExecutorSpec to use trial field instead of metadata for trial status --- .../app/softnetwork/elastic/client/LicenseExecutorSpec.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/test/scala/app/softnetwork/elastic/client/LicenseExecutorSpec.scala b/core/src/test/scala/app/softnetwork/elastic/client/LicenseExecutorSpec.scala index f82da7f9..b0b66aaa 100644 --- a/core/src/test/scala/app/softnetwork/elastic/client/LicenseExecutorSpec.scala +++ b/core/src/test/scala/app/softnetwork/elastic/client/LicenseExecutorSpec.scala @@ -177,7 +177,7 @@ class LicenseExecutorSpec extends AnyFlatSpec with Matchers { licenseType = LicenseType.Pro, features = Feature.values.toSet, expiresAt = Some(Instant.now().plusSeconds(15 * 86400)), - metadata = Map("trial" -> "true") + trial = true ) } val executor = new LicenseExecutor(strategy = mkStrategy(trialManager)) @@ -302,7 +302,7 @@ class LicenseExecutorSpec extends AnyFlatSpec with Matchers { licenseType = LicenseType.Pro, features = Feature.values.toSet, expiresAt = Some(Instant.parse("2026-07-08T23:59:59Z")), - metadata = Map("trial" -> "true") + trial = true ) val executor = new LicenseExecutor( strategy = mkStrategy(proManager, refreshResult = Right(trialKey))