-
Notifications
You must be signed in to change notification settings - Fork 94
feat: Add AppSetting for frontend asset base url and param in cli #18850
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
Open
bjorntore
wants to merge
20
commits into
main
Choose a base branch
from
feat/controller-frontend-version-appsetting
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
3319e9b
Add configurable controller frontend version
bjorntore a89b2a4
Rename frontend dev server flag
bjorntore 8af13cf
Merge branch 'main' into feat/controller-frontend-version-appsetting
bjorntore d75d9d1
fix: use localtest service owner org number
bjorntore 28ea932
Removing lots of versioning stuff we no longer need when v9 versions …
19722fc
Removing assertions on cookie that is no longer in use in v9
575e42c
Hiding the frontend version switcher when app is v9+, as it's no long…
8d5e57e
Showing an error page when app is not started with --dev-frontend
d5cd5db
Removing frontendUrl config from cypress (no longer in use)
73c7fa9
Adding --dev-frontend to `studioctl build` as well, and using those w…
ac3e965
Updating test now that outdated frontend assets are not loaded by def…
450a218
Merge branch 'refs/heads/main' into feat/controller-frontend-version-…
8727a45
Updating changed paths
ca272e0
gofmt
989f6b8
Fixing comments from codeql
fbfb8de
Fixing formatting and linting issues
9e5df5e
Revert "Adding --dev-frontend to `studioctl build` as well, and using…
f4dea78
Simplifying app-run-local-env, as overriding the port is not possible…
50c58e9
Running gofmt again
2fcca5d
Merge branch 'main' into feat/controller-frontend-version-appsetting
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...ckend/test/Altinn.App.Api.Tests/Controllers/HomeControllerTest_AppFrontendAssetBaseUrl.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| using System.Net; | ||
| using Altinn.App.Core.Models; | ||
| using Altinn.Platform.Storage.Interface.Models; | ||
| using App.IntegrationTests.Mocks.Services; | ||
| using Microsoft.AspNetCore.Hosting; | ||
| using Microsoft.AspNetCore.Mvc.Testing; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Microsoft.Extensions.DependencyInjection.Extensions; | ||
| using Microsoft.Extensions.FileProviders; | ||
| using Microsoft.Extensions.Hosting; | ||
| using Moq; | ||
| using Xunit.Abstractions; | ||
|
|
||
| namespace Altinn.App.Api.Tests.Controllers; | ||
|
|
||
| public class HomeControllerTest_AppFrontendAssetBaseUrl : ApiTestBase, IClassFixture<WebApplicationFactory<Program>> | ||
| { | ||
| private const string Org = "tdd"; | ||
| private const string App = "contributer-restriction"; | ||
|
|
||
| public HomeControllerTest_AppFrontendAssetBaseUrl( | ||
| WebApplicationFactory<Program> factory, | ||
| ITestOutputHelper outputHelper | ||
| ) | ||
| : base(factory, outputHelper) | ||
| { | ||
| OverrideEnvironment = Environments.Development; | ||
| SendAsync = _ => | ||
| Task.FromResult( | ||
| new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent("""{"orgs":{}}""") } | ||
| ); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task Index_UsesAppFrontendAssetBaseUrlAppSetting() | ||
| { | ||
| OverrideAppSetting("AppSettings:AppFrontendAssetBaseUrl", "/configured/frontend/"); | ||
|
|
||
| using var client = GetRootedClient(Org, App, configureServices: ConfigureStatelessAnonymousApp); | ||
| using var response = await client.GetAsync($"{Org}/{App}/"); | ||
| var html = await response.Content.ReadAsStringAsync(); | ||
|
|
||
| Assert.Equal(HttpStatusCode.OK, response.StatusCode); | ||
| Assert.Contains("href=\"/configured/frontend/altinn-app-frontend.css\"", html); | ||
| Assert.Contains("src=\"/configured/frontend/altinn-app-frontend.js\"", html); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task Index_UsesCdnAppFrontendAssetsByDefault() | ||
| { | ||
| using var client = GetRootedClient(Org, App, configureServices: ConfigureStatelessAnonymousApp); | ||
| using var response = await client.GetAsync($"{Org}/{App}/"); | ||
| var html = await response.Content.ReadAsStringAsync(); | ||
|
|
||
| Assert.Equal(HttpStatusCode.OK, response.StatusCode); | ||
| Assert.Contains("href=\"https://altinncdn.no/toolkits/altinn-app-frontend/4/altinn-app-frontend.css\"", html); | ||
| Assert.Contains("src=\"https://altinncdn.no/toolkits/altinn-app-frontend/4/altinn-app-frontend.js\"", html); | ||
| } | ||
|
|
||
| private static void ConfigureStatelessAnonymousApp(IServiceCollection services) | ||
| { | ||
| var webHostEnvironmentMock = new Mock<IWebHostEnvironment>(); | ||
| webHostEnvironmentMock.SetupGet(e => e.EnvironmentName).Returns(Environments.Development); | ||
| webHostEnvironmentMock.SetupGet(e => e.ApplicationName).Returns("Altinn.App.Api"); | ||
| webHostEnvironmentMock.SetupGet(e => e.ContentRootPath).Returns(Directory.GetCurrentDirectory()); | ||
| webHostEnvironmentMock | ||
| .SetupGet(e => e.WebRootPath) | ||
| .Returns(Path.Join(Directory.GetCurrentDirectory(), "wwwroot")); | ||
| webHostEnvironmentMock.SetupGet(e => e.ContentRootFileProvider).Returns(new NullFileProvider()); | ||
| webHostEnvironmentMock.SetupGet(e => e.WebRootFileProvider).Returns(new NullFileProvider()); | ||
| services.Replace(ServiceDescriptor.Singleton(webHostEnvironmentMock.Object)); | ||
|
|
||
| services.AddSingleton( | ||
| new AppMetadataMutationHook(appMetadata => | ||
| { | ||
| appMetadata.OnEntry = new OnEntry { Show = "Task_1" }; | ||
| appMetadata.DataTypes.Find(d => d.Id == "default")!.AppLogic!.AllowAnonymousOnStateless = true; | ||
| }) | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.