Skip to content

Commit

Permalink
Various updates to app-localtest (#60)
Browse files Browse the repository at this point in the history
* Add vscode debug files
* add support for proxying /_framework/aspnetcore-browser-refresh.js
  calls through the loadbalancer by rewriting the both the url and the
  script reference.
* Fix a few C# formatting isuses
  • Loading branch information
ivarne authored Oct 10, 2023
1 parent 67c3d04 commit acdcb84
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 3 deletions.
33 changes: 33 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/src/bin/Debug/net6.0/LocalTest.dll",
"args": [],
"cwd": "${workspaceFolder}/src",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
41 changes: 41 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/LocalTest.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/LocalTest.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/LocalTest.sln"
],
"problemMatcher": "$msCompile"
}
]
}
6 changes: 6 additions & 0 deletions loadbalancer/templates/nginx.conf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ http {

location = / {
proxy_pass http://localtest/Home/;
sub_filter '<script src="/_framework/aspnetcore-browser-refresh.js"></script>' '<script src="/Home/_framework/aspnetcore-browser-refresh.js"></script>';
}

location / {
Expand All @@ -81,8 +82,13 @@ http {
proxy_cookie_domain altinn3local.no local.altinn.cloud;
}

location /Home/_framework/ {
proxy_pass http://localtest/_framework/;
}

location /Home/ {
proxy_pass http://localtest/Home/;
sub_filter '<script src="/_framework/aspnetcore-browser-refresh.js"></script>' '<script src="/Home/_framework/aspnetcore-browser-refresh.js"></script>';
}

location /receipt/ {
Expand Down
6 changes: 3 additions & 3 deletions src/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public async Task<ActionResult> GetTestOrgToken(string id, [FromQuery] string or
public static readonly string FRONTEND_URL_COOKIE_NAME = "frontendVersion";

[HttpGet]
public async Task<ActionResult> FrontendVersion([FromServices]HttpClient client)
public async Task<ActionResult> FrontendVersion([FromServices] HttpClient client)
{
var versionFromCookie = HttpContext.Request.Cookies[FRONTEND_URL_COOKIE_NAME];

Expand Down Expand Up @@ -315,7 +315,7 @@ private async Task<IEnumerable<SelectListItem>> GetTestUsersForList()

var userParties = await _partiesService.GetParties(properProfile.UserId);

if (userParties.Count == 1)
if (userParties.Count == 1 && userParties.First().PartyId == properProfile.PartyId)
{
// Don't add singe party users to a group
var party = userParties.First();
Expand Down Expand Up @@ -349,7 +349,7 @@ private async Task<IEnumerable<SelectListItem>> GetTestUsersForList()

private async Task<int> GetAppAuthLevel(bool isHttp, IEnumerable<SelectListItem> testApps)
{
if(!isHttp)
if (!isHttp)
{
return 2;
}
Expand Down

0 comments on commit acdcb84

Please sign in to comment.