File tree Expand file tree Collapse file tree 3 files changed +5
-10
lines changed
Expand file tree Collapse file tree 3 files changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ cd extract
6161mkdir users
6262
6363# use your own secret key and username
64- echo " SECRET_KEY " > users/USERNAME
64+ echo " user: key " > users/users.yml
6565` ` `
6666
6767Once a username and password has been created, you can make a request.
Original file line number Diff line number Diff line change 55require "openssl"
66require "base64"
77require "connection_pool"
8+ require "yaml"
89
910set :protection , except : [ :json_csrf ]
1011
1415
1516$users = begin
1617 if ENV [ "EXTRACT_USERS" ]
17- File . readlines ( ENV [ "EXTRACT_USERS" ] ) . each_with_object ( { } ) do |line , hash |
18- line = line . strip
19- next if line . empty?
20-
21- username , password = line . split ( "=" , 2 )
22- hash [ username ] = password if username && password
23- end
18+ YAML . safe_load_file ( ENV [ "EXTRACT_USERS" ] )
2419 else
2520 { "demo" => "demo" }
2621 end
Original file line number Diff line number Diff line change 11USERS = Tempfile . new
2- USERS . write ( "user= key" )
2+ USERS . write ( "user: key" )
33USERS . close
44
55ENV [ "RACK_ENV" ] = "test"
@@ -31,7 +31,7 @@ class Test < Minitest::Test
3131 include Rack ::Test ::Methods
3232
3333 def setup
34- @user , @key = File . read ( USERS ) . split ( "=" , 2 )
34+ @user , @key = YAML . safe_load_file ( USERS ) . first
3535 end
3636
3737 def app
You can’t perform that action at this time.
0 commit comments