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

Fix for local testing for altinn-receipt #91

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

khanrn
Copy link

@khanrn khanrn commented Mar 5, 2024

Fix for local testing for altinn-receipt

Description

While this solution addresses local testing for altinn-receipt, I'm open to exploring alternative methods that don't involve modifying the docker-compose.yml file directly. If you have any ideas or suggestions, please provide your input here. 🙂

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • All tests run green

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

@khanrn khanrn changed the title Fix for local testing for altinn-receipt Fix for local testing for altinn-receipt Mar 5, 2024
@ivarne
Copy link
Member

ivarne commented Mar 5, 2024

Can you explain how and why this will fix anything? Does localtest need to call authorization endpoints over http?

You'll also need to fix https://github.com/Altinn/app-localtest/blob/main/podman-compose.yml

@khanrn
Copy link
Author

khanrn commented Mar 5, 2024

@ivarne You are correct! This change need to reflect the podman-comose.yml as well. But I skipped that as I was quite certain(as I mentioned in the Slack discussion) that this PR would raise a discussion. Therefore I wanted to find the best approach to achieve this first before doing any further change. 🙂

Now the question is why this change?

When testing altinn-receipt in locally it calls the /authentication/api/v1/openid/.well-known/openid-configuration to get the OpenID configuration and that configuration is returned by app-localtest. And in that configuration if the address is localhost then altinn-receipt calls localhost:5101 which ends up calling it's own localhost. Here we want altinn-receipt to call host.docker.internal:5101. Therefore this change came.

Related Issue(s) and PR(s)

@ivarne
Copy link
Member

ivarne commented Mar 5, 2024

What do you mean by testing altinn-receipt in locally. Do you run the https://github.com/Altinn/altinn-receipt project locally?

I don't see how changing the environment variables for the localtest mock project does anything to the receipt project?

@khanrn
Copy link
Author

khanrn commented Mar 5, 2024

@ivarne Yes. You are correct I'm referring to testing https://github.com/Altinn/altinn-receipt project locally.

So when the altinn-receipt app is getting tested against app-localtest it gets the SocketException: Address not available (see the first screenshot) error as when it is reaching out to localhost:5101 it is actually going for it's own as this runs in an individual docker container. Then a it turns out that the values from the OpenID configuration (see the first screenshot) is creating the issue which is generated by app-localtest with the environment variables proposed here for change. Because this environment variable is actually giving the altinn-receipt the address localhost:5101. This proposed fix with the PR mentioned in the Related Issue(s) section of this PR fixed the issue.

I must admit that it is not the best way to fix it. It'd be better if we can have this in the .env configuration. Or can set the environment over CLI.🤔

  1. SocketException: Address not available

    Screenshot 2024-03-05 at 15 35 17

  2. openid-configuration

    Screenshot 2024-03-05 at 15 36 23

@ivarne
Copy link
Member

ivarne commented Mar 5, 2024

Aha, Now I understand. This "fix" will likely break apps that use this endpoint to get the json web keys to verify cookies when running outside of docker (all of them), so we need a better solution.

@ivarne
Copy link
Member

ivarne commented Mar 5, 2024

Maybe @tjololo has some ideas for how the openIdConnect endpoint can reply with an url for the keys that works both inside and outside docker?

@SandGrainOne
Copy link
Member

SandGrainOne commented Mar 13, 2024

@ivarne I'm unable to test an app locally on my machine without changes for podman.
I get it working by adding:

  "AuthnGeneralSettings": {
    "PlatformEndpoint": "http://local.altinn.cloud:5101/"
  },

to the appsettings.podman.json file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants