snapshot of https://github.com/mountain-loop/yaak.git (main, 2026-09-23; blobs > 131072B omitted)
This commit is contained in:
1032
plugins/importer-postman/tests/fixtures/auth.input.json
vendored
Normal file
1032
plugins/importer-postman/tests/fixtures/auth.input.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
421
plugins/importer-postman/tests/fixtures/auth.output.json
vendored
Normal file
421
plugins/importer-postman/tests/fixtures/auth.output.json
vendored
Normal file
@@ -0,0 +1,421 @@
|
||||
{
|
||||
"resources": {
|
||||
"workspaces": [
|
||||
{
|
||||
"model": "workspace",
|
||||
"id": "GENERATE_ID::WORKSPACE_0",
|
||||
"name": "Authentication",
|
||||
"authenticationType": "basic",
|
||||
"authentication": {
|
||||
"username": "workspace",
|
||||
"password": "workspace_secret"
|
||||
}
|
||||
}
|
||||
],
|
||||
"environments": [
|
||||
{
|
||||
"model": "environment",
|
||||
"id": "GENERATE_ID::ENVIRONMENT_0",
|
||||
"name": "Global Variables",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"parentModel": "workspace",
|
||||
"parentId": null,
|
||||
"variables": [
|
||||
{
|
||||
"name": "COLLECTION VARIABLE",
|
||||
"value": "collection variable"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"httpRequests": [
|
||||
{
|
||||
"model": "http_request",
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_0",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"folderId": null,
|
||||
"name": "No Auth",
|
||||
"method": "GET",
|
||||
"url": "https://yaak.app/x/echo",
|
||||
"urlParameters": [],
|
||||
"body": {},
|
||||
"bodyType": null,
|
||||
"sortPriority": 0,
|
||||
"headers": [],
|
||||
"authenticationType": "none",
|
||||
"authentication": {}
|
||||
},
|
||||
{
|
||||
"model": "http_request",
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_1",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"folderId": null,
|
||||
"name": "Inherit",
|
||||
"method": "GET",
|
||||
"url": "https://yaak.app/x/echo",
|
||||
"urlParameters": [],
|
||||
"body": {},
|
||||
"bodyType": null,
|
||||
"sortPriority": 1,
|
||||
"headers": [],
|
||||
"authenticationType": null,
|
||||
"authentication": {}
|
||||
},
|
||||
{
|
||||
"model": "http_request",
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_2",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"folderId": null,
|
||||
"name": "OAuth 2 Auth Code",
|
||||
"method": "GET",
|
||||
"url": "${[hello]}",
|
||||
"urlParameters": [],
|
||||
"body": {
|
||||
"text": "{\n \"hello\": \"world\"\n}"
|
||||
},
|
||||
"bodyType": "application/json",
|
||||
"sortPriority": 2,
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"enabled": true
|
||||
}
|
||||
],
|
||||
"authenticationType": "oauth2",
|
||||
"authentication": {
|
||||
"name": "oauth2",
|
||||
"grantType": "authorization_code",
|
||||
"clientId": "cliend id",
|
||||
"headerPrefix": "Bearer",
|
||||
"scope": "scope",
|
||||
"clientSecret": "clientsecet",
|
||||
"authorizationUrl": "https://github.com/login/oauth/authorize",
|
||||
"accessTokenUrl": "https://github.com/login/oauth/access_token",
|
||||
"redirectUri": "https://callback",
|
||||
"state": "state"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "http_request",
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_3",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"folderId": null,
|
||||
"name": "OAuth 2 Auth Code (PKCE)",
|
||||
"method": "GET",
|
||||
"url": "${[hello]}",
|
||||
"urlParameters": [],
|
||||
"body": {
|
||||
"text": "{\n \"hello\": \"world\"\n}"
|
||||
},
|
||||
"bodyType": "application/json",
|
||||
"sortPriority": 3,
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"enabled": true
|
||||
}
|
||||
],
|
||||
"authenticationType": "oauth2",
|
||||
"authentication": {
|
||||
"name": "oauth2",
|
||||
"grantType": "authorization_code",
|
||||
"clientId": "cliend id",
|
||||
"headerPrefix": "Bearer",
|
||||
"scope": "scope",
|
||||
"clientSecret": "clientsecet",
|
||||
"authorizationUrl": "https://github.com/login/oauth/authorize",
|
||||
"accessTokenUrl": "https://github.com/login/oauth/access_token",
|
||||
"redirectUri": "https://callback",
|
||||
"state": "state",
|
||||
"usePkce": true,
|
||||
"pkceChallengeMethod": "S256",
|
||||
"pkceCodeVerifier": "verifier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "http_request",
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_4",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"folderId": null,
|
||||
"name": "OAuth 2 Implicit",
|
||||
"method": "GET",
|
||||
"url": "${[hello]}",
|
||||
"urlParameters": [],
|
||||
"body": {
|
||||
"text": "{\n \"hello\": \"world\"\n}"
|
||||
},
|
||||
"bodyType": "application/json",
|
||||
"sortPriority": 4,
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"enabled": true
|
||||
}
|
||||
],
|
||||
"authenticationType": "oauth2",
|
||||
"authentication": {
|
||||
"name": "oauth2",
|
||||
"grantType": "implicit",
|
||||
"clientId": "cliend id",
|
||||
"headerPrefix": "Bearer",
|
||||
"scope": "scope",
|
||||
"authorizationUrl": "https://github.com/login/oauth/authorize",
|
||||
"redirectUri": "https://yaak.app/x/echo",
|
||||
"state": "state"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "http_request",
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_5",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"folderId": null,
|
||||
"name": "OAuth 2 Password",
|
||||
"method": "GET",
|
||||
"url": "${[hello]}",
|
||||
"urlParameters": [],
|
||||
"body": {
|
||||
"text": "{\n \"hello\": \"world\"\n}"
|
||||
},
|
||||
"bodyType": "application/json",
|
||||
"sortPriority": 5,
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"enabled": true
|
||||
}
|
||||
],
|
||||
"authenticationType": "oauth2",
|
||||
"authentication": {
|
||||
"name": "oauth2",
|
||||
"grantType": "password",
|
||||
"clientId": "clientid",
|
||||
"headerPrefix": "Bearer",
|
||||
"scope": "scope",
|
||||
"clientSecret": "clientsecret",
|
||||
"accessTokenUrl": "https://github.com/login/oauth/access_token",
|
||||
"username": "username",
|
||||
"password": "password"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "http_request",
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_6",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"folderId": null,
|
||||
"name": "OAuth 2 Client Credentials",
|
||||
"method": "GET",
|
||||
"url": "${[hello]}",
|
||||
"urlParameters": [],
|
||||
"body": {
|
||||
"text": "{\n \"hello\": \"world\"\n}"
|
||||
},
|
||||
"bodyType": "application/json",
|
||||
"sortPriority": 6,
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"enabled": true
|
||||
}
|
||||
],
|
||||
"authenticationType": "oauth2",
|
||||
"authentication": {
|
||||
"name": "oauth2",
|
||||
"grantType": "client_credentials",
|
||||
"clientId": "clientid",
|
||||
"headerPrefix": "Bearer",
|
||||
"scope": "scope",
|
||||
"clientSecret": "clientsecret",
|
||||
"accessTokenUrl": "https://github.com/login/oauth/access_token"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "http_request",
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_7",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"folderId": null,
|
||||
"name": "AWS V4",
|
||||
"method": "GET",
|
||||
"url": "https://yaak.app/x/echo",
|
||||
"urlParameters": [],
|
||||
"body": {},
|
||||
"bodyType": null,
|
||||
"sortPriority": 7,
|
||||
"headers": [],
|
||||
"authenticationType": "awsv4",
|
||||
"authentication": {
|
||||
"accessKeyId": "access",
|
||||
"secretAccessKey": "secret",
|
||||
"sessionToken": "session",
|
||||
"region": "us-west-1",
|
||||
"service": "s3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "http_request",
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_8",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"folderId": null,
|
||||
"name": "API Key",
|
||||
"method": "GET",
|
||||
"url": "https://yaak.app/x/echo",
|
||||
"urlParameters": [],
|
||||
"body": {},
|
||||
"bodyType": null,
|
||||
"sortPriority": 8,
|
||||
"headers": [],
|
||||
"authenticationType": "apikey",
|
||||
"authentication": {
|
||||
"location": "query",
|
||||
"key": "X-API-Key",
|
||||
"value": "secret-123"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "http_request",
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_9",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"folderId": null,
|
||||
"name": "JWT",
|
||||
"method": "GET",
|
||||
"url": "https://yaak.app/x/echo",
|
||||
"urlParameters": [],
|
||||
"body": {},
|
||||
"bodyType": null,
|
||||
"sortPriority": 9,
|
||||
"headers": [],
|
||||
"authenticationType": "jwt",
|
||||
"authentication": {
|
||||
"algorithm": "HS384",
|
||||
"secret": "mysecret",
|
||||
"secretBase64": false,
|
||||
"payload": "{\n \"my\": \"payload\"\n}",
|
||||
"headerPrefix": "Bearer",
|
||||
"location": "header"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "http_request",
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_10",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"folderId": null,
|
||||
"name": "Digest",
|
||||
"method": "GET",
|
||||
"url": "https://yaak.app/x/echo",
|
||||
"urlParameters": [],
|
||||
"body": {},
|
||||
"bodyType": null,
|
||||
"sortPriority": 10,
|
||||
"headers": [],
|
||||
"authenticationType": "digest",
|
||||
"authentication": {
|
||||
"username": "digest-user",
|
||||
"password": "digest-pass",
|
||||
"realm": "testrealm@yaak.app"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "http_request",
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_11",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"folderId": null,
|
||||
"name": "NTLM",
|
||||
"method": "GET",
|
||||
"url": "https://yaak.app/x/echo",
|
||||
"urlParameters": [],
|
||||
"body": {},
|
||||
"bodyType": null,
|
||||
"sortPriority": 11,
|
||||
"headers": [],
|
||||
"authenticationType": "windows",
|
||||
"authentication": {
|
||||
"username": "ntlm-user",
|
||||
"password": "ntlm-pass",
|
||||
"domain": "CORP",
|
||||
"workstation": "WORKSTATION-01"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "http_request",
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_12",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"folderId": null,
|
||||
"name": "OAuth 1",
|
||||
"method": "GET",
|
||||
"url": "https://yaak.app/x/echo",
|
||||
"urlParameters": [],
|
||||
"body": {},
|
||||
"bodyType": null,
|
||||
"sortPriority": 12,
|
||||
"headers": [],
|
||||
"authenticationType": "oauth1",
|
||||
"authentication": {
|
||||
"signatureMethod": "HMAC-SHA256",
|
||||
"consumerKey": "consumer-key",
|
||||
"consumerSecret": "consumer-secret",
|
||||
"tokenKey": "access-token",
|
||||
"tokenSecret": "token-secret",
|
||||
"callback": "https://yaak.app/x/callback",
|
||||
"verifier": "verifier-123",
|
||||
"timestamp": "1700000000",
|
||||
"nonce": "9e6dfada256c",
|
||||
"version": "1.0",
|
||||
"realm": "yaak.app"
|
||||
}
|
||||
},
|
||||
{
|
||||
"model": "http_request",
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_13",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"folderId": "GENERATE_ID::FOLDER_0",
|
||||
"name": "Folder Child Inherit",
|
||||
"method": "GET",
|
||||
"url": "https://yaak.app/x/echo",
|
||||
"urlParameters": [],
|
||||
"body": {},
|
||||
"bodyType": null,
|
||||
"sortPriority": 14,
|
||||
"headers": [],
|
||||
"authenticationType": null,
|
||||
"authentication": {}
|
||||
},
|
||||
{
|
||||
"model": "http_request",
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_14",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"folderId": "GENERATE_ID::FOLDER_0",
|
||||
"name": "Folder Child No Auth",
|
||||
"method": "GET",
|
||||
"url": "https://yaak.app/x/echo",
|
||||
"urlParameters": [],
|
||||
"body": {},
|
||||
"bodyType": null,
|
||||
"sortPriority": 15,
|
||||
"headers": [],
|
||||
"authenticationType": "none",
|
||||
"authentication": {}
|
||||
}
|
||||
],
|
||||
"folders": [
|
||||
{
|
||||
"model": "folder",
|
||||
"sortPriority": 13,
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"id": "GENERATE_ID::FOLDER_0",
|
||||
"name": "Folder With Auth",
|
||||
"folderId": null,
|
||||
"authenticationType": "bearer",
|
||||
"authentication": {
|
||||
"token": "folder-token"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"sourceKeys": {
|
||||
"GENERATE_ID::WORKSPACE_0": "collection:9e6dfada-256c-49ea-a38f-7d1b05b7ca2d"
|
||||
}
|
||||
}
|
||||
67
plugins/importer-postman/tests/fixtures/dynamic-variables.input.json
vendored
Normal file
67
plugins/importer-postman/tests/fixtures/dynamic-variables.input.json
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
{
|
||||
"info": {
|
||||
"_postman_id": "5c0ffee0-dyn0-4var-9abc-000000000001",
|
||||
"name": "Dynamic Variables",
|
||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
||||
},
|
||||
"item": [
|
||||
{
|
||||
"name": "Dynamic Variables",
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "X-Request-Id",
|
||||
"value": "{{$guid}}"
|
||||
},
|
||||
{
|
||||
"key": "X-Correlation-Id",
|
||||
"value": "{{$randomUUID}}"
|
||||
},
|
||||
{
|
||||
"key": "X-Sent-At",
|
||||
"value": "{{$timestamp}}"
|
||||
},
|
||||
{
|
||||
"key": "X-Sent-At-Iso",
|
||||
"value": "{{$isoTimestamp}}"
|
||||
},
|
||||
{
|
||||
"key": "X-Spaced",
|
||||
"value": "{{ $guid }}"
|
||||
},
|
||||
{
|
||||
"key": "X-Faker",
|
||||
"value": "{{$randomFirstName}}"
|
||||
},
|
||||
{
|
||||
"key": "X-Plain",
|
||||
"value": "{{base_url}}"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "https://yaak.app/x/echo?n={{$randomInt}}",
|
||||
"protocol": "https",
|
||||
"host": ["yaak", "app"],
|
||||
"path": ["x", "echo"],
|
||||
"query": [
|
||||
{
|
||||
"key": "n",
|
||||
"value": "{{$randomInt}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"id\": \"{{$guid}}\",\n \"at\": {{$timestamp}},\n \"mixed\": \"{{$guid}}/{{base_url}}\"\n}",
|
||||
"options": {
|
||||
"raw": {
|
||||
"language": "json"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
}
|
||||
95
plugins/importer-postman/tests/fixtures/dynamic-variables.output.json
vendored
Normal file
95
plugins/importer-postman/tests/fixtures/dynamic-variables.output.json
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
{
|
||||
"resources": {
|
||||
"workspaces": [
|
||||
{
|
||||
"model": "workspace",
|
||||
"id": "GENERATE_ID::WORKSPACE_1",
|
||||
"name": "Dynamic Variables",
|
||||
"authenticationType": null,
|
||||
"authentication": {}
|
||||
}
|
||||
],
|
||||
"environments": [
|
||||
{
|
||||
"model": "environment",
|
||||
"id": "GENERATE_ID::ENVIRONMENT_1",
|
||||
"name": "Global Variables",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_1",
|
||||
"parentModel": "workspace",
|
||||
"parentId": null,
|
||||
"variables": []
|
||||
}
|
||||
],
|
||||
"httpRequests": [
|
||||
{
|
||||
"model": "http_request",
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_15",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_1",
|
||||
"folderId": null,
|
||||
"name": "Dynamic Variables",
|
||||
"method": "POST",
|
||||
"url": "https://yaak.app/x/echo",
|
||||
"urlParameters": [
|
||||
{
|
||||
"name": "n",
|
||||
"value": "${[random.range(min='0',max='1000',decimals='0')]}",
|
||||
"enabled": true
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"text": "{\n \"id\": \"${[uuid.v4()]}\",\n \"at\": ${[timestamp.unix()]},\n \"mixed\": \"${[uuid.v4()]}/${[base_url]}\"\n}"
|
||||
},
|
||||
"bodyType": "application/json",
|
||||
"sortPriority": 0,
|
||||
"headers": [
|
||||
{
|
||||
"name": "X-Request-Id",
|
||||
"value": "${[uuid.v4()]}",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "X-Correlation-Id",
|
||||
"value": "${[uuid.v4()]}",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "X-Sent-At",
|
||||
"value": "${[timestamp.unix()]}",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "X-Sent-At-Iso",
|
||||
"value": "${[timestamp.iso8601()]}",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "X-Spaced",
|
||||
"value": "${[uuid.v4()]}",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "X-Faker",
|
||||
"value": "${[$randomFirstName]}",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "X-Plain",
|
||||
"value": "${[base_url]}",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json",
|
||||
"enabled": true
|
||||
}
|
||||
],
|
||||
"authenticationType": null,
|
||||
"authentication": {}
|
||||
}
|
||||
],
|
||||
"folders": []
|
||||
},
|
||||
"sourceKeys": {
|
||||
"GENERATE_ID::WORKSPACE_1": "collection:5c0ffee0-dyn0-4var-9abc-000000000001"
|
||||
}
|
||||
}
|
||||
38
plugins/importer-postman/tests/fixtures/nested.input.json
vendored
Normal file
38
plugins/importer-postman/tests/fixtures/nested.input.json
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"info": {
|
||||
"_postman_id": "9e6dfada-256c-49ea-a38f-7d1b05b7ca2d",
|
||||
"name": "New Collection",
|
||||
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json",
|
||||
"_exporter_id": "18798"
|
||||
},
|
||||
"item": [
|
||||
{
|
||||
"name": "Top Folder",
|
||||
"item": [
|
||||
{
|
||||
"name": "Nested Folder",
|
||||
"item": [
|
||||
{
|
||||
"name": "Request 1",
|
||||
"request": {
|
||||
"method": "GET"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Request 2",
|
||||
"request": {
|
||||
"method": "GET"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Request 3",
|
||||
"request": {
|
||||
"method": "GET"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
99
plugins/importer-postman/tests/fixtures/nested.output.json
vendored
Normal file
99
plugins/importer-postman/tests/fixtures/nested.output.json
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
{
|
||||
"resources": {
|
||||
"workspaces": [
|
||||
{
|
||||
"model": "workspace",
|
||||
"id": "GENERATE_ID::WORKSPACE_2",
|
||||
"name": "New Collection",
|
||||
"authenticationType": null,
|
||||
"authentication": {}
|
||||
}
|
||||
],
|
||||
"environments": [
|
||||
{
|
||||
"model": "environment",
|
||||
"id": "GENERATE_ID::ENVIRONMENT_2",
|
||||
"name": "Global Variables",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_2",
|
||||
"parentModel": "workspace",
|
||||
"parentId": null,
|
||||
"variables": []
|
||||
}
|
||||
],
|
||||
"httpRequests": [
|
||||
{
|
||||
"model": "http_request",
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_16",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_2",
|
||||
"folderId": "GENERATE_ID::FOLDER_2",
|
||||
"name": "Request 1",
|
||||
"method": "GET",
|
||||
"url": "",
|
||||
"urlParameters": [],
|
||||
"body": {},
|
||||
"bodyType": null,
|
||||
"sortPriority": 2,
|
||||
"headers": [],
|
||||
"authenticationType": null,
|
||||
"authentication": {}
|
||||
},
|
||||
{
|
||||
"model": "http_request",
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_17",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_2",
|
||||
"folderId": "GENERATE_ID::FOLDER_1",
|
||||
"name": "Request 2",
|
||||
"method": "GET",
|
||||
"url": "",
|
||||
"urlParameters": [],
|
||||
"body": {},
|
||||
"bodyType": null,
|
||||
"sortPriority": 3,
|
||||
"headers": [],
|
||||
"authenticationType": null,
|
||||
"authentication": {}
|
||||
},
|
||||
{
|
||||
"model": "http_request",
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_18",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_2",
|
||||
"folderId": null,
|
||||
"name": "Request 3",
|
||||
"method": "GET",
|
||||
"url": "",
|
||||
"urlParameters": [],
|
||||
"body": {},
|
||||
"bodyType": null,
|
||||
"sortPriority": 4,
|
||||
"headers": [],
|
||||
"authenticationType": null,
|
||||
"authentication": {}
|
||||
}
|
||||
],
|
||||
"folders": [
|
||||
{
|
||||
"model": "folder",
|
||||
"sortPriority": 0,
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_2",
|
||||
"id": "GENERATE_ID::FOLDER_1",
|
||||
"name": "Top Folder",
|
||||
"folderId": null,
|
||||
"authenticationType": null,
|
||||
"authentication": {}
|
||||
},
|
||||
{
|
||||
"model": "folder",
|
||||
"sortPriority": 1,
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_2",
|
||||
"id": "GENERATE_ID::FOLDER_2",
|
||||
"name": "Nested Folder",
|
||||
"folderId": "GENERATE_ID::FOLDER_1",
|
||||
"authenticationType": null,
|
||||
"authentication": {}
|
||||
}
|
||||
]
|
||||
},
|
||||
"sourceKeys": {
|
||||
"GENERATE_ID::WORKSPACE_2": "collection:9e6dfada-256c-49ea-a38f-7d1b05b7ca2d"
|
||||
}
|
||||
}
|
||||
126
plugins/importer-postman/tests/fixtures/params.input.json
vendored
Normal file
126
plugins/importer-postman/tests/fixtures/params.input.json
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
{
|
||||
"info": {
|
||||
"_postman_id": "9e6dfada-256c-49ea-a38f-7d1b05b7ca2d",
|
||||
"name": "New Collection",
|
||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
|
||||
"_exporter_id": "18798"
|
||||
},
|
||||
"item": [
|
||||
{
|
||||
"name": "Form URL",
|
||||
"request": {
|
||||
"auth": {
|
||||
"type": "bearer",
|
||||
"bearer": [
|
||||
{
|
||||
"key": "token",
|
||||
"value": "my-token",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "X-foo",
|
||||
"value": "bar",
|
||||
"description": "description"
|
||||
},
|
||||
{
|
||||
"key": "Disabled",
|
||||
"value": "tnroant",
|
||||
"description": "ntisorantosra",
|
||||
"disabled": true
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "formdata",
|
||||
"formdata": [
|
||||
{
|
||||
"key": "Key",
|
||||
"contentType": "Custom/COntent",
|
||||
"description": "DEscription",
|
||||
"type": "file",
|
||||
"src": "/Users/gschier/Desktop/Screenshot 2024-05-31 at 12.05.11 PM.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
"url": {
|
||||
"raw": "example.com/:foo/:bar?q=qqq&",
|
||||
"host": ["example", "com"],
|
||||
"path": [":foo", ":bar"],
|
||||
"query": [
|
||||
{
|
||||
"key": "disabled",
|
||||
"value": "secondvalue",
|
||||
"description": "this is disabled",
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"key": "q",
|
||||
"value": "qqq",
|
||||
"description": "hello"
|
||||
},
|
||||
{
|
||||
"key": "",
|
||||
"value": null
|
||||
}
|
||||
],
|
||||
"variable": [
|
||||
{
|
||||
"key": "foo",
|
||||
"value": "fff",
|
||||
"description": "Description"
|
||||
},
|
||||
{
|
||||
"key": "bar",
|
||||
"value": "bbb",
|
||||
"description": "bbb description"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
],
|
||||
"auth": {
|
||||
"type": "basic",
|
||||
"basic": [
|
||||
{
|
||||
"key": "password",
|
||||
"value": "globalpass",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"key": "username",
|
||||
"value": "globaluser",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"event": [
|
||||
{
|
||||
"listen": "prerequest",
|
||||
"script": {
|
||||
"type": "text/javascript",
|
||||
"packages": {},
|
||||
"exec": [""]
|
||||
}
|
||||
},
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"type": "text/javascript",
|
||||
"packages": {},
|
||||
"exec": [""]
|
||||
}
|
||||
}
|
||||
],
|
||||
"variable": [
|
||||
{
|
||||
"key": "COLLECTION VARIABLE",
|
||||
"value": "collection variable",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
107
plugins/importer-postman/tests/fixtures/params.output.json
vendored
Normal file
107
plugins/importer-postman/tests/fixtures/params.output.json
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
{
|
||||
"resources": {
|
||||
"workspaces": [
|
||||
{
|
||||
"model": "workspace",
|
||||
"id": "GENERATE_ID::WORKSPACE_3",
|
||||
"name": "New Collection",
|
||||
"authenticationType": "basic",
|
||||
"authentication": {
|
||||
"username": "globaluser",
|
||||
"password": "globalpass"
|
||||
}
|
||||
}
|
||||
],
|
||||
"environments": [
|
||||
{
|
||||
"model": "environment",
|
||||
"id": "GENERATE_ID::ENVIRONMENT_3",
|
||||
"name": "Global Variables",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_3",
|
||||
"parentModel": "workspace",
|
||||
"parentId": null,
|
||||
"variables": [
|
||||
{
|
||||
"name": "COLLECTION VARIABLE",
|
||||
"value": "collection variable"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"httpRequests": [
|
||||
{
|
||||
"model": "http_request",
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_19",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_3",
|
||||
"folderId": null,
|
||||
"name": "Form URL",
|
||||
"method": "POST",
|
||||
"url": "example.com/:foo/:bar",
|
||||
"urlParameters": [
|
||||
{
|
||||
"name": "disabled",
|
||||
"value": "secondvalue",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"name": "q",
|
||||
"value": "qqq",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"value": "",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": ":foo",
|
||||
"value": "fff",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": ":bar",
|
||||
"value": "bbb",
|
||||
"enabled": true
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"form": [
|
||||
{
|
||||
"enabled": true,
|
||||
"contentType": "Custom/COntent",
|
||||
"name": "Key",
|
||||
"file": "/Users/gschier/Desktop/Screenshot 2024-05-31 at 12.05.11 PM.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
"bodyType": "multipart/form-data",
|
||||
"sortPriority": 0,
|
||||
"headers": [
|
||||
{
|
||||
"name": "X-foo",
|
||||
"value": "bar",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "Disabled",
|
||||
"value": "tnroant",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "multipart/form-data",
|
||||
"enabled": true
|
||||
}
|
||||
],
|
||||
"authenticationType": "bearer",
|
||||
"authentication": {
|
||||
"token": "my-token"
|
||||
}
|
||||
}
|
||||
],
|
||||
"folders": []
|
||||
},
|
||||
"sourceKeys": {
|
||||
"GENERATE_ID::WORKSPACE_3": "collection:9e6dfada-256c-49ea-a38f-7d1b05b7ca2d"
|
||||
}
|
||||
}
|
||||
201
plugins/importer-postman/tests/index.test.ts
Normal file
201
plugins/importer-postman/tests/index.test.ts
Normal file
@@ -0,0 +1,201 @@
|
||||
import * as fs from "node:fs";
|
||||
import * as path from "node:path";
|
||||
import { describe, expect, test } from "vite-plus/test";
|
||||
import { convertPostman } from "../src";
|
||||
|
||||
describe("importer-postman", () => {
|
||||
const p = path.join(__dirname, "fixtures");
|
||||
const fixtures = fs.readdirSync(p);
|
||||
|
||||
for (const fixture of fixtures) {
|
||||
if (fixture.includes(".output")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
test(`Imports ${fixture}`, () => {
|
||||
const contents = fs.readFileSync(path.join(p, fixture), "utf-8");
|
||||
const expected = fs.readFileSync(path.join(p, fixture.replace(".input", ".output")), "utf-8");
|
||||
const result = convertPostman(contents);
|
||||
// console.log(JSON.stringify(result, null, 2))
|
||||
expect(JSON.stringify(result, null, 2)).toEqual(
|
||||
JSON.stringify(JSON.parse(expected), null, 2),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
test("Imports object descriptions without [object Object]", () => {
|
||||
const result = convertPostman(
|
||||
JSON.stringify({
|
||||
info: {
|
||||
name: "Description Test",
|
||||
schema: "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
|
||||
},
|
||||
item: [
|
||||
{
|
||||
name: "Request 1",
|
||||
request: {
|
||||
method: "GET",
|
||||
description: {
|
||||
content: "Lijst van klanten",
|
||||
type: "text/plain",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
|
||||
expect(result?.resources.workspaces).toEqual([
|
||||
expect.objectContaining({
|
||||
name: "Description Test",
|
||||
}),
|
||||
]);
|
||||
expect(result?.resources.httpRequests).toEqual([
|
||||
expect.objectContaining({
|
||||
name: "Request 1",
|
||||
description: "Lijst van klanten",
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
test("Imports url.path when it is a string instead of an array", () => {
|
||||
const result = convertPostman(
|
||||
JSON.stringify({
|
||||
info: {
|
||||
name: "String Path Test",
|
||||
schema: "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
|
||||
},
|
||||
item: [
|
||||
{
|
||||
name: "String Path",
|
||||
request: {
|
||||
method: "GET",
|
||||
url: {
|
||||
host: ["example", "com"],
|
||||
path: "foo/bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
|
||||
expect(result?.resources.httpRequests).toEqual([
|
||||
expect.objectContaining({
|
||||
name: "String Path",
|
||||
url: "example.com/foo/bar",
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
test("Keys items by their Postman ID, unchanged by a rename", () => {
|
||||
const collection = (requestName: string) =>
|
||||
JSON.stringify({
|
||||
info: {
|
||||
_postman_id: "collection-id",
|
||||
name: "Keys",
|
||||
schema: "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
|
||||
},
|
||||
item: [
|
||||
{
|
||||
id: "folder-id",
|
||||
name: "Folder",
|
||||
item: [
|
||||
{
|
||||
id: "request-id",
|
||||
name: requestName,
|
||||
request: { method: "GET", url: "https://yaak.app" },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const before = convertPostman(collection("Original"));
|
||||
const after = convertPostman(collection("Renamed"));
|
||||
|
||||
const keyOf = (result: ReturnType<typeof convertPostman>, id: string | undefined) =>
|
||||
id == null ? undefined : result?.sourceKeys?.[id];
|
||||
|
||||
expect(keyOf(before, before?.resources.httpRequests[0]?.id)).toBe("item:request-id");
|
||||
expect(keyOf(after, after?.resources.httpRequests[0]?.id)).toBe("item:request-id");
|
||||
expect(keyOf(before, before?.resources.folders[0]?.id)).toBe("item:folder-id");
|
||||
expect(keyOf(before, before?.resources.workspaces[0]?.id)).toBe("collection:collection-id");
|
||||
});
|
||||
|
||||
test("Falls back to the default OAuth 1 signature method for unrecognized ones", () => {
|
||||
const result = convertPostman(
|
||||
JSON.stringify({
|
||||
info: {
|
||||
name: "OAuth 1 Signature",
|
||||
schema: "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
|
||||
},
|
||||
item: [
|
||||
{
|
||||
name: "Request",
|
||||
request: {
|
||||
method: "GET",
|
||||
url: "https://yaak.app",
|
||||
auth: {
|
||||
type: "oauth1",
|
||||
oauth1: [{ key: "signatureMethod", value: "HMAC-SHA384" }],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
|
||||
expect(result?.resources.httpRequests).toEqual([
|
||||
expect.objectContaining({
|
||||
authenticationType: "oauth1",
|
||||
authentication: { signatureMethod: "HMAC-SHA1" },
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
test("Leaves {{constructor}} alone instead of reaching Object.prototype", () => {
|
||||
const result = convertPostman(
|
||||
JSON.stringify({
|
||||
info: {
|
||||
name: "Prototype Key",
|
||||
schema: "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
|
||||
},
|
||||
item: [
|
||||
{
|
||||
name: "Request",
|
||||
request: {
|
||||
method: "GET",
|
||||
url: "https://yaak.app",
|
||||
header: [
|
||||
{ key: "X-A", value: "{{constructor}}" },
|
||||
{ key: "X-B", value: "{{toString}}" },
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
|
||||
expect(result?.resources.httpRequests[0]?.headers).toEqual([
|
||||
{ name: "X-A", value: "${[constructor]}", enabled: true },
|
||||
{ name: "X-B", value: "${[toString]}", enabled: true },
|
||||
]);
|
||||
});
|
||||
|
||||
test("Omits keys for items the collection never identified", () => {
|
||||
const result = convertPostman(
|
||||
JSON.stringify({
|
||||
info: {
|
||||
name: "No IDs",
|
||||
schema: "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
|
||||
},
|
||||
item: [{ name: "Request", request: { method: "GET", url: "https://yaak.app" } }],
|
||||
}),
|
||||
);
|
||||
|
||||
const requestId = result?.resources.httpRequests[0]?.id;
|
||||
expect(requestId).toBeDefined();
|
||||
expect(result?.sourceKeys).not.toHaveProperty(requestId as string);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user