@@ -488,3 +488,63 @@ describe("auth scope options", () => {
488488 } ) ,
489489 ) ;
490490} ) ;
491+
492+ describe ( "auth pairing create --base-url" , ( ) => {
493+ it . effect . each ( [ "192.168.1.5:3773" , "localhost:3773" , "ftp://localhost:3773" ] ) (
494+ "rejects %s before issuing a token" ,
495+ ( baseUrl ) =>
496+ Effect . gen ( function * ( ) {
497+ const baseDir = NodeFS . mkdtempSync ( NodePath . join ( NodeOS . tmpdir ( ) , "t3-cli-base-url-test-" ) ) ;
498+ const error = yield * runCli ( [
499+ "auth" ,
500+ "pairing" ,
501+ "create" ,
502+ "--base-dir" ,
503+ baseDir ,
504+ "--base-url" ,
505+ baseUrl ,
506+ ] ) . pipe ( Effect . provide ( layerCliRuntime ) , Effect . flip ) ;
507+
508+ if ( ! CliError . isCliError ( error ) || error . _tag !== "ShowHelp" ) {
509+ assert . fail ( `Expected ShowHelp, got ${ String ( error ) } ` ) ;
510+ }
511+ const flagError = error . errors [ 0 ] ;
512+ if ( flagError ?. _tag !== "InvalidValue" ) {
513+ assert . fail ( `Expected InvalidValue, got ${ String ( flagError ?. _tag ) } ` ) ;
514+ }
515+ assert . equal ( flagError . option , "base-url" ) ;
516+ assert . equal ( flagError . value , baseUrl ) ;
517+
518+ const listOutput = yield * captureStdout (
519+ runCli ( [ "auth" , "pairing" , "list" , "--base-dir" , baseDir , "--json" ] ) ,
520+ ) ;
521+ assert . deepEqual ( JSON . parse ( listOutput ) , [ ] ) ;
522+ } ) ,
523+ ) ;
524+
525+ it . effect . each ( [ "http://192.168.1.5:3773" , "https://example.com" , "http:localhost:3773" ] ) (
526+ "prints a pair URL for %s" ,
527+ ( baseUrl ) =>
528+ Effect . gen ( function * ( ) {
529+ const baseDir = NodeFS . mkdtempSync ( NodePath . join ( NodeOS . tmpdir ( ) , "t3-cli-base-url-test-" ) ) ;
530+ const output = yield * captureStdout (
531+ runCli ( [
532+ "auth" ,
533+ "pairing" ,
534+ "create" ,
535+ "--base-dir" ,
536+ baseDir ,
537+ "--base-url" ,
538+ baseUrl ,
539+ "--json" ,
540+ ] ) ,
541+ ) ;
542+ const issued = JSON . parse ( output ) as {
543+ readonly credential : string ;
544+ readonly pairUrl : string ;
545+ } ;
546+
547+ assert . equal ( issued . pairUrl , `${ new URL ( baseUrl ) . origin } /pair#token=${ issued . credential } ` ) ;
548+ } ) ,
549+ ) ;
550+ } ) ;
0 commit comments