This repository was archived by the owner on Dec 9, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ describe("Login Plugin", () => {
105105 expect ( AzureLoginService . interactiveLogin ) . toBeCalled ( )
106106 expect ( sls . variables [ "subscriptionId" ] ) . toEqual ( "test-subs-id" ) ;
107107 expect ( sls . cli . log ) . toBeCalledWith ( "Using subscription ID: test-subs-id" ) ;
108- } )
108+ } ) ;
109109
110110 it ( "Uses the default subscription ID" , async ( ) => {
111111 const sls = MockFactory . createTestServerless ( ) ;
@@ -115,4 +115,14 @@ describe("Login Plugin", () => {
115115 expect ( sls . variables [ "subscriptionId" ] ) . toEqual ( "azureSubId" ) ;
116116 expect ( sls . cli . log ) . toBeCalledWith ( "Using subscription ID: azureSubId" ) ;
117117 } ) ;
118+
119+ it ( "Uses the subscription ID specified in serverless yaml" , async ( ) => {
120+ const sls = MockFactory . createTestServerless ( ) ;
121+ const opt = MockFactory . createTestServerlessOptions ( ) ;
122+ sls . service . provider [ "subscriptionId" ] = "test-subs-id" ;
123+ await invokeLoginHook ( false , sls , opt ) ;
124+ expect ( AzureLoginService . interactiveLogin ) . toBeCalled ( )
125+ expect ( sls . variables [ "subscriptionId" ] ) . toEqual ( "test-subs-id" ) ;
126+ expect ( sls . cli . log ) . toBeCalledWith ( "Using subscription ID: test-subs-id" ) ;
127+ } ) ;
118128} ) ;
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ export class AzureLoginPlugin extends AzureBasePlugin<AzureLoginOptions> {
2828 this . serverless . variables [ "azureCredentials" ] = authResult . credentials ;
2929 // Use environment variable for sub ID or use the first subscription in the list (service principal can
3030 // have access to more than one subscription)
31- this . serverless . variables [ "subscriptionId" ] = this . options . subscriptionId || process . env . azureSubId || authResult . subscriptions [ 0 ] . id ;
31+ this . serverless . variables [ "subscriptionId" ] = this . options . subscriptionId || process . env . azureSubId || this . serverless . service . provider [ "subscriptionId" ] || authResult . subscriptions [ 0 ] . id ;
3232 this . serverless . cli . log ( `Using subscription ID: ${ this . serverless . variables [ "subscriptionId" ] } ` ) ;
3333 }
3434 catch ( e ) {
You can’t perform that action at this time.
0 commit comments