diff --git a/Controllers/RvfController.cs b/Controllers/RvfController.cs index 0956a76..2eedb76 100644 --- a/Controllers/RvfController.cs +++ b/Controllers/RvfController.cs @@ -29,14 +29,25 @@ namespace rockfishCore.Controllers //### CUSTOMER ROUTE CALLED FROM RAVEN #### [HttpPost] - public async Task PostLicenseFetchRequest([FromBody] dtoFetchRequest fetchRequest) + public async Task PostLicenseFetchRequest([FromBody] dtoFetchRequest fetchRequest, [FromQuery] bool dtt) { if (!ModelState.IsValid) { return BadRequest(ModelState); } - string FetchRequestDbId=fetchRequest.DbId; + string FetchRequestDbId = fetchRequest.DbId; + + if (dtt) + { + return Ok(new + { + data = new + { + key = RavenKeyFactory.GetRavenTestKey(FetchRequestDbId) + } + }); + } string LicenseKey = null; //check for a key for this dbid, first check licensed then check trial diff --git a/util/RavenKeyFactory.cs b/util/RavenKeyFactory.cs index 63f1e08..deb3d40 100644 --- a/util/RavenKeyFactory.cs +++ b/util/RavenKeyFactory.cs @@ -460,6 +460,22 @@ oArP0E2Vbow3JMxq/oeXmHbrLMLQfYyXwFmciLFigOtkd45bfHdrbA== + public static string GetRavenTestKey(string dbid) + { + + //Build a sample test key, sign it and return it + AyaNovaLicenseKey k = new AyaNovaLicenseKey(); + k.LicenseFormat = "8"; + k.RegisteredTo = "GZ TestCo Inc."; + k.DbId = dbid; + k.Features.Add(new LicenseFeature() { Feature = ACCOUNTING_FEATURE_NAME, Count = 0 }); + k.Features.Add(new LicenseFeature() { Feature = SERVICE_TECHS_FEATURE_NAME, Count = 1000 }); + k.MaintenanceExpiration = k.LicenseExpiration = DateTime.UtcNow.AddMonths(1); + k.Features.Add(new LicenseFeature() { Feature = TRIAL_FEATURE_NAME, Count = 0 }); + k.Features.Add(new LicenseFeature() { Feature = RENTAL_FEATURE_NAME, Count = 0 }); + return GenerateRavenKey(k); + } + //eoc } //eons @@ -472,39 +488,4 @@ oArP0E2Vbow3JMxq/oeXmHbrLMLQfYyXwFmciLFigOtkd45bfHdrbA== -// public static string GetRavenTestKey(Guid dbid) -// { - -// //Build a sample test key, sign it and return it -// AyaNovaLicenseKey k = new AyaNovaLicenseKey(); -// k.LicenseFormat = "8"; - -// var vv = Math.Truncate((DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds); -// string sId = vv.ToString(); -// if (sId.Contains(",")) -// sId = sId.Split('.')[0]; -// k.Id = $"00-{sId}"; -// k.RegisteredTo = "Best Besterson Inc."; -// k.DbId = dbid; - -// //add accounting and user features either way -// k.Features.Add(new LicenseFeature() { Feature = ACCOUNTING_FEATURE_NAME, Count = 0 }); -// k.Features.Add(new LicenseFeature() { Feature = SERVICE_TECHS_FEATURE_NAME, Count = 1000 }); - - -// //fake trial key or fake licensed key -// if (dbid == TEST_TRIAL_KEY_DBID) -// { -// k.MaintenanceExpiration = k.LicenseExpiration = DateTime.UtcNow.AddMonths(1); -// k.Features.Add(new LicenseFeature() { Feature = TRIAL_FEATURE_NAME, Count = 0 }); -// } -// else -// { -// k.MaintenanceExpiration = DateTime.UtcNow.AddYears(1); -// k.LicenseExpiration = DateUtil.EmptyDateValue;//1/1/5555 as per spec -// } - -// return genKey(k); -// } - // #endregion \ No newline at end of file