2022-06-30 01:46:41 +02:00
|
|
|
|
using System.Text;
|
2021-10-05 18:12:05 +02:00
|
|
|
|
using AutoFixture;
|
|
|
|
|
using Bit.Core.Context;
|
2022-01-11 10:40:51 +01:00
|
|
|
|
using Bit.Core.Entities;
|
2021-10-05 18:12:05 +02:00
|
|
|
|
using Bit.Core.Enums;
|
|
|
|
|
using Bit.Core.Enums.Provider;
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 23:25:06 +01:00
|
|
|
|
using Bit.Core.Test.AutoFixture.UserFixtures;
|
|
|
|
|
using Bit.Core.Utilities;
|
|
|
|
|
using Bit.Test.Common.AutoFixture;
|
|
|
|
|
using Bit.Test.Common.AutoFixture.Attributes;
|
2021-10-05 18:12:05 +02:00
|
|
|
|
using IdentityModel;
|
2022-05-20 21:24:59 +02:00
|
|
|
|
using Microsoft.AspNetCore.DataProtection;
|
2021-01-06 19:49:28 +01:00
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace Bit.Core.Test.Utilities;
|
2022-08-29 22:06:55 +02:00
|
|
|
|
|
2021-01-06 19:49:28 +01:00
|
|
|
|
public class CoreHelpersTests
|
|
|
|
|
{
|
|
|
|
|
public static IEnumerable<object[]> _epochTestCases = new[]
|
|
|
|
|
{
|
|
|
|
|
new object[] {new DateTime(2020, 12, 30, 11, 49, 12, DateTimeKind.Utc), 1609328952000L},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void GenerateComb_Success()
|
|
|
|
|
{
|
|
|
|
|
// Arrange & Act
|
|
|
|
|
var comb = CoreHelpers.GenerateComb();
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.NotEqual(Guid.Empty, comb);
|
|
|
|
|
// TODO: Add more asserts to make sure important aspects of
|
|
|
|
|
// the comb are working properly
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-10 23:12:09 +02:00
|
|
|
|
public static IEnumerable<object[]> GenerateCombCases = new[]
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2022-05-10 23:12:09 +02:00
|
|
|
|
new object[]
|
|
|
|
|
{
|
|
|
|
|
Guid.Parse("a58db474-43d8-42f1-b4ee-0c17647cd0c0"), // Input Guid
|
|
|
|
|
new DateTime(2022, 3, 12, 12, 12, 0, DateTimeKind.Utc), // Input Time
|
|
|
|
|
Guid.Parse("a58db474-43d8-42f1-b4ee-ae5600c90cc1"), // Expected Comb
|
2022-08-29 20:53:16 +02:00
|
|
|
|
},
|
2022-05-10 23:12:09 +02:00
|
|
|
|
new object[]
|
2022-08-29 20:53:16 +02:00
|
|
|
|
{
|
2022-05-10 23:12:09 +02:00
|
|
|
|
Guid.Parse("f776e6ee-511f-4352-bb28-88513002bdeb"),
|
|
|
|
|
new DateTime(2021, 5, 10, 10, 52, 0, DateTimeKind.Utc),
|
|
|
|
|
Guid.Parse("f776e6ee-511f-4352-bb28-ad2400b313c1"),
|
2022-08-29 22:06:55 +02:00
|
|
|
|
},
|
2022-05-10 23:12:09 +02:00
|
|
|
|
new object[]
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2022-05-10 23:12:09 +02:00
|
|
|
|
Guid.Parse("51a25fc7-3cad-497d-8e2f-8d77011648a1"),
|
|
|
|
|
new DateTime(1999, 2, 26, 16, 53, 13, DateTimeKind.Utc),
|
|
|
|
|
Guid.Parse("51a25fc7-3cad-497d-8e2f-8d77011649cd"),
|
2022-08-29 22:06:55 +02:00
|
|
|
|
},
|
2022-05-10 23:12:09 +02:00
|
|
|
|
new object[]
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2022-05-10 23:12:09 +02:00
|
|
|
|
Guid.Parse("bfb8f353-3b32-4a9e-bef6-24fe0b54bfb0"),
|
|
|
|
|
new DateTime(2024, 10, 20, 1, 32, 16, DateTimeKind.Utc),
|
|
|
|
|
Guid.Parse("bfb8f353-3b32-4a9e-bef6-b20f00195780"),
|
|
|
|
|
}
|
2022-08-29 22:06:55 +02:00
|
|
|
|
};
|
2022-05-10 23:12:09 +02:00
|
|
|
|
|
2021-01-06 19:49:28 +01:00
|
|
|
|
[Theory]
|
|
|
|
|
[MemberData(nameof(GenerateCombCases))]
|
|
|
|
|
public void GenerateComb_WithInputs_Success(Guid inputGuid, DateTime inputTime, Guid expectedComb)
|
|
|
|
|
{
|
|
|
|
|
var comb = CoreHelpers.GenerateComb(inputGuid, inputTime);
|
|
|
|
|
|
|
|
|
|
Assert.Equal(expectedComb, comb);
|
2022-08-29 22:06:55 +02:00
|
|
|
|
}
|
2021-01-06 19:49:28 +01:00
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData(2, 5, new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 })]
|
|
|
|
|
[InlineData(2, 3, new[] { 1, 2, 3, 4, 5 })]
|
|
|
|
|
[InlineData(2, 1, new[] { 1, 2 })]
|
|
|
|
|
[InlineData(1, 1, new[] { 1 })]
|
|
|
|
|
[InlineData(2, 2, new[] { 1, 2, 3 })]
|
|
|
|
|
public void Batch_Success(int batchSize, int totalBatches, int[] collection)
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2021-01-06 19:49:28 +01:00
|
|
|
|
// Arrange
|
|
|
|
|
var remainder = collection.Length % batchSize;
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
var batches = collection.Batch(batchSize);
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Equal(totalBatches, batches.Count());
|
|
|
|
|
|
|
|
|
|
foreach (var batch in batches.Take(totalBatches - 1))
|
|
|
|
|
{
|
|
|
|
|
Assert.Equal(batchSize, batch.Count());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Assert.Equal(batches.Last().Count(), remainder == 0 ? batchSize : remainder);
|
2022-08-29 22:06:55 +02:00
|
|
|
|
}
|
2021-01-06 19:49:28 +01:00
|
|
|
|
|
|
|
|
|
/*
|
2022-08-29 22:06:55 +02:00
|
|
|
|
[Fact]
|
2021-01-06 19:49:28 +01:00
|
|
|
|
public void ToGuidIdArrayTVP_Success()
|
|
|
|
|
{
|
|
|
|
|
// Arrange
|
|
|
|
|
var item0 = Guid.NewGuid();
|
|
|
|
|
var item1 = Guid.NewGuid();
|
|
|
|
|
|
|
|
|
|
var ids = new[] { item0, item1 };
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
var dt = ids.ToGuidIdArrayTVP();
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Single(dt.Columns);
|
|
|
|
|
Assert.Equal("GuidId", dt.Columns[0].ColumnName);
|
|
|
|
|
Assert.Equal(2, dt.Rows.Count);
|
|
|
|
|
Assert.Equal(item0, dt.Rows[0][0]);
|
|
|
|
|
Assert.Equal(item1, dt.Rows[1][0]);
|
2022-08-29 22:06:55 +02:00
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
2021-01-06 19:49:28 +01:00
|
|
|
|
// TODO: Test the other ToArrayTVP Methods
|
2022-08-29 22:06:55 +02:00
|
|
|
|
|
2022-08-29 21:53:48 +02:00
|
|
|
|
[Theory]
|
2021-01-06 19:49:28 +01:00
|
|
|
|
[InlineData("12345&6789", "123456789")]
|
|
|
|
|
[InlineData("abcdef", "ABCDEF")]
|
|
|
|
|
[InlineData("1!@#$%&*()_+", "1")]
|
|
|
|
|
[InlineData("\u00C6123abc\u00C7", "123ABC")]
|
|
|
|
|
[InlineData("123\u00C6ABC", "123ABC")]
|
|
|
|
|
[InlineData("\r\nHello", "E")]
|
|
|
|
|
[InlineData("\tdef", "DEF")]
|
|
|
|
|
[InlineData("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV1234567890", "ABCDEFABCDEF1234567890")]
|
|
|
|
|
public void CleanCertificateThumbprint_Success(string input, string output)
|
2022-08-29 21:53:48 +02:00
|
|
|
|
{
|
2021-01-06 19:49:28 +01:00
|
|
|
|
// Arrange & Act
|
|
|
|
|
var sanitizedInput = CoreHelpers.CleanCertificateThumbprint(input);
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Equal(output, sanitizedInput);
|
2022-08-29 22:06:55 +02:00
|
|
|
|
}
|
2021-01-06 19:49:28 +01:00
|
|
|
|
|
|
|
|
|
// TODO: Add more tests
|
|
|
|
|
[Theory]
|
|
|
|
|
[MemberData(nameof(_epochTestCases))]
|
|
|
|
|
public void ToEpocMilliseconds_Success(DateTime date, long milliseconds)
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2021-01-06 19:49:28 +01:00
|
|
|
|
// Act & Assert
|
|
|
|
|
Assert.Equal(milliseconds, CoreHelpers.ToEpocMilliseconds(date));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
[MemberData(nameof(_epochTestCases))]
|
|
|
|
|
public void FromEpocMilliseconds(DateTime date, long milliseconds)
|
|
|
|
|
{
|
2021-10-05 18:12:05 +02:00
|
|
|
|
// Act & Assert
|
|
|
|
|
Assert.Equal(date, CoreHelpers.FromEpocMilliseconds(milliseconds));
|
2022-08-29 21:53:48 +02:00
|
|
|
|
}
|
2021-01-06 19:49:28 +01:00
|
|
|
|
|
2022-08-29 21:53:48 +02:00
|
|
|
|
[Fact]
|
2021-10-05 18:12:05 +02:00
|
|
|
|
public void SecureRandomString_Success()
|
2022-08-29 21:53:48 +02:00
|
|
|
|
{
|
2021-10-05 18:12:05 +02:00
|
|
|
|
// Arrange & Act
|
|
|
|
|
var @string = CoreHelpers.SecureRandomString(8);
|
2021-01-06 19:49:28 +01:00
|
|
|
|
|
|
|
|
|
// Assert
|
2021-10-05 18:12:05 +02:00
|
|
|
|
// TODO: Should probably add more Asserts down the line
|
|
|
|
|
Assert.Equal(8, @string.Length);
|
2022-08-29 22:06:55 +02:00
|
|
|
|
}
|
2021-01-06 19:49:28 +01:00
|
|
|
|
|
2022-08-29 22:06:55 +02:00
|
|
|
|
[Theory]
|
2021-01-06 19:49:28 +01:00
|
|
|
|
[InlineData(1, "1 Bytes")]
|
|
|
|
|
[InlineData(-5L, "-5 Bytes")]
|
|
|
|
|
[InlineData(1023L, "1023 Bytes")]
|
|
|
|
|
[InlineData(1024L, "1 KB")]
|
|
|
|
|
[InlineData(1025L, "1 KB")]
|
|
|
|
|
[InlineData(-1023L, "-1023 Bytes")]
|
|
|
|
|
[InlineData(-1024L, "-1 KB")]
|
|
|
|
|
[InlineData(-1025L, "-1 KB")]
|
|
|
|
|
[InlineData(1048575L, "1024 KB")]
|
|
|
|
|
[InlineData(1048576L, "1 MB")]
|
|
|
|
|
[InlineData(1048577L, "1 MB")]
|
|
|
|
|
[InlineData(-1048575L, "-1024 KB")]
|
|
|
|
|
[InlineData(-1048576L, "-1 MB")]
|
|
|
|
|
[InlineData(-1048577L, "-1 MB")]
|
|
|
|
|
[InlineData(1073741823L, "1024 MB")]
|
|
|
|
|
[InlineData(1073741824L, "1 GB")]
|
|
|
|
|
[InlineData(1073741825L, "1 GB")]
|
|
|
|
|
[InlineData(-1073741823L, "-1024 MB")]
|
|
|
|
|
[InlineData(-1073741824L, "-1 GB")]
|
|
|
|
|
[InlineData(-1073741825L, "-1 GB")]
|
|
|
|
|
[InlineData(long.MaxValue, "8589934592 GB")]
|
|
|
|
|
public void ReadableBytesSize_Success(long size, string readable)
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2021-01-06 19:49:28 +01:00
|
|
|
|
// Act & Assert
|
|
|
|
|
Assert.Equal(readable, CoreHelpers.ReadableBytesSize(size));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void CloneObject_Success()
|
2022-08-29 21:53:48 +02:00
|
|
|
|
{
|
2021-01-06 19:49:28 +01:00
|
|
|
|
var original = new { Message = "Message" };
|
|
|
|
|
|
|
|
|
|
var copy = CoreHelpers.CloneObject(original);
|
|
|
|
|
|
|
|
|
|
Assert.Equal(original.Message, copy.Message);
|
2022-08-29 21:53:48 +02:00
|
|
|
|
}
|
2021-01-06 19:49:28 +01:00
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void ExtendQuery_AddNewParameter_Success()
|
|
|
|
|
{
|
|
|
|
|
// Arrange
|
|
|
|
|
var uri = new Uri("https://bitwarden.com/?param1=value1");
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
var newUri = CoreHelpers.ExtendQuery(uri,
|
|
|
|
|
new Dictionary<string, string> { { "param2", "value2" } });
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Equal("https://bitwarden.com/?param1=value1¶m2=value2", newUri.ToString());
|
2022-08-29 21:53:48 +02:00
|
|
|
|
}
|
2021-01-06 19:49:28 +01:00
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void ExtendQuery_AddTwoNewParameters_Success()
|
2022-08-29 21:53:48 +02:00
|
|
|
|
{
|
2021-01-06 19:49:28 +01:00
|
|
|
|
// Arrange
|
|
|
|
|
var uri = new Uri("https://bitwarden.com/?param1=value1");
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
var newUri = CoreHelpers.ExtendQuery(uri,
|
|
|
|
|
new Dictionary<string, string>
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2021-01-06 19:49:28 +01:00
|
|
|
|
{ "param2", "value2" },
|
|
|
|
|
{ "param3", "value3" }
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Equal("https://bitwarden.com/?param1=value1¶m2=value2¶m3=value3", newUri.ToString());
|
2022-08-29 21:53:48 +02:00
|
|
|
|
}
|
2021-01-06 19:49:28 +01:00
|
|
|
|
|
2022-08-29 20:53:16 +02:00
|
|
|
|
[Fact]
|
2021-01-06 19:49:28 +01:00
|
|
|
|
public void ExtendQuery_AddExistingParameter_Success()
|
|
|
|
|
{
|
|
|
|
|
// Arrange
|
|
|
|
|
var uri = new Uri("https://bitwarden.com/?param1=value1¶m2=value2");
|
|
|
|
|
|
2022-08-29 22:06:55 +02:00
|
|
|
|
// Act
|
2021-01-06 19:49:28 +01:00
|
|
|
|
var newUri = CoreHelpers.ExtendQuery(uri,
|
|
|
|
|
new Dictionary<string, string> { { "param1", "test_value" } });
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Equal("https://bitwarden.com/?param1=test_value¶m2=value2", newUri.ToString());
|
2022-08-29 22:06:55 +02:00
|
|
|
|
}
|
2021-08-31 05:49:11 +02:00
|
|
|
|
|
2022-08-29 22:06:55 +02:00
|
|
|
|
[Fact]
|
2021-10-05 18:12:05 +02:00
|
|
|
|
public void ExtendQuery_AddNoParameters_Success()
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2021-10-05 18:12:05 +02:00
|
|
|
|
// Arrange
|
2021-08-31 05:49:11 +02:00
|
|
|
|
const string startingUri = "https://bitwarden.com/?param1=value1";
|
2021-10-05 18:12:05 +02:00
|
|
|
|
|
|
|
|
|
var uri = new Uri(startingUri);
|
|
|
|
|
|
2022-08-29 21:53:48 +02:00
|
|
|
|
// Act
|
2021-10-05 18:12:05 +02:00
|
|
|
|
var newUri = CoreHelpers.ExtendQuery(uri, new Dictionary<string, string>());
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.Equal(startingUri, newUri.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-29 22:06:55 +02:00
|
|
|
|
[Theory]
|
2021-10-05 18:12:05 +02:00
|
|
|
|
[InlineData("bücher.com", "xn--bcher-kva.com")]
|
2021-08-31 05:49:11 +02:00
|
|
|
|
[InlineData("bücher.cömé", "xn--bcher-kva.xn--cm-cja4c")]
|
|
|
|
|
[InlineData("hello@bücher.com", "hello@xn--bcher-kva.com")]
|
2021-10-05 18:12:05 +02:00
|
|
|
|
[InlineData("hello@world.cömé", "hello@world.xn--cm-cja4c")]
|
2021-08-31 05:49:11 +02:00
|
|
|
|
[InlineData("hello@bücher.cömé", "hello@xn--bcher-kva.xn--cm-cja4c")]
|
|
|
|
|
[InlineData("ascii.com", "ascii.com")]
|
|
|
|
|
[InlineData("", "")]
|
2021-10-05 18:12:05 +02:00
|
|
|
|
[InlineData(null, null)]
|
|
|
|
|
public void PunyEncode_Success(string text, string expected)
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2021-10-05 18:12:05 +02:00
|
|
|
|
var actual = CoreHelpers.PunyEncode(text);
|
|
|
|
|
Assert.Equal(expected, actual);
|
2022-08-29 22:06:55 +02:00
|
|
|
|
}
|
2021-10-05 18:12:05 +02:00
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void GetEmbeddedResourceContentsAsync_Success()
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2021-10-05 18:12:05 +02:00
|
|
|
|
var fileContents = CoreHelpers.GetEmbeddedResourceContentsAsync("data.embeddedResource.txt");
|
2021-08-31 05:49:11 +02:00
|
|
|
|
Assert.Equal("Contents of embeddedResource.txt\n", fileContents.Replace("\r\n", "\n"));
|
2022-08-29 21:53:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-05 18:12:05 +02:00
|
|
|
|
[Theory, CustomAutoData(typeof(UserFixture))]
|
|
|
|
|
public void BuildIdentityClaims_BaseClaims_Success(User user, bool isPremium)
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2021-10-05 18:12:05 +02:00
|
|
|
|
var expected = new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{ "premium", isPremium ? "true" : "false" },
|
|
|
|
|
{ JwtClaimTypes.Email, user.Email },
|
|
|
|
|
{ JwtClaimTypes.EmailVerified, user.EmailVerified ? "true" : "false" },
|
|
|
|
|
{ JwtClaimTypes.Name, user.Name },
|
|
|
|
|
{ "sstamp", user.SecurityStamp },
|
|
|
|
|
}.ToList();
|
|
|
|
|
|
|
|
|
|
var actual = CoreHelpers.BuildIdentityClaims(user, Array.Empty<CurrentContentOrganization>(),
|
|
|
|
|
Array.Empty<CurrentContentProvider>(), isPremium);
|
|
|
|
|
|
|
|
|
|
foreach (var claim in expected)
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2021-10-05 18:12:05 +02:00
|
|
|
|
Assert.Contains(claim, actual);
|
|
|
|
|
}
|
|
|
|
|
Assert.Equal(expected.Count, actual.Count);
|
2022-08-29 22:06:55 +02:00
|
|
|
|
}
|
2021-10-05 18:12:05 +02:00
|
|
|
|
|
|
|
|
|
[Theory, CustomAutoData(typeof(UserFixture))]
|
|
|
|
|
public void BuildIdentityClaims_NonCustomOrganizationUserType_Success(User user)
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2021-10-05 18:12:05 +02:00
|
|
|
|
var fixture = new Fixture().WithAutoNSubstitutions();
|
|
|
|
|
foreach (var organizationUserType in Enum.GetValues<OrganizationUserType>().Except(new[] { OrganizationUserType.Custom }))
|
|
|
|
|
{
|
|
|
|
|
var org = fixture.Create<CurrentContentOrganization>();
|
|
|
|
|
org.Type = organizationUserType;
|
|
|
|
|
|
|
|
|
|
var expected = new KeyValuePair<string, string>($"org{organizationUserType.ToString().ToLower()}", org.Id.ToString());
|
|
|
|
|
var actual = CoreHelpers.BuildIdentityClaims(user, new[] { org }, Array.Empty<CurrentContentProvider>(), false);
|
|
|
|
|
|
|
|
|
|
Assert.Contains(expected, actual);
|
|
|
|
|
}
|
2022-08-29 22:06:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-05 18:12:05 +02:00
|
|
|
|
[Theory, CustomAutoData(typeof(UserFixture))]
|
2022-05-20 21:24:59 +02:00
|
|
|
|
public void BuildIdentityClaims_CustomOrganizationUserClaims_Success(User user, CurrentContentOrganization org)
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2021-10-05 18:12:05 +02:00
|
|
|
|
var fixture = new Fixture().WithAutoNSubstitutions();
|
|
|
|
|
org.Type = OrganizationUserType.Custom;
|
|
|
|
|
|
|
|
|
|
var actual = CoreHelpers.BuildIdentityClaims(user, new[] { org }, Array.Empty<CurrentContentProvider>(), false);
|
|
|
|
|
foreach (var (permitted, claimName) in org.Permissions.ClaimsMap)
|
|
|
|
|
{
|
|
|
|
|
var claim = new KeyValuePair<string, string>(claimName, org.Id.ToString());
|
|
|
|
|
if (permitted)
|
|
|
|
|
{
|
2022-08-29 21:53:48 +02:00
|
|
|
|
|
2021-10-05 18:12:05 +02:00
|
|
|
|
Assert.Contains(claim, actual);
|
|
|
|
|
}
|
2022-05-20 21:24:59 +02:00
|
|
|
|
else
|
2022-08-29 21:53:48 +02:00
|
|
|
|
{
|
2021-10-05 18:12:05 +02:00
|
|
|
|
Assert.DoesNotContain(claim, actual);
|
2022-08-29 21:53:48 +02:00
|
|
|
|
}
|
2022-08-29 20:53:16 +02:00
|
|
|
|
}
|
2022-08-29 22:06:55 +02:00
|
|
|
|
}
|
2022-08-29 20:53:16 +02:00
|
|
|
|
|
2022-05-20 21:24:59 +02:00
|
|
|
|
[Theory, CustomAutoData(typeof(UserFixture))]
|
|
|
|
|
public void BuildIdentityClaims_ProviderClaims_Success(User user)
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2021-10-05 18:12:05 +02:00
|
|
|
|
var fixture = new Fixture().WithAutoNSubstitutions();
|
2022-05-20 21:24:59 +02:00
|
|
|
|
var providers = new List<CurrentContentProvider>();
|
|
|
|
|
foreach (var providerUserType in Enum.GetValues<ProviderUserType>())
|
2022-08-29 20:53:16 +02:00
|
|
|
|
{
|
2022-05-20 21:24:59 +02:00
|
|
|
|
var provider = fixture.Create<CurrentContentProvider>();
|
2021-10-05 18:12:05 +02:00
|
|
|
|
provider.Type = providerUserType;
|
|
|
|
|
providers.Add(provider);
|
2022-08-29 22:06:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-20 21:24:59 +02:00
|
|
|
|
var claims = new List<KeyValuePair<string, string>>();
|
2022-08-29 22:06:55 +02:00
|
|
|
|
|
2021-10-05 18:12:05 +02:00
|
|
|
|
if (providers.Any())
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2022-05-20 21:24:59 +02:00
|
|
|
|
foreach (var group in providers.GroupBy(o => o.Type))
|
|
|
|
|
{
|
2021-10-05 18:12:05 +02:00
|
|
|
|
switch (group.Key)
|
2022-05-20 21:24:59 +02:00
|
|
|
|
{
|
|
|
|
|
case ProviderUserType.ProviderAdmin:
|
|
|
|
|
foreach (var provider in group)
|
|
|
|
|
{
|
|
|
|
|
claims.Add(new KeyValuePair<string, string>("providerprovideradmin", provider.Id.ToString()));
|
2022-08-29 22:06:55 +02:00
|
|
|
|
}
|
|
|
|
|
break;
|
2022-05-20 21:24:59 +02:00
|
|
|
|
case ProviderUserType.ServiceUser:
|
|
|
|
|
foreach (var provider in group)
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2022-05-20 21:24:59 +02:00
|
|
|
|
claims.Add(new KeyValuePair<string, string>("providerserviceuser", provider.Id.ToString()));
|
2022-08-29 22:06:55 +02:00
|
|
|
|
}
|
2022-05-20 21:24:59 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var actual = CoreHelpers.BuildIdentityClaims(user, Array.Empty<CurrentContentOrganization>(), providers, false);
|
|
|
|
|
foreach (var claim in claims)
|
|
|
|
|
{
|
|
|
|
|
Assert.Contains(claim, actual);
|
|
|
|
|
}
|
2022-08-29 22:06:55 +02:00
|
|
|
|
}
|
2022-05-20 21:24:59 +02:00
|
|
|
|
|
|
|
|
|
public static IEnumerable<object[]> TokenIsValidData()
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
|
|
|
|
return new[]
|
2022-05-20 21:24:59 +02:00
|
|
|
|
{
|
|
|
|
|
new object[]
|
2022-08-29 21:53:48 +02:00
|
|
|
|
{
|
2022-05-20 21:24:59 +02:00
|
|
|
|
"first_part 476669d4-9642-4af8-9b29-9366efad4ed3 test@email.com {0}", // unprotectedTokenTemplate
|
|
|
|
|
"first_part", // firstPart
|
|
|
|
|
"test@email.com", // email
|
|
|
|
|
Guid.Parse("476669d4-9642-4af8-9b29-9366efad4ed3"), // id
|
|
|
|
|
DateTime.UtcNow.AddHours(-1), // creationTime
|
|
|
|
|
12, // expirationInHours
|
|
|
|
|
true, // isValid
|
|
|
|
|
}
|
2022-08-29 22:06:55 +02:00
|
|
|
|
};
|
2022-08-29 20:53:16 +02:00
|
|
|
|
}
|
2022-08-29 22:06:55 +02:00
|
|
|
|
|
|
|
|
|
[Theory]
|
2022-05-20 21:24:59 +02:00
|
|
|
|
[MemberData(nameof(TokenIsValidData))]
|
|
|
|
|
public void TokenIsValid_Success(string unprotectedTokenTemplate, string firstPart, string userEmail, Guid id, DateTime creationTime, double expirationInHours, bool isValid)
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2022-05-20 21:24:59 +02:00
|
|
|
|
var protector = new TestDataProtector(string.Format(unprotectedTokenTemplate, CoreHelpers.ToEpocMilliseconds(creationTime)));
|
2022-08-29 21:53:48 +02:00
|
|
|
|
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 23:25:06 +01:00
|
|
|
|
Assert.Equal(isValid, CoreHelpers.TokenIsValid(firstPart, protector, "protected_token", userEmail, id, expirationInHours));
|
2022-08-29 22:06:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 23:25:06 +01:00
|
|
|
|
private class TestDataProtector : IDataProtector
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 23:25:06 +01:00
|
|
|
|
private readonly string _token;
|
|
|
|
|
public TestDataProtector(string token)
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
2022-05-20 21:24:59 +02:00
|
|
|
|
_token = token;
|
2022-08-29 22:06:55 +02:00
|
|
|
|
}
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 23:25:06 +01:00
|
|
|
|
public IDataProtector CreateProtector(string purpose) => throw new NotImplementedException();
|
|
|
|
|
public byte[] Protect(byte[] plaintext) => throw new NotImplementedException();
|
|
|
|
|
public byte[] Unprotect(byte[] protectedData)
|
|
|
|
|
{
|
|
|
|
|
return Encoding.UTF8.GetBytes(_token);
|
|
|
|
|
}
|
2021-01-06 19:49:28 +01:00
|
|
|
|
}
|
2022-08-29 22:06:55 +02:00
|
|
|
|
|
|
|
|
|
[Theory]
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 23:25:06 +01:00
|
|
|
|
[InlineData("hi@email.com", "hi@email.com")] // Short email with no room to obfuscate
|
|
|
|
|
[InlineData("name@email.com", "na**@email.com")] // Can obfuscate
|
|
|
|
|
[InlineData("reallylongnamethatnooneshouldhave@email", "re*******************************@email")] // Really long email and no .com, .net, etc
|
|
|
|
|
[InlineData("name@", "name@")] // @ symbol but no domain
|
|
|
|
|
[InlineData("", "")] // Empty string
|
|
|
|
|
[InlineData(null, null)] // null
|
2021-10-05 18:12:05 +02:00
|
|
|
|
public void ObfuscateEmail_Success(string input, string expected)
|
2022-08-29 22:06:55 +02:00
|
|
|
|
{
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 23:25:06 +01:00
|
|
|
|
Assert.Equal(expected, CoreHelpers.ObfuscateEmail(input));
|
2022-08-29 22:06:55 +02:00
|
|
|
|
}
|
2021-01-06 19:49:28 +01:00
|
|
|
|
}
|