Skip to content

Commit

Permalink
no ssl tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nitely committed Aug 18, 2024
1 parent 2b874bb commit 92676fb
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ jobs:
(nimble funcserve &) && \
sleep 10s && \
nimble functest"
- name: Run Functional Insecure Tests
run: |
docker pull nimlang/nim:${{ matrix.nim }}
docker run --env-file .env --rm -v `pwd`:/usr/src/app -w /usr/src/app nimlang/nim:${{ matrix.nim }} \
/bin/bash -c "git config --global --add safe.directory /usr/src/app && \
nimble install -y && \
(nimble funcserveinsec &) && \
sleep 10s && \
nimble functestinsec"
- name: Run Examples
run: |
docker pull nimlang/nim:${{ matrix.nim }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ tests/testclient
tests/testclientserver
tests/testserver
tests/functional/tserial
tests/functional/tserialinsecure
tests/functional/tserver
tests/functional/tserverinsecure
tests/functional/tconcurrent
tests/functional/tconcurrentdata
tests/functional/tflowcontrol
Expand Down
6 changes: 6 additions & 0 deletions hyperx.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ task functest, "Func test":
exec "nim c -r -d:release tests/functional/tflowcontrol.nim"
exec "nim c -r -d:release tests/functional/tcancel.nim"

task funcserveinsec, "Func Serve Insecure":
exec "nim c -r -d:release tests/functional/tserverinsecure.nim"

task functestinsec, "Func test insecure":
exec "nim c -r tests/functional/tserialinsecure.nim"

task h2spec, "h2spec test":
exec "./h2spec --tls --port 8783 --strict"

Expand Down
41 changes: 41 additions & 0 deletions tests/functional/tserialinsecure.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## Same as tserial but uses plain http2

{.define: ssl.}
{.define: hyperxSanityCheck.}

import std/asyncdispatch
import ../../src/hyperx/client
import ./tutils.nim

proc main() {.async.} =
var checked = 0
var client = newClient(localHost, localInsecurePort, ssl = false)
with client:
for story in stories("raw-data"):
for headers in cases(story):
doAssert headers.isRequest
# there is only one case with content
if headers.contentLen != 0:
continue
let rawHeaders = headers.rawHeaders()
let strm = client.newClientStream()
with strm:
let headersRef = new(seq[Header])
headersRef[] = headers
await strm.sendHeaders(headersRef, finish = true)
var data = newStringref()
await strm.recvHeaders(data)
doAssert data[] == ":status: 200\r\n"
data[].setLen 0
while not strm.recvEnded:
await strm.recvBody(data)
doAssert data[] == rawHeaders
inc checked
doAssert checked == 348
echo "checked ", $checked

(proc =
waitFor main()
doAssert not hasPendingOperations()
echo "ok"
)()
2 changes: 1 addition & 1 deletion tests/functional/tserver.nim
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ proc processClientHandler(client: ClientContext) {.async.} =
echoStats client
#GC_fullCollect()

proc serve(server: ServerContext) {.async.} =
proc serve*(server: ServerContext) {.async.} =
with server:
while server.isConnected:
let client = await server.recvClient()
Expand Down
19 changes: 19 additions & 0 deletions tests/functional/tserverinsecure.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{.define: ssl.}
{.define: hyperxSanityCheck.}

import std/asyncdispatch
import ../../src/hyperx/server
import ./tserver
import ./tutils

proc main() {.async.} =
echo "Serving forever"
var server = newServer(
localHost, localInsecurePort, ssl = false
)
await server.serve()

when isMainModule:
waitFor main()
doAssert not hasPendingOperations()
echo "ok"
1 change: 1 addition & 0 deletions tests/functional/tutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import std/asyncdispatch

const localHost* = "127.0.0.1"
const localPort* = Port 8763
const localInsecurePort* = Port 7770
const testDataBaseDir = "tests/functional/"

type Header* = (string, string)
Expand Down

0 comments on commit 92676fb

Please sign in to comment.