@@ -28,28 +28,46 @@ describe('vars', () => {
2828 expect ( vars . particleboardUrl ) . to . equal ( 'https://particleboard.heroku.com' )
2929 } )
3030
31- it ( 'respects HEROKU_HOST' , ( ) => {
32- process . env . HEROKU_HOST = 'customhost'
33- expect ( vars . apiHost ) . to . equal ( 'api.customhost' )
34- expect ( vars . apiUrl ) . to . equal ( 'https://api.customhost' )
35- expect ( vars . gitHost ) . to . equal ( 'customhost' )
36- expect ( vars . host ) . to . equal ( 'customhost' )
37- expect ( vars . httpGitHost ) . to . equal ( 'git.customhost' )
38- expect ( vars . gitPrefixes ) . to . deep . equal ( [ 'git@customhost:' , 'ssh://git@customhost/' , 'https://git.customhost/' ] )
31+ it ( 'respects valid HEROKU_HOST values' , ( ) => {
32+ // Test with a valid heroku.com subdomain
33+ process . env . HEROKU_HOST = 'staging.heroku.com'
34+ expect ( vars . apiHost ) . to . equal ( 'api.staging.heroku.com' )
35+ expect ( vars . apiUrl ) . to . equal ( 'https://api.staging.heroku.com' )
36+ expect ( vars . gitHost ) . to . equal ( 'staging.heroku.com' )
37+ expect ( vars . host ) . to . equal ( 'staging.heroku.com' )
38+ expect ( vars . httpGitHost ) . to . equal ( 'git.staging.heroku.com' )
39+ expect ( vars . gitPrefixes ) . to . deep . equal ( [ '[email protected] :' , 'ssh://[email protected] /' , 'https://git.staging.heroku.com/' ] ) 3940 expect ( vars . particleboardUrl ) . to . equal ( 'https://particleboard.heroku.com' )
4041 } )
4142
42- it ( 'respects HEROKU_HOST as url' , ( ) => {
43- process . env . HEROKU_HOST = 'https://customhost'
44- expect ( vars . host ) . to . equal ( 'https://customhost' )
45- expect ( vars . apiHost ) . to . equal ( 'customhost' )
46- expect ( vars . apiUrl ) . to . equal ( 'https://customhost' )
47- expect ( vars . gitHost ) . to . equal ( 'customhost' )
48- expect ( vars . httpGitHost ) . to . equal ( 'customhost' )
49- expect ( vars . gitPrefixes ) . to . deep . equal ( [ 'git@customhost:' , 'ssh://git@customhost/' , 'https://customhost/' ] )
43+ it ( 'rejects invalid HEROKU_HOST values for security' , ( ) => {
44+ // Test that invalid hosts are rejected and fallback to default
45+ process . env . HEROKU_HOST = 'bogus-server.com'
46+ expect ( vars . host ) . to . equal ( 'heroku.com' ) // Should fallback to default
47+ expect ( vars . apiHost ) . to . equal ( 'api.heroku.com' )
48+ expect ( vars . apiUrl ) . to . equal ( 'https://api.heroku.com' )
49+ } )
50+
51+ it ( 'respects legitimate HEROKU_HOST as url' , ( ) => {
52+ // Test with a valid heroku.com subdomain URL
53+ process . env . HEROKU_HOST = 'https://staging.heroku.com'
54+ expect ( vars . host ) . to . equal ( 'https://staging.heroku.com' )
55+ expect ( vars . apiHost ) . to . equal ( 'staging.heroku.com' )
56+ expect ( vars . apiUrl ) . to . equal ( 'https://staging.heroku.com' )
57+ expect ( vars . gitHost ) . to . equal ( 'staging.heroku.com' )
58+ expect ( vars . httpGitHost ) . to . equal ( 'staging.heroku.com' )
59+ expect ( vars . gitPrefixes ) . to . deep . equal ( [ '[email protected] :' , 'ssh://[email protected] /' , 'https://staging.heroku.com/' ] ) 5060 expect ( vars . particleboardUrl ) . to . equal ( 'https://particleboard.heroku.com' )
5161 } )
5262
63+ it ( 'rejects invalid HEROKU_HOST URLs' , ( ) => {
64+ // Test that invalid URL hosts are rejected and fallback to default
65+ process . env . HEROKU_HOST = 'https://bogus-server.com'
66+ expect ( vars . host ) . to . equal ( 'heroku.com' ) // Should fallback to default for security
67+ expect ( vars . apiHost ) . to . equal ( 'api.heroku.com' )
68+ expect ( vars . apiUrl ) . to . equal ( 'https://api.heroku.com' )
69+ } )
70+
5371 it ( 'respects HEROKU_PARTICLEBOARD_URL' , ( ) => {
5472 process . env . HEROKU_PARTICLEBOARD_URL = 'https://customhost'
5573 expect ( vars . particleboardUrl ) . to . equal ( 'https://customhost' )
0 commit comments