testbeat 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rspec/spec_helper.rb +28 -0
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e59dd7479b13ac9f2dc6601ba218331a94ad2dd
4
- data.tar.gz: cefb28d6daacd2a4043873e642d4efd6e1aa5e9a
3
+ metadata.gz: f351005ad9c8613e13e6b8149aaa3575166ea5ff
4
+ data.tar.gz: 4dedca6c54209fb5914b5bef5dd13b2b8caf1a64
5
5
  SHA512:
6
- metadata.gz: bc5190359a7bc19858c80be84a46b5e97e65408e60913ce0d0555269b92f7dc9d671871f31d7ce1795bb6340bd233220cabcddc7b97ceac039088364b147607c
7
- data.tar.gz: 9dfdd882f9aaab8c3f1e2987bf11beebc86bf36d2b5dd2413c4a7160558046cac9b27867e469e9cec7915867044da7f21b8de20804ce2ba20ef18c8e27bcbddd
6
+ metadata.gz: 6afa9b30143d299cd97fe9ffe6ce6f4f1fe3717c4c0c2c30f4fc36742711906616af75f14c5ae13875057e4e9cdacd9eeaca8c51b0e4cb3ff1435c29ad5eb235
7
+ data.tar.gz: c894dd8624444cd387b3930d094791700375f060f3f654e0e39d3ae92fddb92399df417712aeaa204c00eccb3b67b8b6d3d0b69973576dabbe02cd688f6625ed
@@ -273,6 +273,14 @@ class TestbeatContext
273
273
  @method
274
274
  end
275
275
 
276
+ def redirect
277
+ @rest_redirect
278
+ end
279
+
280
+ def redirect?
281
+ !!redirect
282
+ end
283
+
276
284
  def port
277
285
  @rest_port
278
286
  end
@@ -354,6 +362,9 @@ class TestbeatContext
354
362
  if example_group[:port]
355
363
  @rest_port = example_group[:port]
356
364
  end
365
+ if example_group[:redirect]
366
+ @rest_redirect = example_group[:redirect]
367
+ end
357
368
  end
358
369
 
359
370
  end
@@ -438,6 +449,23 @@ class TestbeatRestRequest
438
449
 
439
450
  @response = http.request(req) # Net::HTTPResponse object
440
451
 
452
+ # The redirect must not be authenticated. Consider copying 401 handling to above redirect handling.
453
+ # Follows a single redirect, no recursive redirects (a feature in a test framework).
454
+ if (@response.code == "301" or @response.code == "302") and @testbeat.redirect
455
+ @testbeat.logger.info{ "Redirecting #{@response.code} to #{@response['location']}" }
456
+ redirectTo = URI.parse(@response['location'])
457
+ redirectToPath = [redirectTo.path,redirectTo.query].join('?')
458
+ #reqRedirect = req.new(redirectTo.path, req.to_hash()) # new(path, initheader = nil)
459
+ reqRedirect = HTTP_VERBS[@testbeat.method].new(redirectToPath) # new(path, initheader = nil)
460
+ if @testbeat.headers?
461
+ @testbeat.headers.each {|name, value| reqRedirect[name] = value }
462
+ end
463
+ reqRedirect.body = req.body
464
+ @response = http.request(reqRedirect)
465
+ req = reqRedirect # Needed by auth support below.
466
+ @testbeat.logger.info{ "Redirected #{@response.code}" }
467
+ end
468
+
441
469
  if @response.code == "401" and @testbeat.user and not @testbeat.unauthenticated?
442
470
  u = @testbeat.user
443
471
  @testbeat.logger.info{ "Authenticating to #{@testbeat.resource} with #{u[:username]}:#{u[:password]}" }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testbeat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Staffan Olsson