-
-
Notifications
You must be signed in to change notification settings - Fork 132
CLI: Add webfinger command using Optique #401
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
Merged
Changes from 12 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
624631e
Added Webfinger CLI
2chanhaeng d8f6732
Added cspell words
2chanhaeng 66c00f1
Added test for Webfinger CLI
2chanhaeng fecb60e
Added test for Webfinger CLI
2chanhaeng 4c3b85c
Added test for Webfinger CLI
2chanhaeng 8c10492
Merge branch 'optique/webfinger' of https://github.com/2chanhaeng/fed…
2chanhaeng 88bbbce
Revert "Added test for Webfinger CLI"
2chanhaeng 72e32dd
Merge branch 'next' of https://github.com/fedify-dev/fedify into next
2chanhaeng 4751840
Merge branch 'next' into optique/webfinger
2chanhaeng ffa6dee
Separated functions
2chanhaeng fffc0f6
Added _ prefix to unused var
2chanhaeng 53c844e
Added debug options to test
2chanhaeng 48c0f5f
Fixed test
2chanhaeng 59b7db1
Modularized webfinger
2chanhaeng 9bdf7b8
Modularized webfinger and separated code
2chanhaeng ee3f747
Applied @optique/core/message
2chanhaeng ede5d07
Fixed error message
2chanhaeng 78a82f4
Merge branch 'next' into optique/webfinger
2chanhaeng 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
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,85 @@ | ||
| import { lookupWebFinger } from "@fedify/fedify/webfinger"; | ||
| import { run } from "@optique/run"; | ||
|
dahlia marked this conversation as resolved.
Outdated
|
||
| import { assertEquals, assertStrictEquals, assertThrows } from "@std/assert"; | ||
| import test from "node:test"; | ||
| import { convertHandleToUrl, webFingerCommand } from "./webfinger.ts"; | ||
|
|
||
| const COMMAND = "webfinger"; | ||
| const RESOURCES = ["@hongminhee@hackers.pub", "@fedify@hollo.social"]; | ||
| const USER_AGENT = "MyUserAgent/1.0"; | ||
| const ALIASES = [ | ||
| "https://hackers.pub/ap/actors/019382d3-63d7-7cf7-86e8-91e2551c306c", | ||
| "https://hollo.social/@fedify", | ||
| ]; | ||
|
|
||
| test("webFingerCommand", () => { | ||
| // Resources only | ||
| const argsWithResourcesOnly = [COMMAND, ...RESOURCES]; | ||
| assertEquals( | ||
| run(webFingerCommand, { | ||
| args: argsWithResourcesOnly, | ||
| }), | ||
| { | ||
| debug: false, | ||
| command: COMMAND, | ||
| resources: RESOURCES, | ||
| allowPrivateAddresses: undefined, | ||
| maxRedirection: 5, | ||
| userAgent: undefined, | ||
| }, | ||
| ); | ||
| // With options | ||
| const maxRedirection = 10; | ||
| assertStrictEquals( | ||
| run(webFingerCommand, { | ||
| args: [ | ||
| ...argsWithResourcesOnly, | ||
| "-u", | ||
| USER_AGENT, | ||
| "--max-redirection", | ||
| String(maxRedirection), | ||
| "--allow-private-addresses", | ||
| ], | ||
| }), | ||
| { | ||
| command: COMMAND, | ||
| resources: RESOURCES, | ||
| allowPrivateAddresses: true, | ||
| maxRedirection, | ||
| userAgent: USER_AGENT, | ||
| }, | ||
| ); | ||
| // Wrong option | ||
| assertThrows(() => | ||
| run( | ||
| webFingerCommand, | ||
| { | ||
| args: [ | ||
| ...argsWithResourcesOnly, | ||
| "-Q", | ||
| ], | ||
| }, | ||
| ) | ||
| ); | ||
| // Wrong option value | ||
| assertThrows(() => | ||
| run( | ||
| webFingerCommand, | ||
| { | ||
| args: [ | ||
| ...argsWithResourcesOnly, | ||
| "--max-redirection", | ||
| "-10", | ||
| ], | ||
| }, | ||
| ) | ||
| ); | ||
| }); | ||
|
|
||
| test("Lookup webfinger", async () => { | ||
| const aliases = (await Array.fromAsync( | ||
| RESOURCES.map(convertHandleToUrl), | ||
| (h) => lookupWebFinger(h), | ||
| )).map((w) => w?.aliases?.[0]); | ||
| assertStrictEquals(aliases, ALIASES); | ||
| }); | ||
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
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.