From ca252ec6be01db98af7af4eb638c962ce009dbba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Seld=C3=A9n?= Date: Wed, 19 Aug 2026 16:28:42 +0200 Subject: [PATCH 1/9] Add support for configuring collect states in simulated environment --- .../BankIdSimulatedAppApiClient.cs | 34 ++++++++++++-- .../BankIdSimulatedEnvironmentOptions.cs | 14 ++++++ .../IBankIdBuilderExtensions.cs | 28 +++++++++++- .../BankIdSimulatedAppApiClient_Tests.cs | 45 +++++++++++++++++++ .../BankIdBuilder_Tests.cs | 28 ++++++++++++ 5 files changed, 145 insertions(+), 4 deletions(-) create mode 100644 src/ActiveLogin.Authentication.BankId.Core/BankIdSimulatedEnvironmentOptions.cs diff --git a/src/ActiveLogin.Authentication.BankId.Api/BankIdSimulatedAppApiClient.cs b/src/ActiveLogin.Authentication.BankId.Api/BankIdSimulatedAppApiClient.cs index ba7b44c3..617a3d11 100644 --- a/src/ActiveLogin.Authentication.BankId.Api/BankIdSimulatedAppApiClient.cs +++ b/src/ActiveLogin.Authentication.BankId.Api/BankIdSimulatedAppApiClient.cs @@ -26,6 +26,34 @@ public class BankIdSimulatedAppApiClient : IBankIdAppApiClient new CollectState(CollectStatus.Complete, CollectHintCode.UserSign) }; + /// + /// Gets a new collect-state sequence that resembles a normal authentication flow. + /// + public static List NormalCollectStates => new(DefaultCollectStates); + + /// + /// Gets a new collect-state sequence with the fewest states needed to complete authentication. + /// + public static List FastCollectStates => new() + { + new CollectState(CollectStatus.Pending, CollectHintCode.OutstandingTransaction), + new CollectState(CollectStatus.Complete, CollectHintCode.UserSign) + }; + + /// + /// Gets a new collect-state sequence that covers the UI-relevant successful hint codes. + /// + public static List AllCollectStates => new() + { + new CollectState(CollectStatus.Pending, CollectHintCode.OutstandingTransaction), + new CollectState(CollectStatus.Pending, CollectHintCode.NoClient), + new CollectState(CollectStatus.Pending, CollectHintCode.Started), + new CollectState(CollectStatus.Pending, CollectHintCode.UserMrtd), + new CollectState(CollectStatus.Pending, CollectHintCode.UserCallConfirm), + new CollectState(CollectStatus.Pending, CollectHintCode.UserSign), + new CollectState(CollectStatus.Complete, CollectHintCode.UserSign) + }; + private readonly string _givenName; private readonly string _surname; private readonly string _name; @@ -38,7 +66,7 @@ public class BankIdSimulatedAppApiClient : IBankIdAppApiClient private TimeSpan _delay = TimeSpan.FromMilliseconds(250); public BankIdSimulatedAppApiClient() - : this(DefaultCollectStates) + : this(NormalCollectStates) { } @@ -53,7 +81,7 @@ public BankIdSimulatedAppApiClient(string givenName, string surname) } public BankIdSimulatedAppApiClient(string givenName, string surname, string personalIdentityNumber) - : this(givenName, surname, personalIdentityNumber, DefaultCollectStates) + : this(givenName, surname, personalIdentityNumber, NormalCollectStates) { } @@ -63,7 +91,7 @@ public BankIdSimulatedAppApiClient(string givenName, string surname, string pers } public BankIdSimulatedAppApiClient(string givenName, string surname, string name, string personalIdentityNumber) - : this(givenName, surname, name, personalIdentityNumber, DefaultBankIdIssueDate, DefaultUniqueHardwareId, DefaultCollectStates) + : this(givenName, surname, name, personalIdentityNumber, DefaultBankIdIssueDate, DefaultUniqueHardwareId, NormalCollectStates) { } diff --git a/src/ActiveLogin.Authentication.BankId.Core/BankIdSimulatedEnvironmentOptions.cs b/src/ActiveLogin.Authentication.BankId.Core/BankIdSimulatedEnvironmentOptions.cs new file mode 100644 index 00000000..ea1cd85b --- /dev/null +++ b/src/ActiveLogin.Authentication.BankId.Core/BankIdSimulatedEnvironmentOptions.cs @@ -0,0 +1,14 @@ +using ActiveLogin.Authentication.BankId.Api; + +namespace ActiveLogin.Authentication.BankId.Core; + +/// +/// Configuration for the simulated BankID environment. +/// +public sealed class BankIdSimulatedEnvironmentOptions +{ + /// + /// The sequence of states returned by collect calls. + /// + public List CollectStates { get; set; } = BankIdSimulatedAppApiClient.NormalCollectStates; +} \ No newline at end of file diff --git a/src/ActiveLogin.Authentication.BankId.Core/IBankIdBuilderExtensions.cs b/src/ActiveLogin.Authentication.BankId.Core/IBankIdBuilderExtensions.cs index b1e5e93e..445d85ae 100644 --- a/src/ActiveLogin.Authentication.BankId.Core/IBankIdBuilderExtensions.cs +++ b/src/ActiveLogin.Authentication.BankId.Core/IBankIdBuilderExtensions.cs @@ -267,7 +267,33 @@ public static IBankIdBuilder UseProductionEnvironment(this IBankIdBuilder builde public static IBankIdBuilder UseSimulatedEnvironment(this IBankIdBuilder builder) { return UseSimulatedEnvironment(builder, - x => new BankIdSimulatedAppApiClient(), + x => new BankIdSimulatedAppApiClient(BankIdSimulatedAppApiClient.NormalCollectStates), + x => new BankIdSimulatedVerifyApiClient() + ); + } + + /// + /// Use simulated (in memory) environment. To be used for automated testing. + /// + /// + /// Configures the collect-state sequence. + /// + public static IBankIdBuilder UseSimulatedEnvironment(this IBankIdBuilder builder, Action configure) + { + if (configure == null) + { + throw new ArgumentNullException(nameof(configure)); + } + + var options = new BankIdSimulatedEnvironmentOptions(); + configure(options); + if (options.CollectStates == null || options.CollectStates.Count == 0) + { + throw new ArgumentException("At least one collect state must be configured.", nameof(configure)); + } + + return UseSimulatedEnvironment(builder, + x => new BankIdSimulatedAppApiClient(options.CollectStates), x => new BankIdSimulatedVerifyApiClient() ); } diff --git a/test/ActiveLogin.Authentication.BankId.Api.Test/BankIdSimulatedAppApiClient_Tests.cs b/test/ActiveLogin.Authentication.BankId.Api.Test/BankIdSimulatedAppApiClient_Tests.cs index d6d4bd88..ae47a18a 100644 --- a/test/ActiveLogin.Authentication.BankId.Api.Test/BankIdSimulatedAppApiClient_Tests.cs +++ b/test/ActiveLogin.Authentication.BankId.Api.Test/BankIdSimulatedAppApiClient_Tests.cs @@ -193,4 +193,49 @@ public async Task CancelAsync_CancelsTheCollectFlow() // Assert await Assert.ThrowsAsync(() => bankIdClient.CollectAsync(new CollectRequest(authResponse.OrderRef))); } + + [Fact] + public async Task CollectAsync_WithCustomCollectStates__ShouldReturnConfiguredStates() + { + // Arange + var states = new List + { + new(CollectStatus.Pending, CollectHintCode.NoClient), + new(CollectStatus.Complete, CollectHintCode.UserSign) + }; + var bankIdClient = new BankIdSimulatedAppApiClient(states) + { + Delay = TimeSpan.Zero + }; + + // Act + var authResponse = await bankIdClient.AuthAsync(new AuthRequest("1.1.1.1")); + var firstCollectResponse = await bankIdClient.CollectAsync(new CollectRequest(authResponse.OrderRef)); + var secondCollectResponse = await bankIdClient.CollectAsync(new CollectRequest(authResponse.OrderRef)); + + // Assert + Assert.Equal(CollectStatus.Pending, firstCollectResponse.GetCollectStatus()); + Assert.Equal(CollectHintCode.NoClient, firstCollectResponse.GetCollectHintCode()); + Assert.Equal(CollectStatus.Complete, secondCollectResponse.GetCollectStatus()); + Assert.Equal(CollectHintCode.UserSign, secondCollectResponse.GetCollectHintCode()); + } + + [Fact] + public async Task CollectAsync_WithFastCollectStates__ShouldCompleteAfterOnePendingState() + { + // Arange + var bankIdClient = new BankIdSimulatedAppApiClient(BankIdSimulatedAppApiClient.FastCollectStates) + { + Delay = TimeSpan.Zero + }; + + // Act + var authResponse = await bankIdClient.AuthAsync(new AuthRequest("1.1.1.1")); + var firstCollectResponse = await bankIdClient.CollectAsync(new CollectRequest(authResponse.OrderRef)); + var secondCollectResponse = await bankIdClient.CollectAsync(new CollectRequest(authResponse.OrderRef)); + + // Assert + Assert.Equal(CollectStatus.Pending, firstCollectResponse.GetCollectStatus()); + Assert.Equal(CollectStatus.Complete, secondCollectResponse.GetCollectStatus()); + } } diff --git a/test/ActiveLogin.Authentication.BankId.Core.Test/BankIdBuilder_Tests.cs b/test/ActiveLogin.Authentication.BankId.Core.Test/BankIdBuilder_Tests.cs index 3c80f0a6..87d82768 100644 --- a/test/ActiveLogin.Authentication.BankId.Core.Test/BankIdBuilder_Tests.cs +++ b/test/ActiveLogin.Authentication.BankId.Core.Test/BankIdBuilder_Tests.cs @@ -1,6 +1,9 @@ using System; +using System.Collections.Generic; +using System.Threading.Tasks; using ActiveLogin.Authentication.BankId.Api; +using ActiveLogin.Authentication.BankId.Api.Models; using Microsoft.Extensions.DependencyInjection; @@ -30,4 +33,29 @@ public void AddSimulatedApiErrors_Throws_If_No_IBankIdAppApiClient_Exists_In_Ser } + [Fact] + public async Task UseSimulatedEnvironment_WithOptions__RegistersConfiguredCollectStates() + { + var services = new ServiceCollection(); + var builder = new BankIdBuilder(services); + var states = new List + { + new(CollectStatus.Pending, CollectHintCode.NoClient), + new(CollectStatus.Complete, CollectHintCode.UserSign) + }; + + builder.UseSimulatedEnvironment(options => options.CollectStates = states); + + using var serviceProvider = services.BuildServiceProvider(); + var client = Assert.IsType(serviceProvider.GetRequiredService()); + client.Delay = TimeSpan.Zero; + var authResponse = await client.AuthAsync(new AuthRequest("1.1.1.1")); + var firstCollectResponse = await client.CollectAsync(new CollectRequest(authResponse.OrderRef)); + var secondCollectResponse = await client.CollectAsync(new CollectRequest(authResponse.OrderRef)); + + Assert.Equal(CollectStatus.Pending, firstCollectResponse.GetCollectStatus()); + Assert.Equal(CollectHintCode.NoClient, firstCollectResponse.GetCollectHintCode()); + Assert.Equal(CollectStatus.Complete, secondCollectResponse.GetCollectStatus()); + } + } From c80e379c51325b817dc6112808e397a2c205725f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Seld=C3=A9n?= Date: Wed, 19 Aug 2026 16:28:53 +0200 Subject: [PATCH 2/9] Update documentation --- docs/articles/bankid.md | 48 +++++++++++++++++++ .../README.md | 2 + 2 files changed, 50 insertions(+) diff --git a/docs/articles/bankid.md b/docs/articles/bankid.md index 7919c1ed..0130e5ab 100644 --- a/docs/articles/bankid.md +++ b/docs/articles/bankid.md @@ -210,6 +210,54 @@ services ``` +### Simulated environment with custom collect states + +The simulated environment uses a normal collect flow by default. For automated tests, a faster flow can be selected. The `FastCollectStates` sequence contains only the states needed to reach a successful result. + +```csharp +services + .AddBankId(bankId => + { + bankId.UseSimulatedEnvironment(options => + { + options.CollectStates = BankIdSimulatedAppApiClient.FastCollectStates; + }); + }); +``` + +The `AllCollectStates` sequence can be used to verify that the UI handles the different successful collect hint codes and text lengths. + +```csharp +services + .AddBankId(bankId => + { + bankId.UseSimulatedEnvironment(options => + { + options.CollectStates = BankIdSimulatedAppApiClient.AllCollectStates; + }); + }); +``` + +For a specialized test, provide your own sequence. The final state should have `CollectStatus.Complete` so that the simulated authentication can finish successfully. + +```csharp +services + .AddBankId(bankId => + { + bankId.UseSimulatedEnvironment(options => + { + options.CollectStates = new List + { + new(CollectStatus.Pending, CollectHintCode.Started), + new(CollectStatus.Complete, CollectHintCode.UserSign) + }; + }); + }); +``` + +These examples require the `ActiveLogin.Authentication.BankId.Api` and `ActiveLogin.Authentication.BankId.Core` namespaces. The simulated client also applies a response delay to mimic the real flow. Set `Delay` on the resolved `BankIdSimulatedAppApiClient` when a test needs to remove that delay completely. + + ### Test environment This will use the real REST API for BankID, connecting to the Test environment. diff --git a/src/ActiveLogin.Authentication.BankId.AspNetCore/README.md b/src/ActiveLogin.Authentication.BankId.AspNetCore/README.md index 3ebaa71e..c9becee8 100644 --- a/src/ActiveLogin.Authentication.BankId.AspNetCore/README.md +++ b/src/ActiveLogin.Authentication.BankId.AspNetCore/README.md @@ -26,6 +26,8 @@ services }); ``` +For faster automated tests, configure the simulated environment with `BankIdSimulatedAppApiClient.FastCollectStates`. See the [simulated environment documentation](../../docs/articles/bankid.md) for custom collect-state examples. + ### Production ```csharp From 17947bd631012d46cbba937134ae0eb149ba3da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Seld=C3=A9n?= Date: Thu, 20 Aug 2026 10:51:00 +0200 Subject: [PATCH 3/9] Clarify collection states and handle edge cases --- .../BankIdSimulatedAppApiClient.cs | 9 +++++-- .../IBankIdBuilderExtensions.cs | 4 +++- .../BankIdSimulatedAppApiClient_Tests.cs | 24 +++++++++++++++++++ .../BankIdBuilder_Tests.cs | 1 + 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/ActiveLogin.Authentication.BankId.Api/BankIdSimulatedAppApiClient.cs b/src/ActiveLogin.Authentication.BankId.Api/BankIdSimulatedAppApiClient.cs index 617a3d11..65534193 100644 --- a/src/ActiveLogin.Authentication.BankId.Api/BankIdSimulatedAppApiClient.cs +++ b/src/ActiveLogin.Authentication.BankId.Api/BankIdSimulatedAppApiClient.cs @@ -43,7 +43,7 @@ public class BankIdSimulatedAppApiClient : IBankIdAppApiClient /// /// Gets a new collect-state sequence that covers the UI-relevant successful hint codes. /// - public static List AllCollectStates => new() + public static List AllSuccessfulCollectStates => new() { new CollectState(CollectStatus.Pending, CollectHintCode.OutstandingTransaction), new CollectState(CollectStatus.Pending, CollectHintCode.NoClient), @@ -97,13 +97,18 @@ public BankIdSimulatedAppApiClient(string givenName, string surname, string name public BankIdSimulatedAppApiClient(string givenName, string surname, string name, string personalIdentityNumber, string bankIdIssueDate, string uniqueHardwareId, List collectStates) { + if (collectStates == null || collectStates.Count == 0) + { + throw new ArgumentException("At least one collect state must be configured.", nameof(collectStates)); + } + _givenName = givenName; _surname = surname; _name = name; _personalIdentityNumber = personalIdentityNumber; _bankIdIssueDate = bankIdIssueDate; _uniqueHardwareId = uniqueHardwareId; - _collectStates = collectStates; + _collectStates = new List(collectStates); } public TimeSpan Delay diff --git a/src/ActiveLogin.Authentication.BankId.Core/IBankIdBuilderExtensions.cs b/src/ActiveLogin.Authentication.BankId.Core/IBankIdBuilderExtensions.cs index 445d85ae..ad4211e1 100644 --- a/src/ActiveLogin.Authentication.BankId.Core/IBankIdBuilderExtensions.cs +++ b/src/ActiveLogin.Authentication.BankId.Core/IBankIdBuilderExtensions.cs @@ -292,8 +292,10 @@ public static IBankIdBuilder UseSimulatedEnvironment(this IBankIdBuilder builder throw new ArgumentException("At least one collect state must be configured.", nameof(configure)); } + var collectStates = new List(options.CollectStates); + return UseSimulatedEnvironment(builder, - x => new BankIdSimulatedAppApiClient(options.CollectStates), + x => new BankIdSimulatedAppApiClient(collectStates), x => new BankIdSimulatedVerifyApiClient() ); } diff --git a/test/ActiveLogin.Authentication.BankId.Api.Test/BankIdSimulatedAppApiClient_Tests.cs b/test/ActiveLogin.Authentication.BankId.Api.Test/BankIdSimulatedAppApiClient_Tests.cs index ae47a18a..c0154817 100644 --- a/test/ActiveLogin.Authentication.BankId.Api.Test/BankIdSimulatedAppApiClient_Tests.cs +++ b/test/ActiveLogin.Authentication.BankId.Api.Test/BankIdSimulatedAppApiClient_Tests.cs @@ -238,4 +238,28 @@ public async Task CollectAsync_WithFastCollectStates__ShouldCompleteAfterOnePend Assert.Equal(CollectStatus.Pending, firstCollectResponse.GetCollectStatus()); Assert.Equal(CollectStatus.Complete, secondCollectResponse.GetCollectStatus()); } + + [Fact] + public async Task CollectAsync_WithCustomCollectStates__ShouldNotBeAffectedByChangesToOriginalList() + { + // Arange + var states = new List + { + new(CollectStatus.Pending, CollectHintCode.NoClient), + new(CollectStatus.Complete, CollectHintCode.UserSign) + }; + var bankIdClient = new BankIdSimulatedAppApiClient(states) + { + Delay = TimeSpan.Zero + }; + states.Clear(); + + // Act + var authResponse = await bankIdClient.AuthAsync(new AuthRequest("1.1.1.1")); + var collectResponse = await bankIdClient.CollectAsync(new CollectRequest(authResponse.OrderRef)); + + // Assert + Assert.Equal(CollectStatus.Pending, collectResponse.GetCollectStatus()); + Assert.Equal(CollectHintCode.NoClient, collectResponse.GetCollectHintCode()); + } } diff --git a/test/ActiveLogin.Authentication.BankId.Core.Test/BankIdBuilder_Tests.cs b/test/ActiveLogin.Authentication.BankId.Core.Test/BankIdBuilder_Tests.cs index 87d82768..632bce45 100644 --- a/test/ActiveLogin.Authentication.BankId.Core.Test/BankIdBuilder_Tests.cs +++ b/test/ActiveLogin.Authentication.BankId.Core.Test/BankIdBuilder_Tests.cs @@ -45,6 +45,7 @@ public async Task UseSimulatedEnvironment_WithOptions__RegistersConfiguredCollec }; builder.UseSimulatedEnvironment(options => options.CollectStates = states); + states.Clear(); using var serviceProvider = services.BuildServiceProvider(); var client = Assert.IsType(serviceProvider.GetRequiredService()); From 265a014931f984ead6d643618a098b889541e352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Seld=C3=A9n?= Date: Thu, 20 Aug 2026 10:51:15 +0200 Subject: [PATCH 4/9] Update docs --- docs/articles/bankid.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/articles/bankid.md b/docs/articles/bankid.md index 0130e5ab..043c4801 100644 --- a/docs/articles/bankid.md +++ b/docs/articles/bankid.md @@ -225,7 +225,7 @@ services }); ``` -The `AllCollectStates` sequence can be used to verify that the UI handles the different successful collect hint codes and text lengths. +The `AllSuccessfulCollectStates` sequence can be used to verify that the UI handles the different successful collect hint codes and text lengths. It intentionally does not include failed terminal states, so the simulated authentication can complete successfully. ```csharp services @@ -233,7 +233,7 @@ services { bankId.UseSimulatedEnvironment(options => { - options.CollectStates = BankIdSimulatedAppApiClient.AllCollectStates; + options.CollectStates = BankIdSimulatedAppApiClient.AllSuccessfulCollectStates; }); }); ``` @@ -255,7 +255,7 @@ services }); ``` -These examples require the `ActiveLogin.Authentication.BankId.Api` and `ActiveLogin.Authentication.BankId.Core` namespaces. The simulated client also applies a response delay to mimic the real flow. Set `Delay` on the resolved `BankIdSimulatedAppApiClient` when a test needs to remove that delay completely. +These examples require the `ActiveLogin.Authentication.BankId.Api` and `ActiveLogin.Authentication.BankId.Core` namespaces. The simulated client also applies a response delay to mimic the real flow. Delay is not configured by `UseSimulatedEnvironment`; if a test needs to remove it, resolve the registered `BankIdSimulatedAppApiClient` from dependency injection and set its `Delay` property to `TimeSpan.Zero`. ### Test environment From d1f1b7267fc2d0840750ff9a493d0fc8efbd4ec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Seld=C3=A9n?= Date: Thu, 20 Aug 2026 15:47:41 +0200 Subject: [PATCH 5/9] fix-copilot-pr-comments --- .../BankIdSimulatedAppApiClient.cs | 7 ++++++- .../BankIdSimulatedAppApiClient_Tests.cs | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ActiveLogin.Authentication.BankId.Api/BankIdSimulatedAppApiClient.cs b/src/ActiveLogin.Authentication.BankId.Api/BankIdSimulatedAppApiClient.cs index 65534193..fdcbd624 100644 --- a/src/ActiveLogin.Authentication.BankId.Api/BankIdSimulatedAppApiClient.cs +++ b/src/ActiveLogin.Authentication.BankId.Api/BankIdSimulatedAppApiClient.cs @@ -97,7 +97,12 @@ public BankIdSimulatedAppApiClient(string givenName, string surname, string name public BankIdSimulatedAppApiClient(string givenName, string surname, string name, string personalIdentityNumber, string bankIdIssueDate, string uniqueHardwareId, List collectStates) { - if (collectStates == null || collectStates.Count == 0) + if (collectStates == null) + { + throw new ArgumentNullException(nameof(collectStates)); + } + + if (collectStates.Count == 0) { throw new ArgumentException("At least one collect state must be configured.", nameof(collectStates)); } diff --git a/test/ActiveLogin.Authentication.BankId.Api.Test/BankIdSimulatedAppApiClient_Tests.cs b/test/ActiveLogin.Authentication.BankId.Api.Test/BankIdSimulatedAppApiClient_Tests.cs index c0154817..d5145f2b 100644 --- a/test/ActiveLogin.Authentication.BankId.Api.Test/BankIdSimulatedAppApiClient_Tests.cs +++ b/test/ActiveLogin.Authentication.BankId.Api.Test/BankIdSimulatedAppApiClient_Tests.cs @@ -262,4 +262,16 @@ public async Task CollectAsync_WithCustomCollectStates__ShouldNotBeAffectedByCha Assert.Equal(CollectStatus.Pending, collectResponse.GetCollectStatus()); Assert.Equal(CollectHintCode.NoClient, collectResponse.GetCollectHintCode()); } + + [Fact] + public void Constructor_WithNullCollectStates__ShouldThrowArgumentNullException() + { + Assert.Throws(() => new BankIdSimulatedAppApiClient(null!)); + } + + [Fact] + public void Constructor_WithEmptyCollectStates__ShouldThrowArgumentException() + { + Assert.Throws(() => new BankIdSimulatedAppApiClient(new List())); + } } From a81050c2ae0f0a7d6b8a749f558c9769e0a5eae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Seld=C3=A9n?= Date: Fri, 21 Aug 2026 09:00:22 +0200 Subject: [PATCH 6/9] simplify documentation of custom collect states --- docs/articles/bankid.md | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/docs/articles/bankid.md b/docs/articles/bankid.md index 043c4801..b0328a82 100644 --- a/docs/articles/bankid.md +++ b/docs/articles/bankid.md @@ -225,18 +225,7 @@ services }); ``` -The `AllSuccessfulCollectStates` sequence can be used to verify that the UI handles the different successful collect hint codes and text lengths. It intentionally does not include failed terminal states, so the simulated authentication can complete successfully. - -```csharp -services - .AddBankId(bankId => - { - bankId.UseSimulatedEnvironment(options => - { - options.CollectStates = BankIdSimulatedAppApiClient.AllSuccessfulCollectStates; - }); - }); -``` +The `AllSuccessfulCollectStates` sequence can be used to verify that the UI handles the different successful collect hint codes and text lengths. It intentionally does not include failed terminal states, so the simulated authentication can complete successfully. Set it with `options.CollectStates = BankIdSimulatedAppApiClient.AllSuccessfulCollectStates;`. For a specialized test, provide your own sequence. The final state should have `CollectStatus.Complete` so that the simulated authentication can finish successfully. From feb71df995ffd861e6ff8a2b74582df0810af33e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Seld=C3=A9n?= Date: Fri, 21 Aug 2026 09:00:39 +0200 Subject: [PATCH 7/9] remove redundant validation --- .../IBankIdBuilderExtensions.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/ActiveLogin.Authentication.BankId.Core/IBankIdBuilderExtensions.cs b/src/ActiveLogin.Authentication.BankId.Core/IBankIdBuilderExtensions.cs index ad4211e1..edd131f3 100644 --- a/src/ActiveLogin.Authentication.BankId.Core/IBankIdBuilderExtensions.cs +++ b/src/ActiveLogin.Authentication.BankId.Core/IBankIdBuilderExtensions.cs @@ -287,10 +287,6 @@ public static IBankIdBuilder UseSimulatedEnvironment(this IBankIdBuilder builder var options = new BankIdSimulatedEnvironmentOptions(); configure(options); - if (options.CollectStates == null || options.CollectStates.Count == 0) - { - throw new ArgumentException("At least one collect state must be configured.", nameof(configure)); - } var collectStates = new List(options.CollectStates); From a6c0c23098e24e299f8c0bdcbde93f9e8770940c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Seld=C3=A9n?= Date: Fri, 21 Aug 2026 12:12:38 +0200 Subject: [PATCH 8/9] Removed builder-level defensive copy --- .../IBankIdBuilderExtensions.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/ActiveLogin.Authentication.BankId.Core/IBankIdBuilderExtensions.cs b/src/ActiveLogin.Authentication.BankId.Core/IBankIdBuilderExtensions.cs index edd131f3..16ca7207 100644 --- a/src/ActiveLogin.Authentication.BankId.Core/IBankIdBuilderExtensions.cs +++ b/src/ActiveLogin.Authentication.BankId.Core/IBankIdBuilderExtensions.cs @@ -288,10 +288,8 @@ public static IBankIdBuilder UseSimulatedEnvironment(this IBankIdBuilder builder var options = new BankIdSimulatedEnvironmentOptions(); configure(options); - var collectStates = new List(options.CollectStates); - return UseSimulatedEnvironment(builder, - x => new BankIdSimulatedAppApiClient(collectStates), + x => new BankIdSimulatedAppApiClient(options.CollectStates), x => new BankIdSimulatedVerifyApiClient() ); } From 402cf3b70684f88429fd16a5eb804c4a887ec0be Mon Sep 17 00:00:00 2001 From: Elin Fokine Date: Thu, 27 Aug 2026 17:10:31 +0200 Subject: [PATCH 9/9] Fix failing test. --- .../BankIdBuilder_Tests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/test/ActiveLogin.Authentication.BankId.Core.Test/BankIdBuilder_Tests.cs b/test/ActiveLogin.Authentication.BankId.Core.Test/BankIdBuilder_Tests.cs index 632bce45..87d82768 100644 --- a/test/ActiveLogin.Authentication.BankId.Core.Test/BankIdBuilder_Tests.cs +++ b/test/ActiveLogin.Authentication.BankId.Core.Test/BankIdBuilder_Tests.cs @@ -45,7 +45,6 @@ public async Task UseSimulatedEnvironment_WithOptions__RegistersConfiguredCollec }; builder.UseSimulatedEnvironment(options => options.CollectStates = states); - states.Clear(); using var serviceProvider = services.BuildServiceProvider(); var client = Assert.IsType(serviceProvider.GetRequiredService());