public async Task LinkAccountValidRequestShowsConfirmationPage( int delegateId, int learningHubAuthId, string expectedContent ) { // Given using var scope = _factory.Services.CreateScope(); var learningHubSecurityService = scope.ServiceProvider.GetRequiredService <ILearningHubSsoSecurityService>(); var userDataService = scope.ServiceProvider.GetRequiredService <IUserDataService>(); var testUserData = TestUserDataService.GetDelegate(delegateId); var userIdHash = learningHubSecurityService.GenerateHash(learningHubAuthId.ToString()); var state = $"{testUserData.SessionData[LinkLearningHubRequest.SessionIdentifierKey]}_refId:12345"; var client = await HttpClientHelper.SetDelegateSessionAndGetClient(_factory, delegateId); // When var response = await client.GetAsync( $"/Signposting/LinkLearningHubSso?State={state}&Hash={WebUtility.UrlEncode(userIdHash)}&UserId={learningHubAuthId}" ); // Then using (new AssertionScope()) { response.EnsureSuccessStatusCode(); var responseContent = await response.Content.ReadAsStringAsync(); responseContent.Should().Contain(expectedContent); userDataService.GetDelegateUserLearningHubAuthId(delegateId).Should().NotBeNull(); } }
protected override void ConfigureWebHost(IWebHostBuilder builder) { builder .UseEnvironment("SIT") .ConfigureServices( services => { // Filter: AutoValidateAntiforgeryTokenAttribute // * This globally forces anti-forgery validation in tests. // * Additional setup would be required to pass this validation. // * This filter has been removed, as per below, for testing // so as to remove the anti-forgery requirements. services.Configure <MvcOptions>( o => { o.Filters.Remove(new AutoValidateAntiforgeryTokenAttribute()); } ); services.AddTransient <IStartupFilter, TestUserAppStartupFilter>(); var userDataServiceDescriptor = services.SingleOrDefault( d => d.ServiceType == typeof(IUserDataService) ); services.Remove(userDataServiceDescriptor); services.AddScoped(x => TestUserDataService.FakeUserDataService()); } ); }
public ExtendExpeditionCommandTests() { Celestial celestial = Build.A.Celestial.ThatHasNotBeenScanned(); _starSystems = Build.A.StarSystem.WithCelestial(celestial).InAList(); _userDataService = new TestUserDataService(_starSystems); _navigator = CreateNavigator(new MemoryDataStore <StarSystemDocument>()); _communicator = CreateCommunicator(); _sut = new ExtendExpeditionCommand(_communicator, _navigator, _userDataService, BuildPhrases()); }
public JumpCommandTests() { Celestial celestial = Build.A.Celestial.ThatHasNotBeenScanned(); Celestial celestial2 = Build.A.Celestial.ThatHasNotBeenScanned(); _starSystems = Build.A.StarSystem.WithCelestials(celestial, celestial, celestial2).InAList(); _userDataService = new TestUserDataService(_starSystems); _navigator = CreateNavigator(new MemoryDataStore <StarSystemDocument>()); _communicator = CreateCommunicator(); }
public PlanExpeditionCommandTests() { PlayerStatusRepository playerStatus = CreatePlayerStatusRepository(); Celestial celestial = Build.A.Celestial.ThatHasNotBeenScanned(); _starSystems = Build.A.StarSystem.WithCelestial(celestial).InAList(); _userDataService = new TestUserDataService(_starSystems); _navigator = CreateNavigator(new MemoryDataStore <StarSystemDocument>()); _communicator = CreateCommunicator(); _sut = new PlanExpeditionCommand(_communicator, _navigator, _userDataService, playerStatus, BuildPhrases(), new CelestialValues(), new DetourPlanner(_navigator, null, playerStatus, null));; }