taps 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 2
4
- :patch: 5
4
+ :patch: 6
@@ -53,6 +53,18 @@ class ClientSession
53
53
  @session_resource.delete(:taps_version => Taps.version) if @session_resource
54
54
  end
55
55
 
56
+ def safe_url(url)
57
+ url.sub(/\/\/(.+?)?:(.*?)@/, '//\1:[hidden]@')
58
+ end
59
+
60
+ def safe_remote_url
61
+ safe_url(remote_url)
62
+ end
63
+
64
+ def safe_database_url
65
+ safe_url(database_url)
66
+ end
67
+
56
68
  def cmd_send
57
69
  verify_server
58
70
  cmd_send_schema
@@ -62,27 +74,27 @@ class ClientSession
62
74
  end
63
75
 
64
76
  def cmd_send_indexes
65
- puts "Sending schema indexes to remote taps server #{remote_url} from local database #{database_url}"
77
+ puts "Sending schema indexes to remote taps server #{safe_remote_url} from local database #{safe_database_url}"
66
78
 
67
79
  index_data = `#{File.dirname(__FILE__)}/../../bin/schema indexes #{database_url}`
68
80
  session_resource['indexes'].post(index_data, :taps_version => Taps.version)
69
81
  end
70
82
 
71
83
  def cmd_send_schema
72
- puts "Sending schema to remote taps server #{remote_url} from local database #{database_url}"
84
+ puts "Sending schema to remote taps server #{safe_remote_url} from local database #{safe_database_url}"
73
85
 
74
86
  schema_data = `#{File.dirname(__FILE__)}/../../bin/schema dump #{database_url}`
75
87
  session_resource['schema'].post(schema_data, :taps_version => Taps.version)
76
88
  end
77
89
 
78
90
  def cmd_send_reset_sequences
79
- puts "Resetting db sequences in remote taps server at #{remote_url}"
91
+ puts "Resetting db sequences in remote taps server at #{safe_remote_url}"
80
92
 
81
93
  session_resource["reset_sequences"].post('', :taps_version => Taps.version)
82
94
  end
83
95
 
84
96
  def cmd_send_data
85
- puts "Sending schema and data from local database #{database_url} to remote taps server at #{remote_url}"
97
+ puts "Sending schema and data from local database #{safe_database_url} to remote taps server at #{safe_remote_url}"
86
98
 
87
99
  db.tables.each do |table_name|
88
100
  table = db[table_name]
@@ -132,7 +144,7 @@ class ClientSession
132
144
  end
133
145
 
134
146
  def cmd_receive_data
135
- puts "Receiving data from remote taps server #{remote_url} into local database #{database_url}"
147
+ puts "Receiving data from remote taps server #{safe_remote_url} into local database #{safe_database_url}"
136
148
 
137
149
  tables_with_counts, record_count = fetch_tables_info
138
150
 
@@ -199,7 +211,7 @@ class ClientSession
199
211
  end
200
212
 
201
213
  def cmd_receive_schema
202
- puts "Receiving schema from remote taps server #{remote_url} into local database #{database_url}"
214
+ puts "Receiving schema from remote taps server #{safe_remote_url} into local database #{safe_database_url}"
203
215
 
204
216
  schema_data = session_resource['schema'].get(:taps_version => Taps.version)
205
217
  output = Taps::Utils.load_schema(database_url, schema_data)
@@ -207,7 +219,7 @@ class ClientSession
207
219
  end
208
220
 
209
221
  def cmd_receive_indexes
210
- puts "Receiving schema indexes from remote taps server #{remote_url} into local database #{database_url}"
222
+ puts "Receiving schema indexes from remote taps server #{safe_remote_url} into local database #{safe_database_url}"
211
223
 
212
224
  index_data = session_resource['indexes'].get(:taps_version => Taps.version)
213
225
 
@@ -216,7 +228,7 @@ class ClientSession
216
228
  end
217
229
 
218
230
  def cmd_reset_sequences
219
- puts "Resetting db sequences in #{database_url}"
231
+ puts "Resetting db sequences in #{safe_database_url}"
220
232
 
221
233
  output = `#{File.dirname(__FILE__)}/../../bin/schema reset_db_sequences #{database_url}`
222
234
  puts output if output
@@ -238,10 +250,10 @@ class ClientSession
238
250
  raise
239
251
  end
240
252
  rescue RestClient::Unauthorized
241
- puts "Bad credentials given for #{remote_url}"
253
+ puts "Bad credentials given for #{safe_remote_url}"
242
254
  exit(1)
243
255
  rescue Errno::ECONNREFUSED
244
- puts "Can't connect to #{remote_url}. Please check that it's running"
256
+ puts "Can't connect to #{safe_remote_url}. Please check that it's running"
245
257
  exit(1)
246
258
  end
247
259
  end
@@ -78,5 +78,11 @@ describe Taps::ClientSession do
78
78
  @response.stubs(:headers).returns({ :taps_checksum => Taps::Utils.checksum(@gzip_data) })
79
79
  @client.fetch_table_rows('mytable', 1000, 0).should == [ 1000, { :header => [:x, :y], :data => [[1, 2], [3, 4]] } ]
80
80
  end
81
+
82
+ it "hides the password in urls" do
83
+ @client.safe_url("postgres://postgres:password@localhost/mydb").should == "postgres://postgres:[hidden]@localhost/mydb"
84
+ @client.safe_url("postgres://postgres@localhost/mydb").should == "postgres://postgres@localhost/mydb"
85
+ @client.safe_url("http://x:y@localhost:5000").should == "http://x:[hidden]@localhost:5000"
86
+ end
81
87
  end
82
88
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Chimal, Jr.
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-02-24 00:00:00 -08:00
13
+ date: 2009-02-26 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -85,20 +85,20 @@ extra_rdoc_files: []
85
85
  files:
86
86
  - spec/base.rb
87
87
  - spec/utils_spec.rb
88
- - spec/client_session_spec.rb
89
88
  - spec/server_spec.rb
90
89
  - spec/schema_spec.rb
90
+ - spec/client_session_spec.rb
91
91
  - lib/taps/db_session.rb
92
92
  - lib/taps/progress_bar.rb
93
93
  - lib/taps/cli.rb
94
- - lib/taps/client_session.rb
94
+ - lib/taps/adapter_hacks.rb
95
95
  - lib/taps/adapter_hacks/invalid_text_limit.rb
96
96
  - lib/taps/adapter_hacks/non_rails_schema_dump.rb
97
97
  - lib/taps/schema.rb
98
- - lib/taps/adapter_hacks.rb
99
- - lib/taps/config.rb
100
98
  - lib/taps/server.rb
101
99
  - lib/taps/utils.rb
100
+ - lib/taps/client_session.rb
101
+ - lib/taps/config.rb
102
102
  - README.rdoc
103
103
  - LICENSE
104
104
  - VERSION.yml