Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: split app-scopes endpoint into, status, login and app-scopes #14075

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
da60ad5
Resuable storage interface
framitdavid Oct 25, 2024
03ad004
moved the reusable scoped storage to pure-funciton
framitdavid Oct 25, 2024
13a3d2a
spelling
framitdavid Oct 25, 2024
e2c8b73
added missing method
framitdavid Oct 25, 2024
50fd70d
syntax
framitdavid Oct 25, 2024
8ca15da
added more precise return type
framitdavid Oct 25, 2024
d64d4cf
typecheck
framitdavid Oct 25, 2024
1893117
eslint
framitdavid Oct 25, 2024
d1994ee
added assertion
framitdavid Oct 25, 2024
7c50e30
moved test section to be more readable
framitdavid Oct 25, 2024
6b30edb
Merge branch 'main' of https://github.com/Altinn/altinn-studio
framitdavid Oct 29, 2024
b29b699
Merge branch 'main' of https://github.com/Altinn/altinn-studio
framitdavid Oct 29, 2024
69cb859
Merge branch 'main' of https://github.com/Altinn/altinn-studio
framitdavid Oct 29, 2024
1b48c15
Merge branch 'main' of https://github.com/Altinn/altinn-studio
framitdavid Oct 30, 2024
91d17ec
Merge branch 'main' of https://github.com/Altinn/altinn-studio
framitdavid Nov 4, 2024
4e38a26
Merge branch 'main' of https://github.com/Altinn/altinn-studio
framitdavid Nov 4, 2024
64de22b
Merge branch 'main' of https://github.com/Altinn/altinn-studio
framitdavid Nov 5, 2024
327b25b
Merge branch 'main' of https://github.com/Altinn/altinn-studio
framitdavid Nov 5, 2024
5926dfe
Merge branch 'main' of https://github.com/Altinn/altinn-studio
framitdavid Nov 5, 2024
210f60b
feat(settings): make it possible to open settings modal based on quer…
framitdavid Nov 6, 2024
7a5266c
fixes
framitdavid Nov 6, 2024
1424bb6
improved test description
framitdavid Nov 6, 2024
212d80d
Merge branch 'main' into feat/openSettingsModalBasedOnQueryParam
framitdavid Nov 6, 2024
b9a0731
PR-feedback + improve unit-tests
framitdavid Nov 6, 2024
d3026e9
Merge branch 'feat/openSettingsModalBasedOnQueryParam' of https://git…
framitdavid Nov 6, 2024
7dd7f68
feat: context based login with ansattporten
framitdavid Nov 8, 2024
07a6170
feat: context based login with ansattporten
framitdavid Nov 8, 2024
6dbee28
Merge branch '11-08-feat_context_based_login_with_ansattporten' of ht…
framitdavid Nov 8, 2024
4debfca
Merge branch 'main' of https://github.com/Altinn/altinn-studio
framitdavid Nov 11, 2024
facf0cc
frontend with mocks for maskinporten
framitdavid Nov 12, 2024
c0738ee
Update frontend/app-development/layout/PageHeader/SubHeader/SettingsM…
framitdavid Nov 14, 2024
ab15897
PR feedback
framitdavid Nov 14, 2024
34520cd
feat(settings): make it possible to open settings modal based on quer…
framitdavid Nov 6, 2024
c7a1be1
fixes
framitdavid Nov 6, 2024
f8bbc47
improved test description
framitdavid Nov 6, 2024
2813666
PR-feedback + improve unit-tests
framitdavid Nov 6, 2024
1fcb0bb
feat: context based login with ansattporten
framitdavid Nov 8, 2024
1348b92
feat: context based login with ansattporten
framitdavid Nov 8, 2024
2e8bb93
frontend with mocks for maskinporten
framitdavid Nov 12, 2024
54b3aea
Update frontend/app-development/layout/PageHeader/SubHeader/SettingsM…
framitdavid Nov 14, 2024
1d09526
PR feedback
framitdavid Nov 14, 2024
274644c
Merge branch '11-08-feat_context_based_login_with_ansattporten' of ht…
framitdavid Nov 14, 2024
98f4edf
Merge branch 'main' of https://github.com/Altinn/altinn-studio
framitdavid Nov 14, 2024
3b12f25
hide maskinporten behind featureflag
framitdavid Nov 14, 2024
46477c0
Merge branch 'main' of https://github.com/Altinn/altinn-studio
framitdavid Nov 14, 2024
45da4e6
merge main into feature
framitdavid Nov 14, 2024
dcad4b6
eslint
framitdavid Nov 14, 2024
97b4a8f
fixed issue after merge
framitdavid Nov 14, 2024
41381f1
feat(settings): make it possible to open settings modal based on quer…
framitdavid Nov 6, 2024
2b024b6
fixes
framitdavid Nov 6, 2024
a8e855f
improved test description
framitdavid Nov 6, 2024
1521f6e
PR-feedback + improve unit-tests
framitdavid Nov 6, 2024
c5d41f0
feat: context based login with ansattporten
framitdavid Nov 8, 2024
1f588e1
feat: context based login with ansattporten
framitdavid Nov 8, 2024
b328101
frontend with mocks for maskinporten
framitdavid Nov 12, 2024
e27c80a
Update frontend/app-development/layout/PageHeader/SubHeader/SettingsM…
framitdavid Nov 14, 2024
a032f45
PR feedback
framitdavid Nov 14, 2024
c3dcc35
fixes
framitdavid Nov 6, 2024
8e5f2dd
feat: context based login with ansattporten
framitdavid Nov 8, 2024
0ed1716
frontend with mocks for maskinporten
framitdavid Nov 12, 2024
b99c16b
hide maskinporten behind featureflag
framitdavid Nov 14, 2024
8ad8415
chore: scale designer in dev and staging (#14039)
mirkoSekulic Nov 12, 2024
933a5b7
feat: 2 replicas in prod/staging, 1 in dev (#14047)
mirkoSekulic Nov 13, 2024
ba7dc3b
eslint
framitdavid Nov 14, 2024
96062f6
fixed issue after merge
framitdavid Nov 14, 2024
8ff4a2b
Merge branch '11-08-feat_context_based_login_with_ansattporten' of ht…
framitdavid Nov 14, 2024
cdae4a6
feat: split app-scopes endpoint into, status, login and app-scopes
framitdavid Nov 14, 2024
ce5f840
AnsattPorten controller
mirkoSekulic Nov 19, 2024
383c4b2
rename redirect to param
mirkoSekulic Nov 19, 2024
7253c5d
Add tests for Ansattporten controller
mirkoSekulic Nov 19, 2024
ee5dfc4
Resuable storage interface
framitdavid Oct 25, 2024
8ec2c02
moved the reusable scoped storage to pure-funciton
framitdavid Oct 25, 2024
271b722
feat: context based login with ansattporten
framitdavid Nov 8, 2024
6850d92
feat: context based login with ansattporten
framitdavid Nov 8, 2024
65c6246
frontend with mocks for maskinporten
framitdavid Nov 12, 2024
2b6a2f6
Update frontend/app-development/layout/PageHeader/SubHeader/SettingsM…
framitdavid Nov 14, 2024
40e5436
PR feedback
framitdavid Nov 14, 2024
fcebffa
fixes
framitdavid Nov 6, 2024
45e5f43
feat: context based login with ansattporten
framitdavid Nov 8, 2024
7e3c420
frontend with mocks for maskinporten
framitdavid Nov 12, 2024
5596aa0
hide maskinporten behind featureflag
framitdavid Nov 14, 2024
e7ab276
chore: scale designer in dev and staging (#14039)
mirkoSekulic Nov 12, 2024
aafdaf3
feat: 2 replicas in prod/staging, 1 in dev (#14047)
mirkoSekulic Nov 13, 2024
e5b8e02
eslint
framitdavid Nov 14, 2024
685e8fc
fixed issue after merge
framitdavid Nov 14, 2024
486eb78
fixes
framitdavid Nov 6, 2024
b01d727
feat: context based login with ansattporten
framitdavid Nov 8, 2024
91c4109
frontend with mocks for maskinporten
framitdavid Nov 12, 2024
7a476b6
feat(settings): make it possible to open settings modal based on quer…
framitdavid Nov 6, 2024
604d834
fixes
framitdavid Nov 6, 2024
961e127
PR-feedback + improve unit-tests
framitdavid Nov 6, 2024
db14f33
feat: context based login with ansattporten
framitdavid Nov 8, 2024
f7987a3
frontend with mocks for maskinporten
framitdavid Nov 12, 2024
302cfd0
Resuable storage interface
framitdavid Oct 25, 2024
dd6df57
moved the reusable scoped storage to pure-funciton
framitdavid Oct 25, 2024
7e530a7
feat(settings): make it possible to open settings modal based on quer…
framitdavid Nov 6, 2024
5ab5a7a
fixes
framitdavid Nov 6, 2024
c4f78ea
PR-feedback + improve unit-tests
framitdavid Nov 6, 2024
a050c19
feat: context based login with ansattporten
framitdavid Nov 8, 2024
a71322d
frontend with mocks for maskinporten
framitdavid Nov 12, 2024
4151365
fixes
framitdavid Nov 6, 2024
16cd0d3
feat: context based login with ansattporten
framitdavid Nov 8, 2024
58c632d
frontend with mocks for maskinporten
framitdavid Nov 12, 2024
9c38238
hide maskinporten behind featureflag
framitdavid Nov 14, 2024
d67cc48
chore: scale designer in dev and staging (#14039)
mirkoSekulic Nov 12, 2024
8efd6e6
feat: 2 replicas in prod/staging, 1 in dev (#14047)
mirkoSekulic Nov 13, 2024
8f99411
eslint
framitdavid Nov 14, 2024
cd71378
fixes
framitdavid Nov 6, 2024
ed6e6f0
feat: context based login with ansattporten
framitdavid Nov 8, 2024
fdea28c
frontend with mocks for maskinporten
framitdavid Nov 12, 2024
0e3c585
fixes
framitdavid Nov 6, 2024
5366666
feat: context based login with ansattporten
framitdavid Nov 8, 2024
609f1fe
frontend with mocks for maskinporten
framitdavid Nov 12, 2024
cda9b91
AnsattPorten controller
mirkoSekulic Nov 19, 2024
3dcbd84
rename redirect to param
mirkoSekulic Nov 19, 2024
c42611c
Resuable storage interface
framitdavid Oct 25, 2024
d587052
moved the reusable scoped storage to pure-funciton
framitdavid Oct 25, 2024
7a9f735
fixes
framitdavid Nov 6, 2024
5096c7c
feat: context based login with ansattporten
framitdavid Nov 8, 2024
4fc11db
frontend with mocks for maskinporten
framitdavid Nov 12, 2024
da34694
Update frontend/app-development/layout/PageHeader/SubHeader/SettingsM…
framitdavid Nov 14, 2024
95630ea
PR feedback
framitdavid Nov 14, 2024
1bed951
fixes
framitdavid Nov 6, 2024
6584186
feat: context based login with ansattporten
framitdavid Nov 8, 2024
6a717db
frontend with mocks for maskinporten
framitdavid Nov 12, 2024
4aada2b
hide maskinporten behind featureflag
framitdavid Nov 14, 2024
1e1f257
chore: scale designer in dev and staging (#14039)
mirkoSekulic Nov 12, 2024
e2eddbd
feat: 2 replicas in prod/staging, 1 in dev (#14047)
mirkoSekulic Nov 13, 2024
f87227b
fixed issue after merge
framitdavid Nov 14, 2024
d3dc317
feat(settings): make it possible to open settings modal based on quer…
framitdavid Nov 6, 2024
f21756c
fixes
framitdavid Nov 6, 2024
fa8a401
PR-feedback + improve unit-tests
framitdavid Nov 6, 2024
5b8e333
feat: context based login with ansattporten
framitdavid Nov 8, 2024
37a71da
frontend with mocks for maskinporten
framitdavid Nov 12, 2024
093a257
PR feedback
framitdavid Nov 14, 2024
4b4a273
fixes
framitdavid Nov 6, 2024
53c0119
PR-feedback + improve unit-tests
framitdavid Nov 6, 2024
93c3284
feat: context based login with ansattporten
framitdavid Nov 8, 2024
9c92935
frontend with mocks for maskinporten
framitdavid Nov 12, 2024
6d74368
merge main into feature
framitdavid Nov 21, 2024
866240e
merge main into feature
framitdavid Nov 21, 2024
bafa65f
added login with maskinporten
framitdavid Nov 21, 2024
fffd866
fix redirection from AP to endpoints with default auth scheme
mirkoSekulic Nov 21, 2024
07c0e0c
set feature flag som true in dev
mirkoSekulic Nov 25, 2024
134aedf
merge main into feature
framitdavid Nov 25, 2024
a34889a
Merge branch '11-14-feat_split_app-scopes_endpoint_into_status_login_…
framitdavid Nov 25, 2024
f8f3c38
Fixed unit-test
framitdavid Nov 25, 2024
b9d8a25
Merge branch 'main' into 11-14-feat_split_app-scopes_endpoint_into_st…
framitdavid Nov 25, 2024
a7dd8d1
remove authdelegating handler for AP tests
mirkoSekulic Nov 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions backend/src/Designer/Controllers/AnsattPortenController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System.Threading.Tasks;
using Altinn.Studio.Designer.Constants;
using Altinn.Studio.Designer.Models.Dto;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.FeatureManagement.Mvc;

namespace Altinn.Studio.Designer.Controllers;

[FeatureGate(StudioFeatureFlags.AnsattPorten)]
[Route("designer/api/[controller]")]
[ApiController]
public class AnsattPortenController : ControllerBase
{
[Authorize(AnsattPortenConstants.AnsattportenAuthorizationPolicy)]
[HttpGet("login")]
public async Task<IActionResult> Login([FromQuery(Name = "redirect_to")] string redirectTo)
{
await Task.CompletedTask;
if (!Url.IsLocalUrl(redirectTo))
{
return Forbid();
}

return LocalRedirect(redirectTo);
}

[AllowAnonymous]
[HttpGet("auth-status")]
public async Task<IActionResult> AuthStatus()
{
await Task.CompletedTask;
var authenticateResult =
await HttpContext.AuthenticateAsync(AnsattPortenConstants.AnsattportenAuthenticationScheme);

var authStatus = new AuthStatus
{
IsLoggedIn = authenticateResult.Succeeded
};

return Ok(authStatus);
}

}
8 changes: 2 additions & 6 deletions backend/src/Designer/Controllers/AppScopesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace Altinn.Studio.Designer.Controllers;
[ApiController]
[FeatureGate(StudioFeatureFlags.AnsattPorten)]
[Route("designer/api/{org}/{app:regex(^(?!datamodels$)[[a-z]][[a-z0-9-]]{{1,28}}[[a-z0-9]]$)}/app-scopes")]

public class AppScopesController(IMaskinPortenHttpClient maskinPortenHttpClient,
IAppScopesService appScopesService) : ControllerBase
{
Expand All @@ -28,7 +27,7 @@ public async Task<IActionResult> GetScopesFromMaskinPorten(string org, string ap
{
var scopes = await maskinPortenHttpClient.GetAvailableScopes(cancellationToken);

var reponse = new AppScopesResponse()
var response = new AppScopesResponse()
{
Scopes = scopes.Select(x => new MaskinPortenScopeDto()
{
Expand All @@ -37,10 +36,9 @@ public async Task<IActionResult> GetScopesFromMaskinPorten(string org, string ap
}).ToHashSet()
};

return Ok(reponse);
return Ok(response);
}


[Authorize]
[HttpPut]
public async Task UpsertAppScopes(string org, string app, [FromBody] AppScopesUpsertRequest appScopesUpsertRequest,
Expand All @@ -56,7 +54,6 @@ public async Task UpsertAppScopes(string org, string app, [FromBody] AppScopesUp
await appScopesService.UpsertScopesAsync(AltinnRepoEditingContext.FromOrgRepoDeveloper(org, app, developer), scopes, cancellationToken);
}


[Authorize]
[HttpGet]
public async Task<IActionResult> GetAppScopes(string org, string app, CancellationToken cancellationToken)
Expand All @@ -74,5 +71,4 @@ public async Task<IActionResult> GetAppScopes(string org, string app, Cancellati

return Ok(reponse);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ private static IServiceCollection AddAnsattPortenAuthentication(this IServiceCol
options.Events.OnRedirectToIdentityProvider = context =>
{

if (!context.Request.Path.StartsWithSegments("/designer/api") ||
!context.Request.Path.Value!.Contains("/maskinporten"))
if (!context.Request.Path.StartsWithSegments("/designer/api/ansattporten/login"))
{
context.Response.StatusCode = StatusCodes.Status401Unauthorized;
context.HandleResponse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Linq;
using System.Threading.Tasks;
using Altinn.Studio.Designer.Configuration;
using Altinn.Studio.Designer.Constants;
using Altinn.Studio.Designer.Helpers;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
Expand Down Expand Up @@ -38,6 +39,7 @@ private static IServiceCollection AddGiteaOidcAuthentication(this IServiceCollec
IConfiguration configuration, IWebHostEnvironment env)
{
var oidcSettings = FetchOidcSettingsFromConfiguration(configuration, env);
bool ansattPortenFeatureFlag = configuration.GetSection($"FeatureManagement:{StudioFeatureFlags.AnsattPorten}").Get<bool>();

services
.AddAuthentication(options =>
Expand All @@ -49,7 +51,8 @@ private static IServiceCollection AddGiteaOidcAuthentication(this IServiceCollec
{
options.Cookie.HttpOnly = true;
options.Cookie.SecurePolicy = CookieSecurePolicy.Always;
options.Cookie.SameSite = SameSiteMode.Strict;
options.Cookie.SameSite = ansattPortenFeatureFlag ? SameSiteMode.Lax : SameSiteMode.Strict;

options.Cookie.IsEssential = true;

options.ExpireTimeSpan = TimeSpan.FromMinutes(oidcSettings.CookieExpiryTimeInMinutes);
Expand Down
6 changes: 6 additions & 0 deletions backend/src/Designer/Models/Dto/AuthStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Altinn.Studio.Designer.Models.Dto;

public class AuthStatus
{
public bool IsLoggedIn { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Altinn.Studio.Designer.Models.Dto;
using Designer.Tests.Controllers.AnsattPortenController.Base;
using Designer.Tests.Controllers.ApiTests;
using FluentAssertions;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.AspNetCore.Mvc.Testing.Handlers;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Xunit;

namespace Designer.Tests.Controllers.AnsattPortenController;

public class AuthStatusTest : AnsattPortenControllerTestsBase<AuthStatusTest>, IClassFixture<WebApplicationFactory<Program>>
{
private static string VersionPrefix => "/designer/api/ansattporten/auth-status";

// Setup unauthenticated http client
protected override HttpClient GetTestClient()
{
string configPath = GetConfigPath();
IConfiguration configuration = new ConfigurationBuilder()
.AddJsonFile(configPath, false, false)
.AddJsonStream(GenerateJsonOverrideConfig())
.AddEnvironmentVariables()
.Build();

return Factory.WithWebHostBuilder(builder =>
{
builder.UseConfiguration(configuration);
builder.ConfigureAppConfiguration((_, conf) =>
{
conf.AddJsonFile(configPath);
conf.AddJsonStream(GenerateJsonOverrideConfig());
});
builder.ConfigureTestServices(ConfigureTestServices);
builder.ConfigureServices(ConfigureTestServicesForSpecificTest);
}).CreateDefaultClient(new CookieContainerHandler());
Dismissed Show dismissed Hide dismissed
}

public AuthStatusTest(WebApplicationFactory<Program> factory) : base(factory)
{
}

[Fact]
public async Task AuthStatus_Should_ReturnFalse_IfNotAuthenticated()
{
using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, VersionPrefix);

using var response = await HttpClient.SendAsync(httpRequestMessage);
response.StatusCode.Should().Be(HttpStatusCode.OK);

AuthStatus authStatus = await response.Content.ReadAsAsync<AuthStatus>();
authStatus.IsLoggedIn.Should().BeFalse();
}

[Fact]
public async Task AuthStatus_Should_ReturnTrue_IfAuthenticated()
{
// Setup test authentication
ConfigureTestServicesForSpecificTest = services =>
{
services.AddAuthentication(defaultScheme: TestAuthConstants.TestAuthenticationScheme)
.AddScheme<AuthenticationSchemeOptions, TestAuthHandler>(
TestAuthConstants.TestAuthenticationScheme, options => { });
services.AddTransient<IAuthenticationSchemeProvider, TestSchemeProvider>();
};

using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, VersionPrefix);

using var response = await HttpClient.SendAsync(httpRequestMessage);
response.StatusCode.Should().Be(HttpStatusCode.OK);

AuthStatus authStatus = await response.Content.ReadAsAsync<AuthStatus>();
authStatus.IsLoggedIn.Should().BeTrue();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Altinn.Studio.Designer.Constants;
using Designer.Tests.Controllers.ApiTests;
using Microsoft.AspNetCore.Mvc.Testing;

namespace Designer.Tests.Controllers.AnsattPortenController.Base;

public class AnsattPortenControllerTestsBase<TControllerTest> : DesignerEndpointsTestsBase<TControllerTest> where TControllerTest : class
{
public AnsattPortenControllerTestsBase(WebApplicationFactory<Program> factory) : base(factory)
{
JsonConfigOverrides.Add(
$$"""
{
"FeatureManagement": {
"{{StudioFeatureFlags.AnsattPorten}}": true
},
"AnsattPortenLoginSettings": {
"ClientId": "non-empty-for-testing",
"ClientSecret": "non-empty-for-testing"
}
}
""");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Altinn.Studio.Designer.Constants;
using Designer.Tests.Controllers.AnsattPortenController.Base;
using Designer.Tests.Controllers.ApiTests;
using Microsoft.AspNetCore.Mvc.Testing;
using Xunit;

namespace Designer.Tests.Controllers.AnsattPortenController;

public class LoginTests : AnsattPortenControllerTestsBase<LoginTests>, IClassFixture<WebApplicationFactory<Program>>
{
private static string VersionPrefix => "/designer/api/ansattporten/login";

public LoginTests(WebApplicationFactory<Program> factory) : base(factory)
{
}

[Theory]
[InlineData("/test", HttpStatusCode.Redirect)]
[InlineData("/", HttpStatusCode.Redirect)]
[InlineData("https://docs.altinn.studio/", HttpStatusCode.Forbidden)]
public async Task LoginShouldReturn_ExpectedCode(string redirectTo, HttpStatusCode expectedStatusCode)
{
using var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get
, $"{VersionPrefix}?redirect_to={redirectTo}");

using var response = await HttpClient.SendAsync(httpRequestMessage);
Assert.Equal(expectedStatusCode, response.StatusCode);

if (expectedStatusCode == HttpStatusCode.Redirect)
{
Assert.Equal(redirectTo, response.Headers.Location?.ToString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected HttpClient HttpClient
/// </summary>
protected abstract void ConfigureTestServices(IServiceCollection services);

protected Action<IServiceCollection> ConfigureTestForSpecificTest { get; set; } = delegate { };
protected Action<IServiceCollection> ConfigureTestServicesForSpecificTest { get; set; } = delegate { };

/// <summary>
/// Location of the assembly of the executing unit test.
Expand Down Expand Up @@ -97,7 +97,7 @@ protected virtual HttpClient GetTestClient()
TestAuthConstants.TestAuthenticationScheme, options => { });
services.AddTransient<IAuthenticationSchemeProvider, TestSchemeProvider>();
});
builder.ConfigureServices(ConfigureTestForSpecificTest);
builder.ConfigureServices(ConfigureTestServicesForSpecificTest);
}).CreateDefaultClient(new ApiTestsAuthAndCookieDelegatingHandler(), new CookieContainerHandler());
}

Expand Down Expand Up @@ -152,7 +152,7 @@ private void InitializeJsonConfigOverrides()
}


private Stream GenerateJsonOverrideConfig()
protected Stream GenerateJsonOverrideConfig()
{
var overrideJson = Newtonsoft.Json.Linq.JObject.Parse(JsonConfigOverrides.First());
if (JsonConfigOverrides.Count > 1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Altinn.Studio.Designer.Constants;
using Designer.Tests.Controllers.ApiTests;
using Designer.Tests.Fixtures;
using Microsoft.AspNetCore.Mvc.Testing;
Expand All @@ -9,16 +10,17 @@ public class AppScopesControllerTestsBase<TControllerTest> : DbDesignerEndpoints
{
public AppScopesControllerTestsBase(WebApplicationFactory<Program> factory, DesignerDbFixture designerDbFixture) : base(factory, designerDbFixture)
{
JsonConfigOverrides.Add($@"
{{
""FeatureManagement"": {{
""AnsattPorten"": true
}},
""AnsattPortenLoginSettings"": {{
""ClientId"": ""non-empty-for-testing"",
""ClientSecret"": ""non-empty-for-testing""
}}
}}
");
JsonConfigOverrides.Add(
$$"""
{
"FeatureManagement": {
"{{StudioFeatureFlags.AnsattPorten}}": true
},
"AnsattPortenLoginSettings": {
"ClientId": "non-empty-for-testing",
"ClientSecret": "non-empty-for-testing"
}
}
""");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public async Task Get_Image_Non_Existing_Image_Return_NotFound()
public async Task Call_To_Get_Designer_Iframe_Does_Not_Hit_Image_EndPoint()
{
Mock<IAltinnGitRepositoryFactory> factMock = new();
ConfigureTestForSpecificTest = s =>
ConfigureTestServicesForSpecificTest = s =>
{
s.AddTransient(_ => factMock.Object);
};
Expand Down
2 changes: 1 addition & 1 deletion charts/altinn-designer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ environmentVariables:
- name: OidcLoginSettings__CookieExpiryTimeInMinutes
value: 59
- name: FeatureManagement__AnsattPorten
value: "false"
value: "true"
- name: FeatureManagement__EidLogging
value: "true"
staging:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { useServicesContext } from 'app-shared/contexts/ServicesContext';

export const useIsLoggedInWithAnsattportenQuery = () => {
const { getIsLoggedInWithAnsattporten } = useServicesContext();
return useQuery<boolean>({
return useQuery<{ isLoggedIn: boolean }>({
queryKey: [QueryKey.IsLoggedInWithAnsattporten],
queryFn: () => getIsLoggedInWithAnsattporten(),
queryFn: getIsLoggedInWithAnsattporten,
});
};
Loading
Loading