forked from datalust/seqcli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix seqcli user create (datalust#168); add multi-user testing support…
… to the end-to-end tests
- Loading branch information
1 parent
5dc5991
commit 0fcc345
Showing
13 changed files
with
215 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
version: 2020.5.{build} | ||
version: 2021.1.{build} | ||
skip_tags: true | ||
image: | ||
- Visual Studio 2019 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
|
||
namespace SeqCli.EndToEnd.Support | ||
{ | ||
[AttributeUsage(AttributeTargets.Class)] | ||
public class CliTestCaseAttribute : Attribute | ||
{ | ||
public bool IsSetup { get; set; } | ||
public bool Multiuser { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
test/SeqCli.EndToEnd/Support/IsolatedTestCaseRegistrationSource.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Autofac; | ||
using Autofac.Core; | ||
using Autofac.Core.Activators.Delegate; | ||
using Autofac.Core.Lifetime; | ||
using Autofac.Core.Registration; | ||
using Seq.Api; | ||
using Serilog; | ||
|
||
namespace SeqCli.EndToEnd.Support | ||
{ | ||
// Built-in decorator support didn't transfer metadata. | ||
class IsolatedTestCaseRegistrationSource : IRegistrationSource | ||
{ | ||
public IEnumerable<IComponentRegistration> RegistrationsFor(Service service, Func<Service, IEnumerable<IComponentRegistration>> registrationAccessor) | ||
{ | ||
if (!(service is TypedService ts && ts.ServiceType == typeof(IsolatedTestCase))) | ||
yield break; | ||
|
||
var innerService = ts.ChangeType(typeof(ICliTestCase)); | ||
foreach (var inner in registrationAccessor(innerService)) | ||
{ | ||
yield return new ComponentRegistration( | ||
Guid.NewGuid(), | ||
new DelegateActivator(typeof(IsolatedTestCase), (ctx, p) => | ||
{ | ||
var tc = (ICliTestCase) ctx.ResolveComponent(new ResolveRequest(innerService, inner, p)); | ||
return new IsolatedTestCase( | ||
ctx.Resolve<Lazy<ITestProcess>>(), | ||
ctx.Resolve<Lazy<SeqConnection>>(), | ||
ctx.Resolve<Lazy<ILogger>>(), | ||
ctx.Resolve<CliCommandRunner>(), | ||
ctx.Resolve<Lazy<LicenseSetup>>(), | ||
tc); | ||
}), | ||
new CurrentScopeLifetime(), | ||
InstanceSharing.None, | ||
InstanceOwnership.OwnedByLifetimeScope, | ||
new[] {service}, | ||
inner.Metadata); | ||
} | ||
} | ||
|
||
public bool IsAdapterForIndividualComponents { get; } = true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Seq.Api; | ||
using SeqCli.EndToEnd.Support; | ||
using Serilog; | ||
|
||
namespace SeqCli.EndToEnd.Support | ||
{ | ||
public class LicenseSetup | ||
{ | ||
readonly bool _enabled; | ||
|
||
bool _attempted; | ||
string _certificate; | ||
|
||
public LicenseSetup(Args args) | ||
{ | ||
_enabled = args.Multiuser(); | ||
} | ||
|
||
public async Task SetupAsync( | ||
SeqConnection connection, | ||
ILogger logger) | ||
{ | ||
if (!_enabled) | ||
return; | ||
|
||
if (!_attempted) | ||
{ | ||
_attempted = true; | ||
logger.Information("Reading license certificate from STDIN...."); | ||
_certificate = await Console.In.ReadToEndAsync(); | ||
} | ||
|
||
var license = await connection.Licenses.FindCurrentAsync(); | ||
license.LicenseText = _certificate; | ||
await connection.Licenses.UpdateAsync(license); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.