File tree 4 files changed +29
-10
lines changed
4 files changed +29
-10
lines changed Original file line number Diff line number Diff line change @@ -83,24 +83,24 @@ export class MyDomainResolver extends AsyncOptionalCreatable<MyDomainResolver.Op
83
83
const self : MyDomainResolver = this ;
84
84
const pollingOptions : PollingClient . Options = {
85
85
async poll ( ) : Promise < StatusResult > {
86
- const { host } = self . options . url ;
86
+ const { hostname } = self . options . url ;
87
87
let dnsResult : { address : string } ;
88
88
try {
89
- self . logger . debug ( `Attempting to resolve url: ${ host } ` ) ;
89
+ self . logger . debug ( `Attempting to resolve url: ${ hostname } ` ) ;
90
90
if ( new SfdcUrl ( self . options . url ) . isLocalUrl ( ) ) {
91
91
return {
92
92
completed : true ,
93
93
payload : '127.0.0.1' ,
94
94
} ;
95
95
}
96
- dnsResult = await promisify ( lookup ) ( host ) ;
97
- self . logger . debug ( `Successfully resolved host: ${ host } result: ${ JSON . stringify ( dnsResult ) } ` ) ;
96
+ dnsResult = await promisify ( lookup ) ( hostname ) ;
97
+ self . logger . debug ( `Successfully resolved host: ${ hostname } result: ${ JSON . stringify ( dnsResult ) } ` ) ;
98
98
return {
99
99
completed : true ,
100
100
payload : dnsResult . address ,
101
101
} ;
102
102
} catch ( e ) {
103
- self . logger . debug ( `An error occurred trying to resolve: ${ host } ` ) ;
103
+ self . logger . debug ( `An error occurred trying to resolve: ${ hostname } ` ) ;
104
104
self . logger . debug ( `Error: ${ ( e as Error ) . message } ` ) ;
105
105
self . logger . debug ( 'Re-trying dns lookup again....' ) ;
106
106
return {
Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ export class SfdcUrl extends URL {
135
135
'.stm.salesforce.ms' ,
136
136
'.pc-rnd.force.com' ,
137
137
'.pc-rnd.salesforce.com' ,
138
- '.wc. crm.dev' , // workspaces container
138
+ '.crm.dev' , // workspaces container
139
139
] ;
140
140
return (
141
141
this . origin . startsWith ( 'https://gs1.' ) ||
Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ describe('myDomainResolver', () => {
20
20
const TEST_IP = '1.1.1.1' ;
21
21
const CALL_COUNT = 3 ;
22
22
23
- let lookupAsyncSpy : { callCount : number } ;
23
+ let lookupAsyncSpy : sinon . SinonStub ;
24
+
24
25
beforeEach ( ( ) => {
25
26
lookupAsyncSpy = $$ . SANDBOX . stub ( dns , 'lookup' ) . callsFake ( ( host : string , callback : AnyFunction ) => {
26
27
const isDefaultHost = host === MyDomainResolver . DEFAULT_DOMAIN . host ;
@@ -45,6 +46,17 @@ describe('myDomainResolver', () => {
45
46
expect ( lookupAsyncSpy . callCount ) . to . be . equal ( CALL_COUNT ) ;
46
47
} ) ;
47
48
49
+ it ( 'should do lookup without port' , async ( ) => {
50
+ const options : MyDomainResolver . Options = {
51
+ url : new URL ( `https://${ POSITIVE_HOST } :6101` ) ,
52
+ } ;
53
+ const resolver : MyDomainResolver = await MyDomainResolver . create ( options ) ;
54
+ const ip = await resolver . resolve ( ) ;
55
+ expect ( ip ) . to . be . equal ( TEST_IP ) ;
56
+ // verify that it uses hostname (without port) not host
57
+ expect ( lookupAsyncSpy . args [ 0 ] [ 0 ] ) . to . be . equal ( POSITIVE_HOST ) ;
58
+ } ) ;
59
+
48
60
describe ( 'disable dns check' , ( ) => {
49
61
const env = new Env ( ) ;
50
62
it ( 'should return host if SFDX_DISABLE_DNS_CHECK is set to true' , async ( ) => {
Original file line number Diff line number Diff line change @@ -180,9 +180,16 @@ describe('util/sfdcUrl', () => {
180
180
expect ( url . isLocalUrl ( ) ) . to . equal ( true ) ;
181
181
} ) ;
182
182
it ( 'workspaces with port is internal but not local' , ( ) => {
183
- const url = new SfdcUrl ( 'https://dev.salesforce-com.shane-mclaughlin-0lrfx7zp3l121.wc.crm.dev:6101/' ) ;
184
- expect ( url . isInternalUrl ( ) ) . to . equal ( true ) ;
185
- expect ( url . isLocalUrl ( ) ) . to . equal ( false ) ;
183
+ const urls = [
184
+ 'https://dev.salesforce-com.shane-mclaughlin-0lrfx7zp3l121.wc.crm.dev:6101/' ,
185
+ 'https://dev.salesforce-com.shane-mclaughlin-0lrfx7zp3l121.wb.crm.dev:6101/' ,
186
+ 'https://dev.salesforce-com.shane-mclaughlin-0lrfx7zp3l121.wa.crm.dev:6101/' ,
187
+ ] . map ( ( u ) => new SfdcUrl ( u ) ) ;
188
+
189
+ urls . map ( ( url ) => {
190
+ expect ( url . isInternalUrl ( ) ) . to . equal ( true ) ;
191
+ expect ( url . isLocalUrl ( ) ) . to . equal ( false ) ;
192
+ } ) ;
186
193
} ) ;
187
194
} ) ;
188
195
You can’t perform that action at this time.
0 commit comments