forked from rest-nvim/rest.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli_with_certs_spec.lua
More file actions
50 lines (45 loc) · 1.26 KB
/
cli_with_certs_spec.lua
File metadata and controls
50 lines (45 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---@diagnostic disable: invisible
---@module 'luassert'
require("spec.minimal_init")
vim.g.rest_nvim = vim.tbl_deep_extend("force", {
clients = {
curl = {
opts = {
certificates = {
["localhost"] = {
set_certificate_crt = "./my.cert",
set_certificate_key = "./my.key",
},
},
},
},
},
}, vim.g.rest_nvim)
local Context = require("rest-nvim.context").Context
local curl = require("rest-nvim.client.curl.cli")
local builder = curl.builder
local STAT_FORMAT = builder.STAT_ARGS[2]
require("rest-nvim.client.curl.cli").config = vim.g.rest_nvim
describe("Curl cli builder", function()
it("with opts.certificates", function()
local args = builder.build({
context = Context:new(),
method = "POST",
url = "http://localhost:8000",
headers = {},
cookies = {},
handlers = {},
})
assert.same({
"http://localhost:8000",
"--cert",
"./my.cert",
"--key",
"./my.key",
"-X",
"POST",
"-w",
STAT_FORMAT,
}, args)
end)
end)