push
github
0 of 18 new or added lines in 3 files covered. (0.0%)
1924 existing lines in 56 files now uncovered.0 of 2082 relevant lines covered (0.0%)
0.0 hits per line
UNCOV
1
|
module Unleash |
× |
UNCOV
2
|
module Strategy |
× |
UNCOV
3
|
class RemoteAddress < Base |
× |
UNCOV
4
|
PARAM = 'IPs'.freeze |
× |
5 |
|
|
UNCOV
6
|
def name |
× |
7 |
'remoteAddress'
|
× |
8 |
end
|
|
9 |
|
|
10 |
# need: params['IPs'], context.remote_address
|
|
UNCOV
11
|
def is_enabled?(params = {}, context = nil) |
× |
UNCOV
12
|
return false unless params.is_a?(Hash) && params.has_key?(PARAM) |
× |
UNCOV
13
|
return false unless params.fetch(PARAM, nil).is_a? String |
× |
UNCOV
14
|
return false unless context.class.name == 'Unleash::Context' |
× |
15 |
|
|
UNCOV
16
|
remote_address = ipaddr_or_nil_from_str(context.remote_address) |
× |
17 |
|
|
UNCOV
18
|
params[PARAM]
|
× |
19 |
.split(',')
|
|
20 |
.map(&:strip)
|
|
UNCOV
21
|
.map{ |ipblock| ipaddr_or_nil_from_str(ipblock) } |
× |
22 |
.compact |
|
UNCOV
23
|
.map{ |ipb| ipb.include? remote_address } |
× |
24 |
.any? |
|
25 |
end
|
|
26 |
|
|
UNCOV
27
|
private |
× |
28 |
|
|
UNCOV
29
|
def ipaddr_or_nil_from_str(ip) |
× |
UNCOV
30
|
IPAddr.new(ip)
|
× |
31 |
rescue StandardError |
|
UNCOV
32
|
nil
|
× |
33 |
end
|
|
34 |
end
|
|
35 |
end
|
|
36 |
end
|