-
-
Notifications
You must be signed in to change notification settings - Fork 150
feat: add ability to pass certs #519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
boltlessengineer
merged 11 commits into
rest-nvim:main
from
NigelGreenway:feature/Adds-ability-to-add-certificates-to-env-files
Feb 13, 2025
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
bcfc8b3
feat: add ability to pass certs
6ef40b4
fix: removes extra single quotes
b5dbc90
mod: update types
ee14950
docs: add cert docs
2ed4a7c
fix(style): run formatter on code
536ddbf
mod: correct types
3023d63
tests: add cert test
8f19b61
syle: revert changes
ac3ceed
doc: remove incorrect config info
a68931e
style: remove new lines
2391c88
chore: minor fixes
boltlessengineer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -179,6 +179,20 @@ function builder.extras(req) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| vim.list_extend(args, { "--compressed" }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for domain, _ in pairs(config.clients.curl.opts.certificates) do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local target = req.url | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -- TODO(boltless): this is temporary solution. use same logic from cookie_jar instead | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| local s, _ = string.find(target, domain, 1, true) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already have domain matching functionality in rest.nvim/lua/rest-nvim/cookie_jar.lua Lines 172 to 199 in 404a262
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if s ~= nil then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| vim.list_extend(args, { "--cert", config.clients.curl.opts.certificates[domain].set_certificate_crt }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| vim.list_extend(args, { "--key", config.clients.curl.opts.certificates[domain].set_certificate_key }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return args | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,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) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.