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", () => {
105
105
expect ( AzureLoginService . interactiveLogin ) . toBeCalled ( )
106
106
expect ( sls . variables [ "subscriptionId" ] ) . toEqual ( "test-subs-id" ) ;
107
107
expect ( sls . cli . log ) . toBeCalledWith ( "Using subscription ID: test-subs-id" ) ;
108
- } )
108
+ } ) ;
109
109
110
110
it ( "Uses the default subscription ID" , async ( ) => {
111
111
const sls = MockFactory . createTestServerless ( ) ;
@@ -115,4 +115,14 @@ describe("Login Plugin", () => {
115
115
expect ( sls . variables [ "subscriptionId" ] ) . toEqual ( "azureSubId" ) ;
116
116
expect ( sls . cli . log ) . toBeCalledWith ( "Using subscription ID: azureSubId" ) ;
117
117
} ) ;
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
+ } ) ;
118
128
} ) ;
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ export class AzureLoginPlugin extends AzureBasePlugin<AzureLoginOptions> {
28
28
this . serverless . variables [ "azureCredentials" ] = authResult . credentials ;
29
29
// Use environment variable for sub ID or use the first subscription in the list (service principal can
30
30
// 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 ;
32
32
this . serverless . cli . log ( `Using subscription ID: ${ this . serverless . variables [ "subscriptionId" ] } ` ) ;
33
33
}
34
34
catch ( e ) {
You can’t perform that action at this time.
0 commit comments