public static IServiceCollection AddDocumentManagementHost(this IServiceCollection services, DocumentManagementApiOptions options) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } var loader = new LicenseLoader(); var license = loader.TryGetLicense(); if (license.ExpirationDateTime < DateTime.UtcNow) { throw new LicenseExpiredException(); } services.AddSingleton(options); services.AddDocumentManagementCore(); return(services); }
public void When_Trying_To_GetLicense_File_Then_Informations_Are_Returned() { var directory = Path.Combine(Directory.GetCurrentDirectory(), "Certificates"); Environment.SetEnvironmentVariable("SID_LICENSE", directory); var loader = new LicenseLoader(); var license = loader.TryGetLicense(); var t = ""; }
public async Task WhenImageNotFound_ThenAnnotationNotAdded() { var annotatedSet = CreateSet( new ImageLocator("unknown", "beos")); Assert.AreEqual(0, annotatedSet.LicenseAnnotations.Count()); var computeEngineAdapter = new ComputeEngineAdapter(Defaults.GetCredential()); await LicenseLoader.LoadLicenseAnnotationsAsync( annotatedSet, computeEngineAdapter, CancellationToken.None); Assert.AreEqual(0, annotatedSet.LicenseAnnotations.Count()); }
public async Task WhenImageNotFound_ThenAnnotationNotAdded( [Credential(Role = PredefinedRole.ComputeViewer)] ResourceTask <ICredential> credential) { var annotatedSet = CreateSet( new ImageLocator("unknown", "beos")); Assert.AreEqual(0, annotatedSet.LicenseAnnotations.Count()); var computeEngineAdapter = new ComputeEngineAdapter( await credential); await LicenseLoader.LoadLicenseAnnotationsAsync( annotatedSet, computeEngineAdapter, CancellationToken.None); Assert.AreEqual(0, annotatedSet.LicenseAnnotations.Count()); }
public async Task WhenImageNotFoundButFromWindowsProject_ThenAnnotationIsAdded() { var annotatedSet = CreateSet( new ImageLocator("windows-cloud", "windows-95")); Assert.AreEqual(0, annotatedSet.LicenseAnnotations.Count()); var computeEngineAdapter = new ComputeEngineAdapter(Defaults.GetCredential()); await LicenseLoader.LoadLicenseAnnotationsAsync( annotatedSet, computeEngineAdapter, CancellationToken.None); Assert.AreEqual(1, annotatedSet.LicenseAnnotations.Count()); var annotation = annotatedSet.LicenseAnnotations.Values.First(); Assert.AreEqual(OperatingSystemTypes.Windows, annotation.OperatingSystem); Assert.AreEqual(LicenseTypes.Spla, annotation.LicenseType); }
public async Task WhenImageFound_ThenAnnotationIsAdded( [Credential(Role = PredefinedRole.ComputeViewer)] ResourceTask <ICredential> credential) { var annotatedSet = CreateSet( new ImageLocator("windows-cloud", "family/windows-2019")); Assert.AreEqual(0, annotatedSet.LicenseAnnotations.Count()); var computeEngineAdapter = new ComputeEngineAdapter( await credential); await LicenseLoader.LoadLicenseAnnotationsAsync( annotatedSet, computeEngineAdapter, CancellationToken.None); Assert.AreEqual(1, annotatedSet.LicenseAnnotations.Count()); var annotation = annotatedSet.LicenseAnnotations.Values.First(); Assert.AreEqual(OperatingSystemTypes.Windows, annotation.OperatingSystem); Assert.AreEqual(LicenseTypes.Spla, annotation.LicenseType); }