@@ -78,6 +78,62 @@ describe("authenticateForDeploy", () => {
7878 } ) ;
7979 expect ( result ) . toEqual ( { ok : false , error : "login result" } ) ;
8080 } ) ;
81+
82+ it ( "rejects a PAT in TRIGGER_SECRET_KEY with a helpful error" , async ( ) => {
83+ const result = await authenticateForDeploy ( {
84+ secretKey : "tr_pat_abc123" ,
85+ profile : "default" ,
86+ silent : true ,
87+ login : async ( ) => ( { ok : false , error : "should not be called" } ) ,
88+ } ) ;
89+
90+ expect ( result ) . toEqual ( {
91+ ok : false ,
92+ error : expect . stringContaining ( "TRIGGER_ACCESS_TOKEN" ) ,
93+ } ) ;
94+ } ) ;
95+
96+ it ( "rejects an OAT in TRIGGER_SECRET_KEY with a helpful error" , async ( ) => {
97+ const result = await authenticateForDeploy ( {
98+ secretKey : "tr_oat_abc123" ,
99+ profile : "default" ,
100+ silent : true ,
101+ login : async ( ) => ( { ok : false , error : "should not be called" } ) ,
102+ } ) ;
103+
104+ expect ( result ) . toEqual ( {
105+ ok : false ,
106+ error : expect . stringContaining ( "TRIGGER_ACCESS_TOKEN" ) ,
107+ } ) ;
108+ } ) ;
109+
110+ it ( "rejects a secret key that doesn't look like an API key" , async ( ) => {
111+ const result = await authenticateForDeploy ( {
112+ secretKey : "not-a-valid-key" ,
113+ profile : "default" ,
114+ silent : true ,
115+ login : async ( ) => ( { ok : false , error : "should not be called" } ) ,
116+ } ) ;
117+
118+ expect ( result ) . toEqual ( {
119+ ok : false ,
120+ error : expect . stringContaining ( "does not look like a Trigger.dev API key" ) ,
121+ } ) ;
122+ } ) ;
123+
124+ it ( "throws a descriptive error for an invalid API URL" , async ( ) => {
125+ await expect (
126+ authenticateForDeploy ( {
127+ secretKey : "tr_prod_sk_deploy" ,
128+ apiUrl : "not-a-url" ,
129+ profile : "default" ,
130+ silent : true ,
131+ login : async ( ) => ( { ok : false , error : "should not be called" } ) ,
132+ } )
133+ ) . rejects . toThrow (
134+ 'Invalid API URL "not-a-url". Check your TRIGGER_API_URL environment variable or --api-url flag.'
135+ ) ;
136+ } ) ;
81137} ) ;
82138
83139describe ( "userIdForDeploy" , ( ) => {
0 commit comments