Skip to content

Commit aa1eee3

Browse files
committed
refactor
1 parent 684aec4 commit aa1eee3

1 file changed

Lines changed: 2 additions & 24 deletions

File tree

tests/stubs/acme_api_stub.nim

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,21 @@
77

88
import uri
99
import chronos, chronos/apps/http/httpclient
10-
import ../../libp2p/[autotls/acme/api, utils/opt]
10+
import ../../libp2p/autotls/acme/api
1111

1212
export api
1313

1414
type ACMEApiStub* = ref object of ACMEApi
1515
## Refuses every ACME request, recording what was requested.
16-
stalls*: bool
1716
requestedUris*: seq[Uri]
1817

1918
proc new*(T: typedesc[ACMEApiStub]): ACMEApiStub =
20-
ACMEApiStub(
21-
session: HttpSessionRef.new(),
22-
directory: Opt.some(
23-
ACMEDirectory(
24-
newNonce: LetsEncryptURL & "/new-nonce",
25-
newOrder: LetsEncryptURL & "/new-order",
26-
newAccount: LetsEncryptURL & "/new-account",
27-
)
28-
),
29-
acmeServerURL: parseUri(LetsEncryptURL),
30-
)
31-
32-
method requestNonce*(
33-
self: ACMEApiStub
34-
): Future[Nonce] {.async: (raises: [ACMEError, CancelledError]).} =
35-
Nonce($self.acmeServerURL & "/acme/1234")
36-
37-
proc stallUntilCancelled(self: ACMEApiStub) {.async: (raises: [CancelledError]).} =
38-
## A request that only ends when the caller gives up on it.
39-
await Future[void].Raising([CancelledError]).init("ACMEApiStub.request")
19+
ACMEApiStub(session: HttpSessionRef.new(), acmeServerURL: parseUri(LetsEncryptURL))
4020

4121
proc refuse(
4222
self: ACMEApiStub, uri: Uri
4323
): Future[HTTPResponse] {.async: (raises: [ACMEError, CancelledError]).} =
4424
self.requestedUris.add(uri)
45-
if self.stalls:
46-
await self.stallUntilCancelled()
4725
raise newException(ACMEError, "ACMEApiStub refused " & $uri)
4826

4927
method post*(

0 commit comments

Comments
 (0)