Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 180 additions & 15 deletions examples/Demo/PostmanExample_15steps_v2.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@
"name": "LIST USERS",
"request": {
"method": "GET",
"header": [],
"header": [
{
"key": "Key1",
"value": "Value1",
"type": "text"
},
{
"key": "Key2",
"value": "Value2",
"type": "text"
}
],
"url": {
"raw": "https://reqres.in/api/users?page=2",
"protocol": "https",
Expand Down Expand Up @@ -39,7 +50,18 @@
"type": "noauth"
},
"method": "GET",
"header": [],
"header": [
{
"key": "Key1",
"value": "Value1",
"type": "text"
},
{
"key": "Key2",
"value": "Value2",
"type": "text"
}
],
"url": "https://reqres.in/api/users/2"
},
"response": []
Expand All @@ -51,7 +73,18 @@
"type": "noauth"
},
"method": "GET",
"header": [],
"header": [
{
"key": "Key1",
"value": "Value1",
"type": "text"
},
{
"key": "Key2",
"value": "Value2",
"type": "text"
}
],
"url": "https://reqres.in/api/users/23"
},
"response": []
Expand All @@ -63,7 +96,18 @@
"type": "noauth"
},
"method": "GET",
"header": [],
"header": [
{
"key": "Key1",
"value": "Value1",
"type": "text"
},
{
"key": "Key2",
"value": "Value2",
"type": "text"
}
],
"url": "https://reqres.in/api/unknown"
},
"response": []
Expand All @@ -75,7 +119,18 @@
"type": "noauth"
},
"method": "GET",
"header": [],
"header": [
{
"key": "Key1",
"value": "Value1",
"type": "text"
},
{
"key": "Key2",
"value": "Value2",
"type": "text"
}
],
"url": "https://reqres.in/api/unknown/2"
},
"response": []
Expand All @@ -87,7 +142,18 @@
"type": "noauth"
},
"method": "GET",
"header": [],
"header": [
{
"key": "Key1",
"value": "Value1",
"type": "text"
},
{
"key": "Key2",
"value": "Value2",
"type": "text"
}
],
"url": "https://reqres.in/api/unknown/23"
},
"response": []
Expand All @@ -99,7 +165,18 @@
"type": "noauth"
},
"method": "POST",
"header": [],
"header": [
{
"key": "Key1",
"value": "Value1",
"type": "text"
},
{
"key": "Key2",
"value": "Value2",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"name\": \"morpheus\",\r\n \"job\": \"leader\"\r\n}",
Expand All @@ -120,7 +197,18 @@
"type": "noauth"
},
"method": "PUT",
"header": [],
"header": [
{
"key": "Key1",
"value": "Value1",
"type": "text"
},
{
"key": "Key2",
"value": "Value2",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"name\": \"morpheus\",\r\n \"job\": \"zion resident\"\r\n}",
Expand All @@ -141,7 +229,18 @@
"type": "noauth"
},
"method": "PATCH",
"header": [],
"header": [
{
"key": "Key1",
"value": "Value1",
"type": "text"
},
{
"key": "Key2",
"value": "Value2",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"name\": \"morpheus\",\r\n \"job\": \"zion resident\"\r\n}",
Expand All @@ -162,7 +261,18 @@
"type": "noauth"
},
"method": "DELETE",
"header": [],
"header": [
{
"key": "Key1",
"value": "Value1",
"type": "text"
},
{
"key": "Key2",
"value": "Value2",
"type": "text"
}
],
"url": "https://reqres.in/api/users/2"
},
"response": []
Expand All @@ -174,7 +284,18 @@
"type": "noauth"
},
"method": "POST",
"header": [],
"header": [
{
"key": "Key1",
"value": "Value1",
"type": "text"
},
{
"key": "Key2",
"value": "Value2",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"email\": \"eve.holt@reqres.in\",\r\n \"password\": \"pistol\"\r\n}",
Expand All @@ -195,7 +316,18 @@
"type": "noauth"
},
"method": "POST",
"header": [],
"header": [
{
"key": "Key1",
"value": "Value1",
"type": "text"
},
{
"key": "Key2",
"value": "Value2",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"email\": \"sydney@fife\"\r\n}",
Expand All @@ -216,7 +348,18 @@
"type": "noauth"
},
"method": "POST",
"header": [],
"header": [
{
"key": "Key1",
"value": "Value1",
"type": "text"
},
{
"key": "Key2",
"value": "Value2",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"email\": \"eve.holt@reqres.in\",\r\n \"password\": \"cityslicka\"\r\n}",
Expand All @@ -237,7 +380,18 @@
"type": "noauth"
},
"method": "POST",
"header": [],
"header": [
{
"key": "Key1",
"value": "Value1",
"type": "text"
},
{
"key": "Key2",
"value": "Value2",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"email\": \"peter@klaven\"\r\n}",
Expand All @@ -258,7 +412,18 @@
"type": "noauth"
},
"method": "GET",
"header": [],
"header": [
{
"key": "Key1",
"value": "Value1",
"type": "text"
},
{
"key": "Key2",
"value": "Value2",
"type": "text"
}
],
"url": {
"raw": "https://reqres.in/api/users?delay=3",
"protocol": "https",
Expand Down
2 changes: 1 addition & 1 deletion src/NBomber.Converter/HAR/HarScenarioTemplate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class HelloWorldExample
var step{{ forloop.index }} = await Step.Run("step {{ forloop.index }} - {{ entry.Request.ActionName }}", context, async () =>
{
var request = Http.CreateRequest("{{ entry.Request.Method }}", "{{ entry.Request.Url }}")
{% for header in entry.Request.Headers -%}
{%- for header in entry.Request.Headers -%}
{%- unless header.Name contains ":" or header.Name == "content-length" %}
.WithHeader("{{ header.Name }}", "{{ header.Value | replace: '\"', '\\\"' }}"){% if forloop.last -%};
{% endif -%}
Expand Down
18 changes: 18 additions & 0 deletions src/NBomber.Converter/NBomber.Converter.sln
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ VisualStudioVersion = 17.5.2.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NBomber.Converter", "NBomber.Converter.csproj", "{1F7F69E0-CA18-9649-3E70-03512122665B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NBomber.Converter.Tests", "..\..\tests\NBomber.Converter.Tests\NBomber.Converter.Tests.csproj", "{0409E802-396C-6A4B-983A-DD080AACF4F0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NBomber.Converter.Tool", "..\NBomber.Converter.Tool\NBomber.Converter.Tool.csproj", "{3E8D4BB2-1659-B664-AEB4-05C96EFFC3DE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo", "..\..\examples\Demo\Demo.csproj", "{DA223B8A-C087-E6A4-8206-61E06BA41B45}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -14,6 +20,18 @@ Global
{1F7F69E0-CA18-9649-3E70-03512122665B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F7F69E0-CA18-9649-3E70-03512122665B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F7F69E0-CA18-9649-3E70-03512122665B}.Release|Any CPU.Build.0 = Release|Any CPU
{0409E802-396C-6A4B-983A-DD080AACF4F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0409E802-396C-6A4B-983A-DD080AACF4F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0409E802-396C-6A4B-983A-DD080AACF4F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0409E802-396C-6A4B-983A-DD080AACF4F0}.Release|Any CPU.Build.0 = Release|Any CPU
{3E8D4BB2-1659-B664-AEB4-05C96EFFC3DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3E8D4BB2-1659-B664-AEB4-05C96EFFC3DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E8D4BB2-1659-B664-AEB4-05C96EFFC3DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E8D4BB2-1659-B664-AEB4-05C96EFFC3DE}.Release|Any CPU.Build.0 = Release|Any CPU
{DA223B8A-C087-E6A4-8206-61E06BA41B45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA223B8A-C087-E6A4-8206-61E06BA41B45}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA223B8A-C087-E6A4-8206-61E06BA41B45}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA223B8A-C087-E6A4-8206-61E06BA41B45}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
16 changes: 14 additions & 2 deletions src/NBomber.Converter/Postman/Contracts/PostmanCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public Request Request { get; set; }

[JsonPropertyName("response")]
public List<Response> Responses { get; set; } // Response object
public List<Response> Responses { get; set; }
}

public class Request
Expand All @@ -42,7 +42,7 @@
public string Method { get; set; }

[JsonPropertyName("header")]
public List<(string, string)> Headers { get; set; }
public List<Header> Headers { get; set; }

[JsonPropertyName("url")]
public JsonNode Url { get; set; }
Expand All @@ -51,6 +51,18 @@
public Body Body { get; set; }
}

public class Header
{
[JsonPropertyName("key")]
public string Key { get; set; }

[JsonPropertyName("value")]
public string Value { get; set; }

[JsonPropertyName("type")]
public string Type { get; set; }
}

public class Url
{
[JsonPropertyName("raw")]
Expand Down Expand Up @@ -97,13 +109,13 @@
public class Response
{
[JsonPropertyName("status")]
public string Status { get; set; }

Check warning on line 112 in src/NBomber.Converter/Postman/Contracts/PostmanCollection.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Status' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

[JsonPropertyName("code")]
public int Code { get; set; }

[JsonPropertyName("body")]
public string Body { get; set; }

Check warning on line 118 in src/NBomber.Converter/Postman/Contracts/PostmanCollection.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Body' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

[JsonPropertyName("headers")]
public List<(string, string)> Headers { get; set; }

Check warning on line 121 in src/NBomber.Converter/Postman/Contracts/PostmanCollection.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Headers' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
Expand Down
6 changes: 2 additions & 4 deletions src/NBomber.Converter/Postman/PostmanScenarioTemplate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ public class HelloWorldPostmanExample
var request = Http.CreateRequest("{{ item.Request.Method }}", "{{ item.Request.PlainUrl }}")
{%- if item.Request.Headers.size == 0 -%};{%- endif -%}
{% for header in item.Request.Headers -%}
{% unless header.Key contains ":" or header.Key == "content-length" -%}
.WithHeader("{{ header.Item1 }}", "{{ header.Item2 | replace: '\"', '\\\"' }}")
{% if forloop.last -%}
.WithHeader("{{ header.Item1 }}", "{{ header.Item2 | replace: '\"', '\\\"' }}");
{%- unless header.Key contains ":" or header.Key == "content-length" %}
.WithHeader("{{ header.Key }}", "{{ header.Value | replace: '\"', '\\\"' }}"){% if forloop.last -%};
{% endif -%}
{% endunless -%}
{% else -%}
Expand Down
Loading
Loading