File tree Expand file tree Collapse file tree 5 files changed +33
-12
lines changed
Expand file tree Collapse file tree 5 files changed +33
-12
lines changed Original file line number Diff line number Diff line change @@ -36,8 +36,16 @@ class Application < Rails::Application
3636 config . middleware . use config . session_store , config . session_options
3737
3838 # CAS configuration
39- # - NOTE: overridden in production.rb
40- config . cas_host = ENV . fetch ( 'CAS_HOST' ) { 'auth-test.berkeley.edu' }
39+ config . cas_host = ENV . fetch ( 'CAS_HOST' ) do
40+ "#{ Rails . env . production? ? 'auth' : 'auth-test' } .berkeley.edu"
41+ end
42+
43+ Rails . application . config . hosts . append (
44+ '.ucblib.org' ,
45+ '.lib.berkeley.edu' ,
46+ '.pantheon.berkeley.edu' ,
47+ config . cas_host
48+ )
4149
4250 BerkeleyLibrary ::Alma ::Config . default!
4351
Original file line number Diff line number Diff line change 6363 # logger.formatter = config.log_formatter
6464 # config.logger = ActiveSupport::TaggedLogging.new(logger)
6565 # end
66-
67- # CAS configuration
68- # - NOTE: overrides application.rb
69- config . cas_host = ENV . fetch ( 'CAS_HOST' ) { 'auth.berkeley.edu' }
70-
71- if ENV [ 'CI' ] . blank? # TODO: what if it's not?
72- Rails . application . config . hosts << '.ucblib.org'
73- Rails . application . config . hosts << '.lib.berkeley.edu'
74- Rails . application . config . hosts << config . cas_host
75- end
7666end
Original file line number Diff line number Diff line change 4747
4848 # Annotate rendered view with file names.
4949 # config.action_view.annotate_rendered_view_with_filenames = true
50+
51+ Rails . application . config . hosts . append (
52+ ActionDispatch ::Integration ::Session ::DEFAULT_HOST ,
53+ ActionController ::Renderer ::DEFAULTS [ 'http_host' ]
54+ )
5055end
Original file line number Diff line number Diff line change 66 invalid_uri = 'not a URI'
77 expect ( CorsHelper . allow? ( invalid_uri ) ) . to eq ( false )
88 end
9+
10+ it 'returns true for a lib.berkeley.edu origin' do
11+ source = 'https://www.lib.berkeley.edu/'
12+ expect ( CorsHelper . allow? ( source ) ) . to eq ( true )
13+ end
14+
15+ it 'returns true for a pantheon.berkeley.edu origin' do
16+ source = 'https://dev.pantheon.berkeley.edu/'
17+ expect ( CorsHelper . allow? ( source ) ) . to eq ( true )
18+ end
919 end
1020end
Original file line number Diff line number Diff line change 2727 parsed_response = JSON . parse ( response . body )
2828 expect ( parsed_response ) . to contain_jsonapi_for ( Facet . all , { include : [ :terms ] } )
2929 end
30+
31+ it 'returns a Access-Control-Allow-Origin header in response to an Origin header' do
32+ origin = 'www.lib.berkeley.edu'
33+ get facets_url , params : { include : 'terms' } , headers : { 'Origin' => origin }
34+
35+ expect ( response ) . to be_successful
36+ expect ( response . headers [ 'Access-Control-Allow-Origin' ] ) . to eq ( origin )
37+ end
3038 end
3139 end
3240end
You can’t perform that action at this time.
0 commit comments