From 008d02e715010a55259a8fbe5b3a2d2b54ede861 Mon Sep 17 00:00:00 2001 From: "Matthew H. Irby" Date: Mon, 21 Aug 2023 14:52:22 -0400 Subject: [PATCH] Use hurl for integration tests --- .github/workflows/pr-api.yml | 6 ++++ integrations/tests/health.hurl | 3 ++ integrations/tests/secrets.hurl | 55 +++++++++++++++++++++++++++++++++ src/api/SecretsSharingTool.sln | 7 ----- 4 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 integrations/tests/health.hurl create mode 100644 integrations/tests/secrets.hurl diff --git a/.github/workflows/pr-api.yml b/.github/workflows/pr-api.yml index 7bd7dd1..49f900d 100644 --- a/.github/workflows/pr-api.yml +++ b/.github/workflows/pr-api.yml @@ -15,6 +15,10 @@ jobs: steps: - uses: actions/checkout@v2 + - name: install hurl + uses: gacts/install-hurl@v1.0.3 + with: + version: 4.0.0 - name: Start Docker containers working-directory: . run: docker-compose --project-directory . -f env/local/docker-compose.local.yml up -d @@ -40,6 +44,8 @@ jobs: - name: Run tests working-directory: ./src/api run: dotnet test --verbosity normal + - name: Run integration tests + run: hurl --test integrations/**/*.hurl - name: Stop Docker containers if: always() working-directory: . diff --git a/integrations/tests/health.hurl b/integrations/tests/health.hurl new file mode 100644 index 0000000..c05784c --- /dev/null +++ b/integrations/tests/health.hurl @@ -0,0 +1,3 @@ +GET http://localhost:5000/api/health + +HTTP 200 diff --git a/integrations/tests/secrets.hurl b/integrations/tests/secrets.hurl new file mode 100644 index 0000000..f0ec252 --- /dev/null +++ b/integrations/tests/secrets.hurl @@ -0,0 +1,55 @@ +# Create Secrets -- Test Invalid Input + +POST http://localhost:5000/api/secrets +{ + "message": "", + "expireMinutes": 10 +} + +HTTP 400 + +POST http://localhost:5000/api/secrets +{ + "message": "Hello, World!", + "expireMinutes": 0 +} + +HTTP 400 + +POST http://localhost:5000/api/secrets +{ + "message": "Hello, World!", + "expireMinutes": 10080 +} + +HTTP 400 + + + + +# Create and Retrieve Secrets + +POST http://localhost:5000/api/secrets +{ + "message": "Hello, World!", + "expireMinutes": 10 +} + +HTTP 201 +[Captures] +secret_id: jsonpath "$['secretId']" +key: jsonpath "$['key']" + + +GET http://localhost:5000/api/secrets/{{secret_id}}?key={{key}} + +HTTP 200 +[Asserts] +jsonpath "$['message']" == "Hello, World!" + + +# Getting the same secret again should fail +GET http://localhost:5000/api/secrets/{{secret_id}}?key={{key}} + +HTTP 404 + diff --git a/src/api/SecretsSharingTool.sln b/src/api/SecretsSharingTool.sln index 8281fb2..1423d48 100644 --- a/src/api/SecretsSharingTool.sln +++ b/src/api/SecretsSharingTool.sln @@ -14,8 +14,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecretsSharingTool.Data", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecretsSharingTool.Data.Tests", "SecretsSharingTool.Data.Tests\SecretsSharingTool.Data.Tests.csproj", "{6A7E7FE5-8C7A-4E0F-9CCA-F63DB9FEC1EC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecretsSharingTool.Web.Tests", "SecretsSharingTool.Web.Tests\SecretsSharingTool.Web.Tests.csproj", "{63B69660-D085-4F83-95FD-24EA4FCF2652}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -46,15 +44,10 @@ Global {6A7E7FE5-8C7A-4E0F-9CCA-F63DB9FEC1EC}.Debug|Any CPU.Build.0 = Debug|Any CPU {6A7E7FE5-8C7A-4E0F-9CCA-F63DB9FEC1EC}.Release|Any CPU.ActiveCfg = Release|Any CPU {6A7E7FE5-8C7A-4E0F-9CCA-F63DB9FEC1EC}.Release|Any CPU.Build.0 = Release|Any CPU - {63B69660-D085-4F83-95FD-24EA4FCF2652}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {63B69660-D085-4F83-95FD-24EA4FCF2652}.Debug|Any CPU.Build.0 = Debug|Any CPU - {63B69660-D085-4F83-95FD-24EA4FCF2652}.Release|Any CPU.ActiveCfg = Release|Any CPU - {63B69660-D085-4F83-95FD-24EA4FCF2652}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {20B91B6D-C37F-4491-A848-C6BAE66A7C0A} = {66872805-2E12-4F37-8E08-08C508201861} {2133FEDF-EBA3-49F9-826D-6CA3FBB76F86} = {66872805-2E12-4F37-8E08-08C508201861} {6A7E7FE5-8C7A-4E0F-9CCA-F63DB9FEC1EC} = {66872805-2E12-4F37-8E08-08C508201861} - {63B69660-D085-4F83-95FD-24EA4FCF2652} = {66872805-2E12-4F37-8E08-08C508201861} EndGlobalSection EndGlobal