@@ -60,13 +60,11 @@ function makeClient(baseUrl: string, token = "sk-synthetic-profile-key"): Client
6060 } ) ;
6161}
6262
63- function expectSuccessfulUpload ( uploadOrigin : string ) : void {
63+ function expectSuccessfulUpload ( uploadOrigin : string , token = "sk-synthetic-profile-key" ) : void {
6464 expect ( fetchMock ) . toHaveBeenCalledTimes ( 2 ) ;
6565 const [ policyUrl , policyOptions ] = fetchMock . mock . calls [ 0 ] ! ;
6666 expect ( policyUrl ) . toBe ( `${ uploadOrigin } /api/v1/uploads?action=getPolicy&model=wan3.0-video` ) ;
67- expect ( new Headers ( policyOptions ?. headers ) . get ( "Authorization" ) ) . toBe (
68- "Bearer sk-synthetic-profile-key" ,
69- ) ;
67+ expect ( new Headers ( policyOptions ?. headers ) . get ( "Authorization" ) ) . toBe ( `Bearer ${ token } ` ) ;
7068 const [ uploadUrl , uploadOptions ] = fetchMock . mock . calls [ 1 ] ! ;
7169 expect ( uploadUrl ) . toBe ( policy . upload_host ) ;
7270 expect ( uploadOptions ) . toBeDefined ( ) ;
@@ -131,14 +129,30 @@ describe("regional temporary file uploads", () => {
131129 expect ( fetchMock ) . not . toHaveBeenCalled ( ) ;
132130 } ) ;
133131
134- test ( "rejects Token Plan keys before requesting a policy" , async ( ) => {
132+ test . each ( [
133+ REGIONS . cn ,
134+ REGIONS . intl ,
135+ "https://ws-example.cn-beijing.maas.aliyuncs.com" ,
136+ "https://ws-example.ap-southeast-1.maas.aliyuncs.com" ,
137+ ] ) (
138+ "rejects Token Plan keys on official endpoint %s before requesting a policy" ,
139+ async ( baseUrl ) => {
140+ await expect (
141+ makeClient ( baseUrl , "sk-sp-synthetic-plan-key" ) . uploadFile ( fixturePath , "wan3.0-video" ) ,
142+ ) . rejects . toMatchObject ( {
143+ exitCode : ExitCode . USAGE ,
144+ message : expect . stringContaining ( "Token Plan" ) ,
145+ } ) ;
146+ expect ( fetchMock ) . not . toHaveBeenCalled ( ) ;
147+ } ,
148+ ) ;
149+
150+ test ( "lets a Token Plan key reach an explicit custom proxy" , async ( ) => {
151+ const proxy = "https://proxy.example.test" ;
135152 await expect (
136- makeClient ( REGIONS . cn , "sk-sp-synthetic-plan-key" ) . uploadFile ( fixturePath , "wan3.0-video" ) ,
137- ) . rejects . toMatchObject ( {
138- exitCode : ExitCode . USAGE ,
139- message : expect . stringContaining ( "Token Plan" ) ,
140- } ) ;
141- expect ( fetchMock ) . not . toHaveBeenCalled ( ) ;
153+ makeClient ( proxy , "sk-sp-synthetic-plan-key" ) . uploadFile ( fixturePath , "wan3.0-video" ) ,
154+ ) . resolves . toBe ( "oss://temporary/sample.mp4" ) ;
155+ expectSuccessfulUpload ( proxy , "sk-sp-synthetic-plan-key" ) ;
142156 } ) ;
143157
144158 test ( "preserves upload-policy service errors without retrying another region" , async ( ) => {
0 commit comments