Commit d593e61 1 parent be1d8a8 commit d593e61 Copy full SHA for d593e61
File tree 2 files changed +16
-3
lines changed
2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -29,10 +29,14 @@ export class Common {
29
29
}
30
30
}
31
31
public static async resolveLoginUrl ( instanceUrl : Optional < string > ) : Promise < Optional < string > > {
32
+ const logger = await Logger . child ( 'Common' , { tag : 'resolveLoginUrl' } ) ;
32
33
if ( instanceUrl ) {
34
+ if ( instanceUrl . includes ( 'lightning.force.com' ) ) {
35
+ logger . warn ( messages . getMessage ( 'invalidInstanceUrl' ) ) ;
36
+ throw new SfdxError ( messages . getMessage ( 'invalidInstanceUrl' ) , 'URL_WARNING' ) ;
37
+ }
33
38
return instanceUrl ;
34
39
}
35
- const logger = await Logger . child ( 'Common' , { tag : 'resolveLoginUrl' } ) ;
36
40
let loginUrl : string ;
37
41
try {
38
42
const project = await SfdxProject . resolve ( ) ;
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ describe('common unit tests', () => {
56
56
const loginUrl = await Common . resolveLoginUrl ( undefined ) ;
57
57
expect ( loginUrl ) . to . equal ( SfdcUrl . PRODUCTION ) ;
58
58
} ) ;
59
- it ( 'should throw on lightning login URL' , async ( ) => {
59
+ it ( 'should throw on lightning login URL in sfdcLoginUrl propery ' , async ( ) => {
60
60
sandbox . stub ( SfdxProject . prototype , 'resolveProjectConfig' ) . resolves ( {
61
61
packageDirectories : [
62
62
{
@@ -69,7 +69,16 @@ describe('common unit tests', () => {
69
69
} ) ;
70
70
try {
71
71
await Common . resolveLoginUrl ( undefined ) ;
72
- expect ( 1 ) . to . equal ( 'This test is failing because it is expecting an error that is never thrown' ) ;
72
+ sinon . assert . fail ( 'This test is failing because it is expecting an error that is never thrown' ) ;
73
+ } catch ( error ) {
74
+ const err = error as SfdxError ;
75
+ expect ( err . name ) . to . equal ( 'URL_WARNING' ) ;
76
+ }
77
+ } ) ;
78
+ it ( 'should throw on lightning login URL passed in to resolveLoginUrl()' , async ( ) => {
79
+ try {
80
+ await Common . resolveLoginUrl ( 'https://shanedevhub.lightning.force.com' ) ;
81
+ sinon . assert . fail ( 'This test is failing because it is expecting an error that is never thrown' ) ;
73
82
} catch ( error ) {
74
83
const err = error as SfdxError ;
75
84
expect ( err . name ) . to . equal ( 'URL_WARNING' ) ;
You can’t perform that action at this time.
0 commit comments