-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from danielemery/19-add-an-endpoint-for-sharin…
…g-known_hosts Add an endpoint for sharing known hosts
- Loading branch information
Showing
15 changed files
with
386 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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 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 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,7 @@ | ||
ssh-keys: | ||
- name: key-one | ||
key: "ssh-rsa my-key-one" | ||
user: joeblogs | ||
known-hosts: | ||
- name: example | ||
hosts: hello, error |
This file contains 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,14 @@ | ||
ssh-keys: | ||
- name: key-one | ||
key: "ssh-rsa my-key-one" | ||
user: joeblogs | ||
known-hosts: | ||
- name: example | ||
hosts: | ||
- example.com | ||
keys: | ||
- type: ssh-ed25519 | ||
key: "fake-ed25519-key" | ||
comment: An example key | ||
- type: ssh-rsa | ||
key: "fake rsa key" |
This file contains 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 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 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 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 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,101 @@ | ||
import { assertEquals } from "https://deno.land/[email protected]/assert/mod.ts"; | ||
import { serveKnownHosts } from "./serve-known-hosts.ts"; | ||
import { emptyDependencies } from "../../common/test_helpers.ts"; | ||
|
||
Deno.test("serveKnownHosts (plain): must serve empty string if there are no dependencies", async () => { | ||
const actual = serveKnownHosts("unit-tests", { | ||
...emptyDependencies, | ||
}, "text/plain"); | ||
assertEquals(actual.status, 200); | ||
assertEquals(actual.statusText, "OK"); | ||
assertEquals(await actual.text(), ""); | ||
}); | ||
|
||
Deno.test("serveKnownHosts (plain): must serve known hosts", async () => { | ||
const knownHosts = [ | ||
{ | ||
name: "host1", | ||
hosts: ["host1.com", "host2.com"], | ||
keys: [ | ||
{ | ||
type: "ssh-rsa", | ||
key: "key1", | ||
comment: "comment1", | ||
revoked: false, | ||
"cert-authority": false, | ||
}, | ||
{ | ||
type: "ssh-rsa", | ||
key: "key2", | ||
revoked: false, | ||
"cert-authority": false, | ||
}, | ||
], | ||
}, | ||
{ | ||
name: "host2", | ||
hosts: ["host3.com"], | ||
keys: [ | ||
{ | ||
type: "ssh-rsa", | ||
key: "key3", | ||
revoked: false, | ||
"cert-authority": false, | ||
}, | ||
], | ||
}, | ||
]; | ||
const actual = serveKnownHosts("unit-tests", { | ||
...emptyDependencies, | ||
knownHosts, | ||
}, "text/plain"); | ||
assertEquals(actual.status, 200); | ||
assertEquals(actual.statusText, "OK"); | ||
assertEquals( | ||
await actual.text(), | ||
`host1.com,host2.com ssh-rsa key1 comment1 | ||
host1.com,host2.com ssh-rsa key2 | ||
host3.com ssh-rsa key3`, | ||
); | ||
}); | ||
|
||
Deno.test("serveKnownHosts (plain): must serve known hosts with markers", async () => { | ||
const knownHosts = [ | ||
{ | ||
name: "host1", | ||
hosts: ["host1.com"], | ||
keys: [ | ||
{ | ||
type: "ssh-rsa", | ||
key: "key1", | ||
revoked: false, | ||
"cert-authority": true, | ||
}, | ||
{ | ||
type: "ssh-rsa", | ||
key: "key2", | ||
revoked: true, | ||
"cert-authority": false, | ||
comment: "revoked 2024-09-11", | ||
}, | ||
], | ||
}, | ||
]; | ||
const actual = serveKnownHosts("unit-tests", { | ||
...emptyDependencies, | ||
knownHosts, | ||
}, "text/plain"); | ||
assertEquals(actual.status, 200); | ||
assertEquals(actual.statusText, "OK"); | ||
assertEquals( | ||
await actual.text(), | ||
`@cert-authority host1.com ssh-rsa key1 | ||
@revoked host1.com ssh-rsa key2 revoked 2024-09-11`, | ||
); | ||
}); | ||
|
||
Deno.test("serveKnownHosts (plain): must return NotAcceptable for unsupported content type", () => { | ||
const actual = serveKnownHosts("unit-tests", emptyDependencies, "text/html"); | ||
assertEquals(actual.status, 406); | ||
assertEquals(actual.statusText, "Not Acceptable"); | ||
}); |
Oops, something went wrong.