mobile-subscriber 1.0.0.alpha2 → 1.0.0.alpha3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mobile_subscriber/detection/from_x_nokia_msisdn_http_request_header.rb +9 -5
- data/lib/mobile_subscriber/detection/http_request_info.rb +1 -0
- data/lib/mobile_subscriber/dictionaries/dialing_and_country_codes.rb +3 -0
- data/lib/mobile_subscriber/version.rb +1 -1
- data/spec/detection/from_x_nokia_msisdn_http_request_header_spec.rb +10 -0
- data/spec/factories/requests.rb +10 -0
- data/spec/shared_examples/of_msisdn_detection_from_http_request.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dff021ce9f98d8b6f5b708e5b5b923371a73ae3e
|
4
|
+
data.tar.gz: 6943c7b168217442a6f83cef0b439e71fee48874
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da95e3e0d4d5fd5f9b7d251a08e368b667782e10d59622fb0c42ae42808a77e1900a8c3f30d86f226a4889d2c052f9d74394f6d702aba5633c55f6ad5482cb27
|
7
|
+
data.tar.gz: 8c54ae67aae2b5056834831cadef35704e36f6e017cd7f318c25c4a9f4b5485cbbaeab90fb4139e5dcb050445f84e1026013314c981fd614d781f0493b99c3a8
|
@@ -6,6 +6,7 @@ module MobileSubscriber::Detection
|
|
6
6
|
# - Telcel México
|
7
7
|
# - Claro Argentina
|
8
8
|
# - Claro Costa Rica
|
9
|
+
# - Claro Puerto Rico
|
9
10
|
# - Claro Guatemala
|
10
11
|
# - Claro Honduras
|
11
12
|
# - Claro Nicaragua
|
@@ -17,26 +18,29 @@ module MobileSubscriber::Detection
|
|
17
18
|
|
18
19
|
country_code = (
|
19
20
|
MobileSubscriber::DIALING_COUNTRY_CODES[msisdn[0,2]] ||
|
20
|
-
MobileSubscriber::DIALING_COUNTRY_CODES[msisdn[0,3]]
|
21
|
+
MobileSubscriber::DIALING_COUNTRY_CODES[msisdn[0,3]] || # Dominican 3-digit needed
|
22
|
+
MobileSubscriber::DIALING_COUNTRY_CODES[msisdn[0,1]] # Puerto Rico 1-digit country code of "1"
|
21
23
|
)
|
22
24
|
|
23
25
|
# Determine the Network Operator tuple (MCC + MNC):
|
24
26
|
# TODO: Validate IP ranges, additional headers, etc.
|
25
27
|
network_id_tuple = case country_code
|
28
|
+
when 'PR' # Claro Puerto Rico:
|
29
|
+
{ mcc: "330", mnc: "110" }
|
26
30
|
when 'MX' # Telcel México:
|
27
|
-
{ mcc: "334", mnc: "020"
|
31
|
+
{ mcc: "334", mnc: "020" }
|
28
32
|
when 'GT' # Claro Guatemala:
|
29
|
-
{ mcc: "704", mnc: "01"
|
33
|
+
{ mcc: "704", mnc: "01" }
|
30
34
|
when 'SV' # Claro El Salvador:
|
31
35
|
{ mcc: "706", mnc: "01" }
|
32
36
|
when 'HN' # Claro Honduras:
|
33
|
-
{ mcc: "708", mnc: "001"
|
37
|
+
{ mcc: "708", mnc: "001" }
|
34
38
|
when 'NI' # Claro Nicaragua:
|
35
39
|
{ mcc: "710", mnc: "21" }
|
36
40
|
when 'CR' # Claro Costa Rica
|
37
41
|
{ mcc: "712", mnc: "03" }
|
38
42
|
when 'AR' # Claro Argentina:
|
39
|
-
{ mcc: "722", mnc: "330"
|
43
|
+
{ mcc: "722", mnc: "330" }
|
40
44
|
end
|
41
45
|
|
42
46
|
# Return only if we identified the network:
|
@@ -41,6 +41,7 @@ module MobileSubscriber::Detection
|
|
41
41
|
'X-Wap-Msisdn',
|
42
42
|
'X-Wap-Sesiones3g-Mdn', # Not in referenced literature
|
43
43
|
'X-Wsb-Cli',
|
44
|
+
'X-Ztgo-Beareraddress', # Not in referenced literature
|
44
45
|
|
45
46
|
# Headers that contain bearer information:
|
46
47
|
# http://www.mulliner.org/collin/academic/publications/mobile_web_privacy_icin10_mulliner.pdf
|
@@ -2,6 +2,9 @@ module MobileSubscriber
|
|
2
2
|
# See: http://countrycode.org/
|
3
3
|
# Diccionario de Dialing Country Codes => ISO country codes:
|
4
4
|
DIALING_COUNTRY_CODES = {
|
5
|
+
# WTF???
|
6
|
+
'1' => 'PR', # Puerto Rico "1" country code...
|
7
|
+
|
5
8
|
# Caribbean Islands' country codes are a mess!
|
6
9
|
'1809' => 'DO', # Dominican Republic
|
7
10
|
'1829' => 'DO', # Dominican Republic Overlay 1
|
@@ -45,6 +45,16 @@ describe MobileSubscriber::Detection::FromXNokiaMsisdnHttpRequestHeader do
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
context "when given a request made from Claro Puerto Rico" do
|
49
|
+
let(:test_request) { build :mobile_request_from_claro_puerto_rico }
|
50
|
+
|
51
|
+
include_examples "of detection of msisdn from a valid puerto rican mobile network http request"
|
52
|
+
|
53
|
+
it "has a :mobile_network_code value of '110'" do
|
54
|
+
expect(subject[:mobile_network_code]).to eq '110'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
48
58
|
context "when given a request made from Claro Guatemala" do
|
49
59
|
let(:test_request) { build :mobile_request_from_claro_guatemala }
|
50
60
|
|
data/spec/factories/requests.rb
CHANGED
@@ -100,6 +100,16 @@ FactoryGirl.define do
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
+
# TODO: Replace with a real example request:
|
104
|
+
factory :mobile_request_from_claro_puerto_rico do
|
105
|
+
initialize_with do
|
106
|
+
new build(:common_mobile_request_env).merge(
|
107
|
+
"REMOTE_ADDR" => "64.237.130.12",
|
108
|
+
"HTTP_X_NOKIA_MSISDN" => "17872889401" # 1-787-XXXXXXXX
|
109
|
+
)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
103
113
|
# http://myip.ms/view/ip_owners/80612/Conecel.html
|
104
114
|
factory :mobile_request_from_claro_ecuador do
|
105
115
|
initialize_with do
|
@@ -114,6 +114,17 @@ shared_examples "of detection of msisdn from a valid costa rican mobile network
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
+
shared_examples "of detection of msisdn from a valid puerto rican mobile network http request" do
|
118
|
+
include_examples "of detection of msisdn from a valid mobile network http request"
|
119
|
+
it "has an :id value that starts with '1'" do
|
120
|
+
expect(subject[:id]).to match /\A1/
|
121
|
+
end
|
122
|
+
|
123
|
+
it "has a :mobile_country_code value of '330'" do
|
124
|
+
expect(subject[:mobile_country_code]).to eq '330'
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
117
128
|
shared_examples "of detection of msisdn from a valid colombian mobile network http request" do
|
118
129
|
include_examples "of detection of msisdn from a valid mobile network http request"
|
119
130
|
it "has an :id value that starts with '57'" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mobile-subscriber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.alpha3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Quintanilla
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|