Skip to content

Comments

Use actual ohttp-relay in integration tests#572

Merged
DanGould merged 3 commits intopayjoin:masterfrom
nothingmuch:no-mock-relay-in-tests
Mar 14, 2025
Merged

Use actual ohttp-relay in integration tests#572
DanGould merged 3 commits intopayjoin:masterfrom
nothingmuch:no-mock-relay-in-tests

Conversation

@nothingmuch
Copy link
Collaborator

@nothingmuch nothingmuch commented Mar 12, 2025

Instead of submitting OHTTP requests directly to the directory's OHTTP gateway, give the OHTTP gateway's self signed certificate to the relay so it can connect to it, and exercise the relay in the integration tests.

This change updatespayjoin-test-util's Cargo.toml to use a git origin for the merge commit of payjoin/ohttp-relay#63, as such it needs to be followed up with a commit that specifies an updated version before release.

Depends on

(edit by Dan, when you put dependencies in a list the render pretty)

@coveralls
Copy link
Collaborator

coveralls commented Mar 12, 2025

Pull Request Test Coverage Report for Build 13866951625

Details

  • 18 of 18 (100.0%) changed or added relevant lines in 1 file are covered.
  • 9 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.1%) to 80.497%

Files with Coverage Reduction New Missed Lines %
payjoin/src/send/mod.rs 2 94.34%
payjoin-directory/src/lib.rs 3 76.71%
payjoin-test-utils/src/lib.rs 4 94.94%
Totals Coverage Status
Change from base Build 13844597959: -0.1%
Covered Lines: 4829
Relevant Lines: 5999

💛 - Coveralls

@nothingmuch nothingmuch requested a review from spacebear21 March 12, 2025 20:03
Copy link
Collaborator

@spacebear21 spacebear21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

concept ACK

I wonder if there's any way we could specify the SSL cert path explicitly when initializing the ohttp relay, such that it wouldn't have to read from a shared env variable?

@nothingmuch
Copy link
Collaborator Author

I wonder if there's any way we could specify the SSL cert path explicitly when initializing the ohttp relay, such that it wouldn't have to read from a shared env variable?

Yes, we can construct a RootCertStore from whatever configuration source instead of relying on https://docs.rs/rustls-native-certs/latest/rustls_native_certs/fn.load_native_certs.html

This would mean following up on payjoin/ohttp-relay#62 with something that introduces a mechanism to pass that root store around (IMO introducing a struct RelayService, something I kind of wanted to do anyway for the prober & http client but left as a followup).

Then instead of an environment variable, the CLI interface for the relay could have a CLI option. That would be a more significant change, I decided to use an environment variable in the end since it was significantly less boilerplate code, which I felt was important to control the feature gating complexity.

@nothingmuch
Copy link
Collaborator Author

I was mistaken, since the relay is not actually started as a CLI program in the e2e tests, there's no such restriction.

While the directory's OHTTP gateway does not require the content type
header to be set to `message/ohttp-req`, the OHTTP relay does.
The certificate generated by TestServices is self signed, add it to a
new RootCertStore and give it to the relay for when it acts as an HTTP
client as part of the updated relay API that supports this.

Also use GatewayUri instead of Uri, which has also changed upstream.
Instead of sending OHTTP requests directly to the gateway, send them
through the relay set up by TestServices.
@nothingmuch nothingmuch force-pushed the no-mock-relay-in-tests branch from 935d4a8 to 8649acf Compare March 14, 2025 23:24
Copy link
Contributor

@DanGould DanGould left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 8649acf

What a relief to get rid of this mock.
Note this makes use of an ohttp-relay commit instead of release so that we can test properly. We will have to come out with an ohttp-relay release before we release the next payjoin version.

@DanGould DanGould merged commit 5258182 into payjoin:master Mar 14, 2025
7 checks passed
@nothingmuch nothingmuch deleted the no-mock-relay-in-tests branch March 14, 2025 23:35
nothingmuch added a commit that referenced this pull request Mar 15, 2025
With this change, the payjoin directory's RFC 9540 compatible OHTTP
gateway additionally opts in to receiving OHTTP requests from arbitrary
relays.

See payjoin/ohttp-relay#58. 

Depends on
- #549
- #572
nothingmuch added a commit to nothingmuch/rust-payjoin that referenced this pull request Mar 17, 2025
Some instances of specifying the gateway as the relay were missed in payjoin#572
shinghim pushed a commit to shinghim/rust-payjoin that referenced this pull request Mar 25, 2025
Some instances of specifying the gateway as the relay were missed in payjoin#572
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.

4 participants