-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
460e3e6
commit f56162a
Showing
14 changed files
with
2,187 additions
and
33 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -24,6 +24,9 @@ | |
"SenderEmailAddress": "[email protected]", | ||
"SenderDisplayName": "Support" | ||
}, | ||
"EventNotifications": { | ||
"SubscriptionName": "ApiHost1" | ||
}, | ||
"SSOProvidersService": { | ||
"SSOUserTokens": { | ||
"AesSecret": "V7z5SZnhHRa7z68adsvazQjeIbSiWWcR+4KuAUikhe0=::u4ErEVotb170bM8qKWyT8A==" | ||
|
@@ -36,8 +39,8 @@ | |
"Gravatar": { | ||
"BaseUrl": "https://localhost:5656/gravatar/" | ||
}, | ||
"EventNotifications": { | ||
"SubscriptionName": "ApiHost1" | ||
"UserPilot": { | ||
"BaseUrl": "https://localhost:5656/userpilot/" | ||
} | ||
}, | ||
"Hosts": { | ||
|
142 changes: 142 additions & 0 deletions
142
...re.Shared.IntegrationTests/ApplicationServices/External/UserPilotHttpServiceClientSpec.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,142 @@ | ||
using Application.Interfaces; | ||
using Application.Resources.Shared; | ||
using Common.Configuration; | ||
using Common.Recording; | ||
using Domain.Interfaces; | ||
using Infrastructure.Shared.ApplicationServices.External; | ||
using IntegrationTesting.WebApi.Common; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using UnitTesting.Common; | ||
using Xunit; | ||
|
||
namespace Infrastructure.Shared.IntegrationTests.ApplicationServices.External; | ||
|
||
[Trait("Category", "Integration.External")] | ||
[Collection("External")] | ||
public class UserPilotHttpServiceClientSpec : ExternalApiSpec | ||
{ | ||
private readonly UserPilotHttpServiceClient _serviceClient; | ||
|
||
public UserPilotHttpServiceClientSpec(ExternalApiSetup setup) : base(setup, OverrideDependencies) | ||
{ | ||
var settings = setup.GetRequiredService<IConfigurationSettings>(); | ||
_serviceClient = new UserPilotHttpServiceClient(NoOpRecorder.Instance, settings, new TestHttpClientFactory()); | ||
} | ||
|
||
[Fact] | ||
public async Task WhenDeliverAsyncWithNonIdentifiableEventByAnonymousUntenanted_ThenTracksEvent() | ||
{ | ||
var result = await _serviceClient.DeliverAsync(new TestCaller(), CallerConstants.AnonymousUserId, "aneventname", | ||
new Dictionary<string, string> | ||
{ | ||
{ "aname", "avalue" } | ||
}); | ||
|
||
result.Should().BeSuccess(); | ||
} | ||
|
||
[Fact] | ||
public async Task WhenDeliverAsyncWithNonIdentifiableEventByUserUntenanted_ThenTracksEvent() | ||
{ | ||
var result = await _serviceClient.DeliverAsync(new TestCaller(), "user_1234567890123456789012", "aneventname", | ||
new Dictionary<string, string> | ||
{ | ||
{ "aname", "avalue" } | ||
}); | ||
|
||
result.Should().BeSuccess(); | ||
} | ||
|
||
[Fact] | ||
public async Task WhenDeliverAsyncWithNonIdentifiableEventByAnonymousTenanted_ThenTracksEvent() | ||
{ | ||
var result = await _serviceClient.DeliverAsync(new TestCaller("org_1234567890123456789012"), | ||
CallerConstants.AnonymousUserId, "aneventname", | ||
new Dictionary<string, string> | ||
{ | ||
{ "aname", "avalue" } | ||
}); | ||
|
||
result.Should().BeSuccess(); | ||
} | ||
|
||
[Fact] | ||
public async Task WhenDeliverAsyncWithNonIdentifiableEventByUserTenanted_ThenTracksEvent() | ||
{ | ||
var result = await _serviceClient.DeliverAsync(new TestCaller("org_1234567890123456789012"), | ||
"user_1234567890123456789012", "aneventname", | ||
new Dictionary<string, string> | ||
{ | ||
{ "aname", "avalue" } | ||
}); | ||
|
||
result.Should().BeSuccess(); | ||
} | ||
|
||
[Fact] | ||
public async Task WhenDeliverAsyncWithUserLoginEvent_ThenIdentifiesAndTracks() | ||
{ | ||
var result = await _serviceClient.DeliverAsync(new TestCaller(), "auserid", | ||
UsageConstants.Events.UsageScenarios.Generic.UserLogin, new Dictionary<string, string> | ||
{ | ||
{ UsageConstants.Properties.UserIdOverride, "user_1234567890123456789012" }, | ||
{ UsageConstants.Properties.AuthProvider, "credentials" }, | ||
{ UsageConstants.Properties.Name, "aperson" }, | ||
{ UsageConstants.Properties.EmailAddress, "[email protected]" }, | ||
{ UsageConstants.Properties.DefaultOrganizationId, "org_1234567890123456789012" } | ||
}); | ||
|
||
result.Should().BeSuccess(); | ||
} | ||
|
||
[Fact] | ||
public async Task WhenDeliverAsyncWithOrganizationCreatedEvent_ThenIdentifiesAndTracks() | ||
{ | ||
var result = await _serviceClient.DeliverAsync(new TestCaller(), "auserid", | ||
UsageConstants.Events.UsageScenarios.Generic.OrganizationCreated, new Dictionary<string, string> | ||
{ | ||
{ UsageConstants.Properties.Id, "org_1234567890123456789012" }, | ||
{ UsageConstants.Properties.Name, "anorganization" }, | ||
{ UsageConstants.Properties.Ownership, OrganizationOwnership.Shared.ToString() }, | ||
{ UsageConstants.Properties.CreatedById, "user_1234567890123456789012" }, | ||
{ UsageConstants.Properties.UserIdOverride, "user_1234567890123456789012" } | ||
}); | ||
|
||
result.Should().BeSuccess(); | ||
} | ||
|
||
[Fact] | ||
public async Task WhenDeliverAsyncWithMembershipAddedEvent_ThenIdentifiesAndTracks() | ||
{ | ||
var result = await _serviceClient.DeliverAsync(new TestCaller(), "auserid", | ||
UsageConstants.Events.UsageScenarios.Generic.MembershipAdded, new Dictionary<string, string> | ||
{ | ||
{ UsageConstants.Properties.Id, "membership_1234567890123456789012" }, | ||
{ UsageConstants.Properties.TenantIdOverride, "org_1234567890123456789012" }, | ||
{ UsageConstants.Properties.UserIdOverride, "user_1234567890123456789012" } | ||
}); | ||
|
||
result.Should().BeSuccess(); | ||
} | ||
|
||
[Fact] | ||
public async Task WhenDeliverAsyncWithMembershipChangedEvent_ThenIdentifiesAndTracks() | ||
{ | ||
var result = await _serviceClient.DeliverAsync(new TestCaller(), "auserid", | ||
UsageConstants.Events.UsageScenarios.Generic.MembershipChanged, new Dictionary<string, string> | ||
{ | ||
{ UsageConstants.Properties.Id, "membership_1234567890123456789012" }, | ||
{ UsageConstants.Properties.TenantIdOverride, "org_1234567890123456789012" }, | ||
{ UsageConstants.Properties.UserIdOverride, "user_1234567890123456789012" }, | ||
{ UsageConstants.Properties.Name, "aperson" }, | ||
{ UsageConstants.Properties.EmailAddress, "[email protected]" } | ||
}); | ||
|
||
result.Should().BeSuccess(); | ||
} | ||
|
||
private static void OverrideDependencies(IServiceCollection services) | ||
{ | ||
//Do nothing | ||
} | ||
} |
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.