@@ -22,28 +22,46 @@ describe('vars', () => {
2222 expect ( vars . particleboardUrl ) . to . equal ( 'https://particleboard.heroku.com' )
2323 } )
2424
25- it ( 'respects HEROKU_HOST' , ( ) => {
26- process . env . HEROKU_HOST = 'customhost'
27- expect ( vars . apiHost ) . to . equal ( 'api.customhost' )
28- expect ( vars . apiUrl ) . to . equal ( 'https://api.customhost' )
29- expect ( vars . gitHost ) . to . equal ( 'customhost' )
30- expect ( vars . host ) . to . equal ( 'customhost' )
31- expect ( vars . httpGitHost ) . to . equal ( 'git.customhost' )
32- expect ( vars . gitPrefixes ) . to . deep . equal ( [ 'git@customhost:' , 'ssh://git@customhost/' , 'https://git.customhost/' ] )
25+ it ( 'respects valid HEROKU_HOST values' , ( ) => {
26+ // Test with a valid heroku.com subdomain
27+ process . env . HEROKU_HOST = 'staging.heroku.com'
28+ expect ( vars . apiHost ) . to . equal ( 'api.staging.heroku.com' )
29+ expect ( vars . apiUrl ) . to . equal ( 'https://api.staging.heroku.com' )
30+ expect ( vars . gitHost ) . to . equal ( 'staging.heroku.com' )
31+ expect ( vars . host ) . to . equal ( 'staging.heroku.com' )
32+ expect ( vars . httpGitHost ) . to . equal ( 'git.staging.heroku.com' )
33+ expect ( vars . gitPrefixes ) . to . deep . equal ( [ 'git@staging.heroku.com:' , 'ssh://git@staging.heroku.com/' , 'https://git.staging.heroku.com/' ] )
3334 expect ( vars . particleboardUrl ) . to . equal ( 'https://particleboard.heroku.com' )
3435 } )
3536
36- it ( 'respects HEROKU_HOST as url' , ( ) => {
37- process . env . HEROKU_HOST = 'https://customhost'
38- expect ( vars . host ) . to . equal ( 'https://customhost' )
39- expect ( vars . apiHost ) . to . equal ( 'customhost' )
40- expect ( vars . apiUrl ) . to . equal ( 'https://customhost' )
41- expect ( vars . gitHost ) . to . equal ( 'customhost' )
42- expect ( vars . httpGitHost ) . to . equal ( 'customhost' )
43- expect ( vars . gitPrefixes ) . to . deep . equal ( [ 'git@customhost:' , 'ssh://git@customhost/' , 'https://customhost/' ] )
37+ it ( 'rejects invalid HEROKU_HOST values for security' , ( ) => {
38+ // Test that invalid hosts are rejected and fallback to default
39+ process . env . HEROKU_HOST = 'bogus-server.com'
40+ expect ( vars . host ) . to . equal ( 'heroku.com' ) // Should fallback to default
41+ expect ( vars . apiHost ) . to . equal ( 'api.heroku.com' )
42+ expect ( vars . apiUrl ) . to . equal ( 'https://api.heroku.com' )
43+ } )
44+
45+ it ( 'respects legitimate HEROKU_HOST as url' , ( ) => {
46+ // Test with a valid heroku.com subdomain URL
47+ process . env . HEROKU_HOST = 'https://staging.heroku.com'
48+ expect ( vars . host ) . to . equal ( 'https://staging.heroku.com' )
49+ expect ( vars . apiHost ) . to . equal ( 'staging.heroku.com' )
50+ expect ( vars . apiUrl ) . to . equal ( 'https://staging.heroku.com' )
51+ expect ( vars . gitHost ) . to . equal ( 'staging.heroku.com' )
52+ expect ( vars . httpGitHost ) . to . equal ( 'staging.heroku.com' )
53+ expect ( vars . gitPrefixes ) . to . deep . equal ( [ 'git@staging.heroku.com:' , 'ssh://git@staging.heroku.com/' , 'https://staging.heroku.com/' ] )
4454 expect ( vars . particleboardUrl ) . to . equal ( 'https://particleboard.heroku.com' )
4555 } )
4656
57+ it ( 'rejects invalid HEROKU_HOST URLs' , ( ) => {
58+ // Test that invalid URL hosts are rejected and fallback to default
59+ process . env . HEROKU_HOST = 'https://bogus-server.com'
60+ expect ( vars . host ) . to . equal ( 'heroku.com' ) // Should fallback to default for security
61+ expect ( vars . apiHost ) . to . equal ( 'api.heroku.com' )
62+ expect ( vars . apiUrl ) . to . equal ( 'https://api.heroku.com' )
63+ } )
64+
4765 it ( 'respects HEROKU_PARTICLEBOARD_URL' , ( ) => {
4866 process . env . HEROKU_PARTICLEBOARD_URL = 'https://customhost'
4967 expect ( vars . particleboardUrl ) . to . equal ( 'https://customhost' )
0 commit comments