Skip to content

Commit 72ea746

Browse files
llimlliberunion
andauthored
C# integration tests (readmeio#182)
* 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 (readmeio#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]>
1 parent c59be27 commit 72ea746

27 files changed

Lines changed: 321 additions & 195 deletions

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Integrations (C#)
2+
on: [push]
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v3
8+
9+
- name: Run tests
10+
run: docker-compose run integration_csharp
11+
12+
- name: Cleanup
13+
if: always()
14+
run: docker-compose down

docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,15 @@ services:
7878
- HTTPBIN=true
7979
- INTEGRATION_CLIENT=shell
8080
- NODE_ENV=integration
81+
82+
integration_csharp:
83+
depends_on:
84+
- reverse_proxy
85+
build:
86+
context: .
87+
dockerfile: integrations/csharp.Dockerfile
88+
command: 'npx jest src/integration.test.ts'
89+
environment:
90+
- HTTPBIN=true
91+
- INTEGRATION_CLIENT=csharp
92+
- NODE_ENV=integration

integrations/csharp.Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM node:20-alpine3.18 AS node
2+
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine3.18
3+
4+
COPY integrations/https-cert/rootCA.pem /root/integration-test.pem
5+
6+
# install the integration test certs
7+
RUN apk --no-cache add ca-certificates && \
8+
rm -rf /var/cache/apk/* && \
9+
cp /root/integration-test.pem /usr/local/share/ca-certificates/ && \
10+
update-ca-certificates
11+
12+
# copy node stuff from the node image to the dotnet image. Source for the
13+
# necessary files:
14+
# https://github.com/pyodide/pyodide/blob/1691d347d15a2c211cd49aebe6f15d42dfdf2369/Dockerfile#L105
15+
COPY --from=node /usr/local/bin/node /usr/local/bin/
16+
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
17+
RUN ln -s ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \
18+
&& ln -s ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx
19+
20+
WORKDIR /src
21+
22+
# - create a "hello world" project. We will later overwrite Program.cs in that
23+
# folder with our test fixtures to run them
24+
# - install RestSharp into that project
25+
# - make a folder with the appropriate structure to hold the test fixtures
26+
RUN dotnet new console -o IntTestCsharp -f net7.0 && \
27+
cd IntTestCsharp && \
28+
dotnet add package RestSharp && \
29+
mkdir -p /src/IntTestCsharp/src/fixtures/files
30+
31+
# copy the only test fixture into the fixtures dir
32+
ADD src/fixtures/files/hello.txt /src/IntTestCsharp/src/fixtures/files/
33+
34+
# add pacakge.json first so we don't have to `npm install` unless it changes
35+
ADD package.json /src/
36+
RUN npm install
37+
38+
# keep this last so that once this docker image is built it can be used quickly
39+
ADD . /src

src/fixtures/requests/multipart-form-data-no-params.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ module.exports = {
3838
data: '',
3939
files: {},
4040
form: {},
41-
headers: {
42-
'Content-Type': ['multipart/form-data'],
43-
},
41+
headers: {},
4442
json: null,
4543
method: 'POST',
4644
url: 'https://httpbin.org/anything',

src/helpers/__snapshots__/utils.test.ts.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ exports[`availableTargets returns all available targets 1`] = `
3131
"title": "Clojure",
3232
},
3333
{
34+
"cli": "dotnet",
3435
"clients": [
3536
{
3637
"description": ".NET Standard HTTP Client",

0 commit comments

Comments
 (0)