Skip to content

Commit

Permalink
C# integration tests (#182)
Browse files Browse the repository at this point in the history
* feat: suppert restsharp 107+

Updates restsharp support following their breaking
changes, reported in Kong#312

* add 'using RestSharp'

* update fixtures

* add write response.content at end

* fix(clojure): don't crash if there's no postData content (#171)

* ci: extend ci testing to run on node 20

* build: 5.1.1 release

* feat: dropping support for node 14

* chore(deps): bumping out of date deps

* build: 6.0.0 release

* wip

* getting the csharp integration tests running

* if NODE_ENV=test, these no longer run

* better csharp dockerfile

* the postdata-malformed fixture shouldn't expect a content-type header

* hammering the int tests into shape

* add httpbin

* wip (see below for details)

- go-httpbin is using my local tag bc of mccutchen/go-httpbin#123
- go-httpbin incorrectly thinks our requests are coming in on plain http. Possibly https://stackoverflow.com/a/61446922 is the answer?
- getting close

* updating fixtures for different bin

* wip

* 17 of 18 shell tests passing

* add a reverse proxy so 80 and 443 both go to httpbin

* remove console

* update python output

.json() will parse the output _out_ of json and print it
as a python object, which our integration tests cannot
then parse

* more dockerfile updating

* tell requests to use our CA

* fix python whoopsie

* php tests pass

* tell node to use system ca certs

* update node dockerfile

* switch back to mccutchen

* format integration_test.sh

* fix WORKDIR order in node dockerfile

* remove logging

* now the node tests pass locally

* try adding a node install

I'm not sure why it builds locally but not on gh

* Revert "now the node tests pass locally"

- This broke a lot of other tests

This reverts commit 0d6670d.

* ah HA found it

* remove unnecessary volumes

* add comment

* remove merge artifact

* update csharp dockerfile

* integration test fixes + comments

* fix csharp content type and add newline at end

* fix postdata-malformed fixture

* add explicit json header

* get final tests to pass

* remove cli arg because I can't figure out how to update the snapshots

* fix content-type condition

* don't assert content type of no params test

* re-add cli arg

* jeez content-types are complicated

* update snapshot

* add c# dep on proxy

* un-change package-lock.json

---------

Co-authored-by: Jon Ursenbach <[email protected]>
Co-authored-by: Jon Ursenbach <[email protected]>
  • Loading branch information
3 people authored Jun 23, 2023
1 parent c59be27 commit 72ea746
Show file tree
Hide file tree
Showing 27 changed files with 321 additions and 195 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
14 changes: 14 additions & 0 deletions .github/workflows/integration-csharp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Integrations (C#)
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Run tests
run: docker-compose run integration_csharp

- name: Cleanup
if: always()
run: docker-compose down
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,15 @@ services:
- HTTPBIN=true
- INTEGRATION_CLIENT=shell
- NODE_ENV=integration

integration_csharp:
depends_on:
- reverse_proxy
build:
context: .
dockerfile: integrations/csharp.Dockerfile
command: 'npx jest src/integration.test.ts'
environment:
- HTTPBIN=true
- INTEGRATION_CLIENT=csharp
- NODE_ENV=integration
39 changes: 39 additions & 0 deletions integrations/csharp.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM node:20-alpine3.18 AS node
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine3.18

COPY integrations/https-cert/rootCA.pem /root/integration-test.pem

# install the integration test certs
RUN apk --no-cache add ca-certificates && \
rm -rf /var/cache/apk/* && \
cp /root/integration-test.pem /usr/local/share/ca-certificates/ && \
update-ca-certificates

# copy node stuff from the node image to the dotnet image. Source for the
# necessary files:
# https://github.com/pyodide/pyodide/blob/1691d347d15a2c211cd49aebe6f15d42dfdf2369/Dockerfile#L105
COPY --from=node /usr/local/bin/node /usr/local/bin/
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
RUN ln -s ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \
&& ln -s ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx

WORKDIR /src

# - create a "hello world" project. We will later overwrite Program.cs in that
# folder with our test fixtures to run them
# - install RestSharp into that project
# - make a folder with the appropriate structure to hold the test fixtures
RUN dotnet new console -o IntTestCsharp -f net7.0 && \
cd IntTestCsharp && \
dotnet add package RestSharp && \
mkdir -p /src/IntTestCsharp/src/fixtures/files

# copy the only test fixture into the fixtures dir
ADD src/fixtures/files/hello.txt /src/IntTestCsharp/src/fixtures/files/

# add pacakge.json first so we don't have to `npm install` unless it changes
ADD package.json /src/
RUN npm install

# keep this last so that once this docker image is built it can be used quickly
ADD . /src
4 changes: 1 addition & 3 deletions src/fixtures/requests/multipart-form-data-no-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ module.exports = {
data: '',
files: {},
form: {},
headers: {
'Content-Type': ['multipart/form-data'],
},
headers: {},
json: null,
method: 'POST',
url: 'https://httpbin.org/anything',
Expand Down
1 change: 1 addition & 0 deletions src/helpers/__snapshots__/utils.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ exports[`availableTargets returns all available targets 1`] = `
"title": "Clojure",
},
{
"cli": "dotnet",
"clients": [
{
"description": ".NET Standard HTTP Client",
Expand Down
Loading

0 comments on commit 72ea746

Please sign in to comment.