rpush_extended 3.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +365 -0
- data/LICENSE +7 -0
- data/README.md +393 -0
- data/bin/rpush +4 -0
- data/lib/generators/rpush_config_generator.rb +7 -0
- data/lib/generators/rpush_migration_generator.rb +66 -0
- data/lib/generators/templates/add_adm.rb +23 -0
- data/lib/generators/templates/add_alert_is_json_to_rapns_notifications.rb +9 -0
- data/lib/generators/templates/add_app_to_rapns.rb +11 -0
- data/lib/generators/templates/add_fail_after_to_rpush_notifications.rb +9 -0
- data/lib/generators/templates/add_gcm.rb +117 -0
- data/lib/generators/templates/add_rpush.rb +402 -0
- data/lib/generators/templates/add_wpns.rb +16 -0
- data/lib/generators/templates/create_rapns_apps.rb +16 -0
- data/lib/generators/templates/create_rapns_feedback.rb +25 -0
- data/lib/generators/templates/create_rapns_notifications.rb +36 -0
- data/lib/generators/templates/rename_rapns_to_rpush.rb +87 -0
- data/lib/generators/templates/rpush.rb +135 -0
- data/lib/generators/templates/rpush_2_0_0_updates.rb +79 -0
- data/lib/generators/templates/rpush_2_1_0_updates.rb +11 -0
- data/lib/generators/templates/rpush_2_6_0_updates.rb +10 -0
- data/lib/generators/templates/rpush_2_7_0_updates.rb +12 -0
- data/lib/generators/templates/rpush_3_0_0_updates.rb +11 -0
- data/lib/generators/templates/rpush_3_0_1_updates.rb +13 -0
- data/lib/generators/templates/rpush_3_1_0_add_pushy.rb +9 -0
- data/lib/generators/templates/rpush_3_1_1_updates.rb +15 -0
- data/lib/generators/templates/rpush_3_2_0_add_apns_p8.rb +15 -0
- data/lib/generators/templates/rpush_3_2_4_updates.rb +9 -0
- data/lib/generators/templates/rpush_3_3_0_updates.rb +9 -0
- data/lib/generators/templates/rpush_3_3_1_updates.rb +11 -0
- data/lib/rpush/apns_feedback.rb +17 -0
- data/lib/rpush/cli.rb +213 -0
- data/lib/rpush/client/active_model/adm/app.rb +23 -0
- data/lib/rpush/client/active_model/adm/data_validator.rb +14 -0
- data/lib/rpush/client/active_model/adm/notification.rb +28 -0
- data/lib/rpush/client/active_model/apns/app.rb +37 -0
- data/lib/rpush/client/active_model/apns/binary_notification_validator.rb +16 -0
- data/lib/rpush/client/active_model/apns/device_token_format_validator.rb +14 -0
- data/lib/rpush/client/active_model/apns/notification.rb +104 -0
- data/lib/rpush/client/active_model/apns2/app.rb +15 -0
- data/lib/rpush/client/active_model/apns2/notification.rb +9 -0
- data/lib/rpush/client/active_model/apnsp8/app.rb +23 -0
- data/lib/rpush/client/active_model/apnsp8/notification.rb +9 -0
- data/lib/rpush/client/active_model/gcm/app.rb +19 -0
- data/lib/rpush/client/active_model/gcm/expiry_collapse_key_mutual_inclusion_validator.rb +14 -0
- data/lib/rpush/client/active_model/gcm/notification.rb +59 -0
- data/lib/rpush/client/active_model/notification.rb +22 -0
- data/lib/rpush/client/active_model/payload_data_size_validator.rb +13 -0
- data/lib/rpush/client/active_model/pushy/app.rb +20 -0
- data/lib/rpush/client/active_model/pushy/notification.rb +31 -0
- data/lib/rpush/client/active_model/pushy/time_to_live_validator.rb +14 -0
- data/lib/rpush/client/active_model/registration_ids_count_validator.rb +13 -0
- data/lib/rpush/client/active_model/wns/app.rb +23 -0
- data/lib/rpush/client/active_model/wns/notification.rb +32 -0
- data/lib/rpush/client/active_model/wpns/app.rb +13 -0
- data/lib/rpush/client/active_model/wpns/notification.rb +28 -0
- data/lib/rpush/client/active_model.rb +34 -0
- data/lib/rpush/client/active_record/adm/app.rb +11 -0
- data/lib/rpush/client/active_record/adm/notification.rb +11 -0
- data/lib/rpush/client/active_record/apns/app.rb +11 -0
- data/lib/rpush/client/active_record/apns/feedback.rb +18 -0
- data/lib/rpush/client/active_record/apns/notification.rb +40 -0
- data/lib/rpush/client/active_record/apns2/app.rb +11 -0
- data/lib/rpush/client/active_record/apns2/notification.rb +10 -0
- data/lib/rpush/client/active_record/apnsp8/app.rb +11 -0
- data/lib/rpush/client/active_record/apnsp8/notification.rb +10 -0
- data/lib/rpush/client/active_record/app.rb +13 -0
- data/lib/rpush/client/active_record/gcm/app.rb +11 -0
- data/lib/rpush/client/active_record/gcm/notification.rb +11 -0
- data/lib/rpush/client/active_record/notification.rb +42 -0
- data/lib/rpush/client/active_record/pushy/app.rb +11 -0
- data/lib/rpush/client/active_record/pushy/notification.rb +11 -0
- data/lib/rpush/client/active_record/wns/app.rb +11 -0
- data/lib/rpush/client/active_record/wns/badge_notification.rb +15 -0
- data/lib/rpush/client/active_record/wns/notification.rb +11 -0
- data/lib/rpush/client/active_record/wns/raw_notification.rb +13 -0
- data/lib/rpush/client/active_record/wpns/app.rb +11 -0
- data/lib/rpush/client/active_record/wpns/notification.rb +11 -0
- data/lib/rpush/client/active_record.rb +33 -0
- data/lib/rpush/client/redis/adm/app.rb +14 -0
- data/lib/rpush/client/redis/adm/notification.rb +11 -0
- data/lib/rpush/client/redis/apns/app.rb +11 -0
- data/lib/rpush/client/redis/apns/feedback.rb +20 -0
- data/lib/rpush/client/redis/apns/notification.rb +11 -0
- data/lib/rpush/client/redis/apns2/app.rb +11 -0
- data/lib/rpush/client/redis/apns2/notification.rb +11 -0
- data/lib/rpush/client/redis/apnsp8/app.rb +11 -0
- data/lib/rpush/client/redis/apnsp8/notification.rb +11 -0
- data/lib/rpush/client/redis/app.rb +29 -0
- data/lib/rpush/client/redis/gcm/app.rb +11 -0
- data/lib/rpush/client/redis/gcm/notification.rb +11 -0
- data/lib/rpush/client/redis/notification.rb +74 -0
- data/lib/rpush/client/redis/pushy/app.rb +16 -0
- data/lib/rpush/client/redis/pushy/notification.rb +18 -0
- data/lib/rpush/client/redis/wns/app.rb +14 -0
- data/lib/rpush/client/redis/wns/badge_notification.rb +15 -0
- data/lib/rpush/client/redis/wns/notification.rb +11 -0
- data/lib/rpush/client/redis/wns/raw_notification.rb +11 -0
- data/lib/rpush/client/redis/wpns/app.rb +11 -0
- data/lib/rpush/client/redis/wpns/notification.rb +11 -0
- data/lib/rpush/client/redis.rb +56 -0
- data/lib/rpush/configuration.rb +115 -0
- data/lib/rpush/daemon/adm/delivery.rb +226 -0
- data/lib/rpush/daemon/adm.rb +9 -0
- data/lib/rpush/daemon/apns/delivery.rb +43 -0
- data/lib/rpush/daemon/apns/feedback_receiver.rb +90 -0
- data/lib/rpush/daemon/apns.rb +17 -0
- data/lib/rpush/daemon/apns2/delivery.rb +127 -0
- data/lib/rpush/daemon/apns2.rb +10 -0
- data/lib/rpush/daemon/apnsp8/delivery.rb +166 -0
- data/lib/rpush/daemon/apnsp8/token.rb +43 -0
- data/lib/rpush/daemon/apnsp8.rb +10 -0
- data/lib/rpush/daemon/app_runner.rb +190 -0
- data/lib/rpush/daemon/batch.rb +138 -0
- data/lib/rpush/daemon/constants.rb +59 -0
- data/lib/rpush/daemon/delivery.rb +46 -0
- data/lib/rpush/daemon/delivery_error.rb +27 -0
- data/lib/rpush/daemon/dispatcher/apns_http2.rb +51 -0
- data/lib/rpush/daemon/dispatcher/apns_tcp.rb +152 -0
- data/lib/rpush/daemon/dispatcher/apnsp8_http2.rb +33 -0
- data/lib/rpush/daemon/dispatcher/http.rb +21 -0
- data/lib/rpush/daemon/dispatcher/tcp.rb +22 -0
- data/lib/rpush/daemon/dispatcher_loop.rb +73 -0
- data/lib/rpush/daemon/errors.rb +18 -0
- data/lib/rpush/daemon/feeder.rb +69 -0
- data/lib/rpush/daemon/gcm/delivery.rb +241 -0
- data/lib/rpush/daemon/gcm.rb +9 -0
- data/lib/rpush/daemon/interruptible_sleep.rb +24 -0
- data/lib/rpush/daemon/loggable.rb +33 -0
- data/lib/rpush/daemon/proc_title.rb +17 -0
- data/lib/rpush/daemon/pushy/delivery.rb +90 -0
- data/lib/rpush/daemon/pushy.rb +9 -0
- data/lib/rpush/daemon/queue_payload.rb +12 -0
- data/lib/rpush/daemon/retry_header_parser.rb +23 -0
- data/lib/rpush/daemon/retryable_error.rb +22 -0
- data/lib/rpush/daemon/ring_buffer.rb +16 -0
- data/lib/rpush/daemon/rpc/client.rb +27 -0
- data/lib/rpush/daemon/rpc/server.rb +82 -0
- data/lib/rpush/daemon/rpc.rb +9 -0
- data/lib/rpush/daemon/service_config_methods.rb +51 -0
- data/lib/rpush/daemon/signal_handler.rb +75 -0
- data/lib/rpush/daemon/store/active_record/reconnectable.rb +80 -0
- data/lib/rpush/daemon/store/active_record.rb +214 -0
- data/lib/rpush/daemon/store/interface.rb +20 -0
- data/lib/rpush/daemon/store/redis.rb +166 -0
- data/lib/rpush/daemon/string_helpers.rb +15 -0
- data/lib/rpush/daemon/synchronizer.rb +62 -0
- data/lib/rpush/daemon/tcp_connection.rb +190 -0
- data/lib/rpush/daemon/wns/badge_request.rb +32 -0
- data/lib/rpush/daemon/wns/delivery.rb +178 -0
- data/lib/rpush/daemon/wns/post_request.rb +33 -0
- data/lib/rpush/daemon/wns/raw_request.rb +22 -0
- data/lib/rpush/daemon/wns/toast_request.rb +54 -0
- data/lib/rpush/daemon/wns.rb +9 -0
- data/lib/rpush/daemon/wpns/delivery.rb +132 -0
- data/lib/rpush/daemon/wpns.rb +9 -0
- data/lib/rpush/daemon.rb +179 -0
- data/lib/rpush/deprecatable.rb +24 -0
- data/lib/rpush/deprecation.rb +26 -0
- data/lib/rpush/embed.rb +41 -0
- data/lib/rpush/logger.rb +92 -0
- data/lib/rpush/multi_json_helper.rb +16 -0
- data/lib/rpush/plugin.rb +44 -0
- data/lib/rpush/push.rb +11 -0
- data/lib/rpush/reflectable.rb +13 -0
- data/lib/rpush/reflection_collection.rb +44 -0
- data/lib/rpush/reflection_public_methods.rb +11 -0
- data/lib/rpush/version.rb +14 -0
- data/lib/rpush.rb +43 -0
- data/lib/tasks/quality.rake +35 -0
- data/lib/tasks/test.rake +69 -0
- data/spec/.rubocop.yml +4 -0
- data/spec/functional/adm_spec.rb +50 -0
- data/spec/functional/apns2_spec.rb +232 -0
- data/spec/functional/apns_spec.rb +162 -0
- data/spec/functional/cli_spec.rb +36 -0
- data/spec/functional/embed_spec.rb +49 -0
- data/spec/functional/gcm_spec.rb +46 -0
- data/spec/functional/new_app_spec.rb +44 -0
- data/spec/functional/pushy_spec.rb +22 -0
- data/spec/functional/retry_spec.rb +42 -0
- data/spec/functional/synchronization_spec.rb +97 -0
- data/spec/functional/wpns_spec.rb +71 -0
- data/spec/functional_spec_helper.rb +32 -0
- data/spec/spec_helper.rb +69 -0
- data/spec/support/active_record_setup.rb +73 -0
- data/spec/support/cert_with_password.pem +90 -0
- data/spec/support/cert_without_password.pem +59 -0
- data/spec/support/config/database.yml +44 -0
- data/spec/support/simplecov_helper.rb +24 -0
- data/spec/support/simplecov_quality_formatter.rb +12 -0
- data/spec/tmp/.gitkeep +0 -0
- data/spec/unit/apns_feedback_spec.rb +28 -0
- data/spec/unit/client/active_record/adm/app_spec.rb +58 -0
- data/spec/unit/client/active_record/adm/notification_spec.rb +43 -0
- data/spec/unit/client/active_record/apns/app_spec.rb +29 -0
- data/spec/unit/client/active_record/apns/feedback_spec.rb +9 -0
- data/spec/unit/client/active_record/apns/notification_spec.rb +324 -0
- data/spec/unit/client/active_record/app_spec.rb +30 -0
- data/spec/unit/client/active_record/gcm/app_spec.rb +4 -0
- data/spec/unit/client/active_record/gcm/notification_spec.rb +67 -0
- data/spec/unit/client/active_record/notification_spec.rb +21 -0
- data/spec/unit/client/active_record/pushy/app_spec.rb +17 -0
- data/spec/unit/client/active_record/pushy/notification_spec.rb +65 -0
- data/spec/unit/client/active_record/wns/badge_notification_spec.rb +15 -0
- data/spec/unit/client/active_record/wns/raw_notification_spec.rb +26 -0
- data/spec/unit/client/active_record/wpns/app_spec.rb +4 -0
- data/spec/unit/client/active_record/wpns/notification_spec.rb +21 -0
- data/spec/unit/configuration_spec.rb +46 -0
- data/spec/unit/daemon/adm/delivery_spec.rb +253 -0
- data/spec/unit/daemon/apns/certificate_expired_error_spec.rb +11 -0
- data/spec/unit/daemon/apns/delivery_spec.rb +108 -0
- data/spec/unit/daemon/apns/feedback_receiver_spec.rb +119 -0
- data/spec/unit/daemon/app_runner_spec.rb +188 -0
- data/spec/unit/daemon/batch_spec.rb +169 -0
- data/spec/unit/daemon/delivery_error_spec.rb +13 -0
- data/spec/unit/daemon/delivery_spec.rb +51 -0
- data/spec/unit/daemon/dispatcher/http_spec.rb +34 -0
- data/spec/unit/daemon/dispatcher/tcp_spec.rb +32 -0
- data/spec/unit/daemon/dispatcher_loop_spec.rb +53 -0
- data/spec/unit/daemon/feeder_spec.rb +96 -0
- data/spec/unit/daemon/gcm/delivery_spec.rb +387 -0
- data/spec/unit/daemon/proc_title_spec.rb +11 -0
- data/spec/unit/daemon/pushy/delivery_spec.rb +159 -0
- data/spec/unit/daemon/retryable_error_spec.rb +14 -0
- data/spec/unit/daemon/service_config_methods_spec.rb +36 -0
- data/spec/unit/daemon/signal_handler_spec.rb +99 -0
- data/spec/unit/daemon/store/active_record/reconnectable_spec.rb +165 -0
- data/spec/unit/daemon/store/active_record_spec.rb +357 -0
- data/spec/unit/daemon/store/redis_spec.rb +365 -0
- data/spec/unit/daemon/tcp_connection_spec.rb +292 -0
- data/spec/unit/daemon/wns/delivery_spec.rb +176 -0
- data/spec/unit/daemon/wns/post_request_spec.rb +117 -0
- data/spec/unit/daemon/wpns/delivery_spec.rb +167 -0
- data/spec/unit/daemon_spec.rb +138 -0
- data/spec/unit/deprecatable_spec.rb +32 -0
- data/spec/unit/deprecation_spec.rb +15 -0
- data/spec/unit/embed_spec.rb +47 -0
- data/spec/unit/logger_spec.rb +127 -0
- data/spec/unit/notification_shared.rb +53 -0
- data/spec/unit/plugin_spec.rb +36 -0
- data/spec/unit/push_spec.rb +34 -0
- data/spec/unit/reflectable_spec.rb +27 -0
- data/spec/unit/reflection_collection_spec.rb +26 -0
- data/spec/unit/rpush_spec.rb +8 -0
- data/spec/unit_spec_helper.rb +26 -0
- metadata +709 -0
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'functional_spec_helper'
|
2
|
+
|
3
|
+
describe 'Synchronization' do
|
4
|
+
let(:timeout) { 10 }
|
5
|
+
let(:app) { Rpush::Gcm::App.new }
|
6
|
+
|
7
|
+
def wait_for_num_dispatchers(num)
|
8
|
+
Timeout.timeout(timeout) do
|
9
|
+
until Rpush::Daemon::AppRunner.num_dispatchers_for_app(app) == num
|
10
|
+
sleep 0.1
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
before do
|
16
|
+
app.name = 'test'
|
17
|
+
app.auth_key = 'abc123'
|
18
|
+
app.client_id = 'client'
|
19
|
+
app.client_secret = 'secret'
|
20
|
+
app.connections = 2
|
21
|
+
app.certificate = TEST_CERT_WITH_PASSWORD
|
22
|
+
app.password = 'fubar'
|
23
|
+
app.environment = 'sandbox'
|
24
|
+
app.save!
|
25
|
+
|
26
|
+
Rpush.embed
|
27
|
+
wait_for_num_dispatchers(app.connections)
|
28
|
+
end
|
29
|
+
|
30
|
+
after { Timeout.timeout(timeout) { Rpush.shutdown } }
|
31
|
+
|
32
|
+
it 'increments the number of dispatchers' do
|
33
|
+
app.connections += 1
|
34
|
+
app.save!
|
35
|
+
Rpush.sync
|
36
|
+
wait_for_num_dispatchers(app.connections)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'decrements the number of dispatchers' do
|
40
|
+
app.connections -= 1
|
41
|
+
app.save!
|
42
|
+
Rpush.sync
|
43
|
+
wait_for_num_dispatchers(app.connections)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'stops a deleted app' do
|
47
|
+
app.destroy
|
48
|
+
Rpush.sync
|
49
|
+
expect(Rpush::Daemon::AppRunner.app_running?(app)).to eq(false)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'restarts an app when the certificate is changed' do
|
53
|
+
app.certificate = TEST_CERT
|
54
|
+
app.password = nil
|
55
|
+
app.save!
|
56
|
+
Rpush.sync
|
57
|
+
|
58
|
+
running_app = Rpush::Daemon::AppRunner.app_with_id(app.id)
|
59
|
+
expect(running_app.certificate).to eql(TEST_CERT)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'restarts an app when the environment is changed' do
|
63
|
+
app.environment = 'production'
|
64
|
+
app.save!
|
65
|
+
Rpush.sync
|
66
|
+
|
67
|
+
running_app = Rpush::Daemon::AppRunner.app_with_id(app.id)
|
68
|
+
expect(running_app.environment).to eql('production')
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'restarts an app when the auth_key is changed' do
|
72
|
+
app.auth_key = '321cba'
|
73
|
+
app.save!
|
74
|
+
Rpush.sync
|
75
|
+
|
76
|
+
running_app = Rpush::Daemon::AppRunner.app_with_id(app.id)
|
77
|
+
expect(running_app.auth_key).to eql('321cba')
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'restarts an app when the client_id is changed' do
|
81
|
+
app.client_id = 'another_client'
|
82
|
+
app.save!
|
83
|
+
Rpush.sync
|
84
|
+
|
85
|
+
running_app = Rpush::Daemon::AppRunner.app_with_id(app.id)
|
86
|
+
expect(running_app.client_id).to eql('another_client')
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'restarts an app when the client_secret is changed' do
|
90
|
+
app.client_secret = 'another_secret'
|
91
|
+
app.save!
|
92
|
+
Rpush.sync
|
93
|
+
|
94
|
+
running_app = Rpush::Daemon::AppRunner.app_with_id(app.id)
|
95
|
+
expect(running_app.client_secret).to eql('another_secret')
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'functional_spec_helper'
|
2
|
+
|
3
|
+
describe 'WPNs' do
|
4
|
+
let(:app) { Rpush::Wpns::App.new }
|
5
|
+
let(:notification_with_data) { Rpush::Wpns::Notification.new }
|
6
|
+
let(:notification_with_alert) { Rpush::Wpns::Notification.new }
|
7
|
+
let(:response) { double(Net::HTTPResponse, code: 200) }
|
8
|
+
let(:http) { double(Net::HTTP::Persistent, request: response, shutdown: nil) }
|
9
|
+
|
10
|
+
before do
|
11
|
+
app.name = 'test'
|
12
|
+
app.save!
|
13
|
+
|
14
|
+
notification_with_data.app = app
|
15
|
+
notification_with_data.uri = 'http://sn1.notify.live.net/'
|
16
|
+
notification_with_data.data = { title: "MyApp", body: "test", param: "new_user" }
|
17
|
+
notification_with_data.save!
|
18
|
+
|
19
|
+
notification_with_alert.app = app
|
20
|
+
notification_with_alert.uri = 'http://sn1.notify.live.net/'
|
21
|
+
notification_with_alert.alert = "Hello world!"
|
22
|
+
notification_with_alert.save!
|
23
|
+
|
24
|
+
allow(Net::HTTP::Persistent).to receive_messages(new: http)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'delivers a notification with data successfully' do
|
28
|
+
allow(response).to receive_messages(to_hash: { 'x-notificationstatus' => ['Received'] })
|
29
|
+
|
30
|
+
expect do
|
31
|
+
Rpush.push
|
32
|
+
notification_with_data.reload
|
33
|
+
end.to change(notification_with_data, :delivered).to(true)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'fails to deliver a notification with data successfully' do
|
37
|
+
allow(response).to receive_messages(code: 400)
|
38
|
+
|
39
|
+
expect do
|
40
|
+
Rpush.push
|
41
|
+
notification_with_data.reload
|
42
|
+
end.to change(notification_with_data, :failed_at)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'delivers a notification with an alert successfully' do
|
46
|
+
allow(response).to receive_messages(to_hash: { 'x-notificationstatus' => ['Received'] })
|
47
|
+
|
48
|
+
expect do
|
49
|
+
Rpush.push
|
50
|
+
notification_with_alert.reload
|
51
|
+
end.to change(notification_with_alert, :delivered).to(true)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'fails to deliver a notification with an alert successfully' do
|
55
|
+
allow(response).to receive_messages(code: 400)
|
56
|
+
|
57
|
+
expect do
|
58
|
+
Rpush.push
|
59
|
+
notification_with_alert.reload
|
60
|
+
end.to change(notification_with_alert, :failed_at)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'retries notification that fail due to a SocketError' do
|
64
|
+
expect(http).to receive(:request).and_raise(SocketError.new).twice
|
65
|
+
expect(notification_with_data.deliver_after).to be_nil
|
66
|
+
expect do
|
67
|
+
Rpush.push
|
68
|
+
notification_with_data.reload
|
69
|
+
end.to change(notification_with_data, :deliver_after).to(kind_of(Time))
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'database_cleaner'
|
4
|
+
DatabaseCleaner.strategy = :truncation
|
5
|
+
|
6
|
+
def functional_example?(metadata)
|
7
|
+
metadata[:file_path] =~ %r{/spec/functional/}
|
8
|
+
end
|
9
|
+
|
10
|
+
def timeout(&blk)
|
11
|
+
Timeout.timeout(10, &blk)
|
12
|
+
end
|
13
|
+
|
14
|
+
def stub_tcp_connection(tcp_socket, ssl_socket, io_double)
|
15
|
+
allow_any_instance_of(Rpush::Daemon::TcpConnection).to receive_messages(connect_socket: [tcp_socket, ssl_socket])
|
16
|
+
allow_any_instance_of(Rpush::Daemon::TcpConnection).to receive_messages(setup_ssl_context: double.as_null_object)
|
17
|
+
stub_const('Rpush::Daemon::TcpConnection::IO', io_double)
|
18
|
+
end
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
config.before(:each) do
|
22
|
+
Modis.with_connection do |redis|
|
23
|
+
redis.keys('rpush:*').each { |key| redis.del(key) }
|
24
|
+
end if redis?
|
25
|
+
|
26
|
+
Rpush.config.logger = ::Logger.new(STDOUT) if functional_example?(self.class.metadata)
|
27
|
+
end
|
28
|
+
|
29
|
+
config.after(:each) do
|
30
|
+
DatabaseCleaner.clean if active_record? && functional_example?(self.class.metadata)
|
31
|
+
end
|
32
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
ENV['RAILS_ENV'] = 'test'
|
2
|
+
def client
|
3
|
+
(ENV['CLIENT'] || :active_record).to_sym
|
4
|
+
end
|
5
|
+
|
6
|
+
if !ENV['TRAVIS'] || (ENV['TRAVIS'] && ENV['QUALITY'] == 'true')
|
7
|
+
begin
|
8
|
+
require './spec/support/simplecov_helper'
|
9
|
+
include SimpleCovHelper
|
10
|
+
start_simple_cov("rpush-#{client}-#{RUBY_VERSION}")
|
11
|
+
rescue LoadError
|
12
|
+
puts "Coverage disabled."
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
require 'timecop'
|
17
|
+
require 'activerecord-jdbc-adapter' if defined? JRUBY_VERSION
|
18
|
+
|
19
|
+
require 'rpush'
|
20
|
+
require 'rpush/daemon'
|
21
|
+
require 'rpush/client/redis'
|
22
|
+
require 'rpush/client/active_record'
|
23
|
+
require 'rpush/daemon/store/active_record'
|
24
|
+
require 'rpush/daemon/store/redis'
|
25
|
+
|
26
|
+
def active_record?
|
27
|
+
client == :active_record
|
28
|
+
end
|
29
|
+
|
30
|
+
def redis?
|
31
|
+
client == :redis
|
32
|
+
end
|
33
|
+
|
34
|
+
require 'support/active_record_setup' if active_record?
|
35
|
+
|
36
|
+
RPUSH_ROOT = '/tmp/rails_root'
|
37
|
+
|
38
|
+
Rpush.configure do |config|
|
39
|
+
config.client = client
|
40
|
+
config.log_level = ::Logger::Severity::DEBUG
|
41
|
+
end
|
42
|
+
|
43
|
+
RPUSH_CLIENT = Rpush.config.client
|
44
|
+
|
45
|
+
path = File.join(File.dirname(__FILE__), 'support')
|
46
|
+
TEST_CERT = File.read(File.join(path, 'cert_without_password.pem'))
|
47
|
+
TEST_CERT_WITH_PASSWORD = File.read(File.join(path, 'cert_with_password.pem'))
|
48
|
+
|
49
|
+
def after_example_cleanup
|
50
|
+
Rpush.logger = nil
|
51
|
+
Rpush::Daemon.store = nil
|
52
|
+
Rpush::Deprecation.muted do
|
53
|
+
Rpush.config = nil
|
54
|
+
Rpush.config.client = RPUSH_CLIENT
|
55
|
+
end
|
56
|
+
Rpush.plugins.values.each(&:unload)
|
57
|
+
Rpush.instance_variable_set('@plugins', {})
|
58
|
+
end
|
59
|
+
|
60
|
+
RSpec.configure do |config|
|
61
|
+
config.before(:each) do
|
62
|
+
Rpush.config.log_file = File.join(RPUSH_ROOT, 'rpush.log')
|
63
|
+
allow(Rpush).to receive(:root) { RPUSH_ROOT }
|
64
|
+
end
|
65
|
+
|
66
|
+
config.after(:each) do
|
67
|
+
after_example_cleanup
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
|
3
|
+
jruby = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
|
4
|
+
|
5
|
+
SPEC_ADAPTER = ENV['ADAPTER'] || 'postgresql'
|
6
|
+
SPEC_ADAPTER = 'jdbc' + SPEC_ADAPTER if jruby
|
7
|
+
|
8
|
+
require 'yaml'
|
9
|
+
db_config = YAML.load_file(File.expand_path("config/database.yml", File.dirname(__FILE__)))
|
10
|
+
|
11
|
+
if db_config[SPEC_ADAPTER].nil?
|
12
|
+
puts "No such adapter '#{SPEC_ADAPTER}'. Valid adapters are #{db_config.keys.join(', ')}."
|
13
|
+
exit 1
|
14
|
+
end
|
15
|
+
|
16
|
+
if ENV['TRAVIS']
|
17
|
+
db_config[SPEC_ADAPTER]['username'] = 'postgres'
|
18
|
+
else
|
19
|
+
require 'etc'
|
20
|
+
username = SPEC_ADAPTER =~ /mysql/ ? 'root' : Etc.getlogin
|
21
|
+
db_config[SPEC_ADAPTER]['username'] = username
|
22
|
+
end
|
23
|
+
|
24
|
+
puts "Using #{SPEC_ADAPTER} adapter."
|
25
|
+
|
26
|
+
ActiveRecord::Base.configurations = { "test" => db_config[SPEC_ADAPTER] }
|
27
|
+
ActiveRecord::Base.establish_connection(db_config[SPEC_ADAPTER])
|
28
|
+
|
29
|
+
require 'generators/templates/add_rpush'
|
30
|
+
require 'generators/templates/rpush_2_0_0_updates'
|
31
|
+
require 'generators/templates/rpush_2_1_0_updates'
|
32
|
+
require 'generators/templates/rpush_2_6_0_updates'
|
33
|
+
require 'generators/templates/rpush_2_7_0_updates'
|
34
|
+
require 'generators/templates/rpush_3_0_0_updates'
|
35
|
+
require 'generators/templates/rpush_3_0_1_updates'
|
36
|
+
require 'generators/templates/rpush_3_1_0_add_pushy'
|
37
|
+
require 'generators/templates/rpush_3_1_1_updates'
|
38
|
+
require 'generators/templates/rpush_3_2_0_add_apns_p8'
|
39
|
+
require 'generators/templates/rpush_3_2_4_updates'
|
40
|
+
require 'generators/templates/rpush_3_3_0_updates'
|
41
|
+
require 'generators/templates/rpush_3_3_1_updates'
|
42
|
+
|
43
|
+
migrations = [
|
44
|
+
AddRpush,
|
45
|
+
Rpush200Updates,
|
46
|
+
Rpush210Updates,
|
47
|
+
Rpush260Updates,
|
48
|
+
Rpush270Updates,
|
49
|
+
Rpush300Updates,
|
50
|
+
Rpush301Updates,
|
51
|
+
Rpush310AddPushy,
|
52
|
+
Rpush311Updates,
|
53
|
+
Rpush320AddApnsP8,
|
54
|
+
Rpush324Updates,
|
55
|
+
Rpush330Updates,
|
56
|
+
Rpush331Updates
|
57
|
+
]
|
58
|
+
|
59
|
+
unless ENV['TRAVIS']
|
60
|
+
migrations.reverse_each do |m|
|
61
|
+
begin
|
62
|
+
m.down
|
63
|
+
rescue ActiveRecord::StatementInvalid => e
|
64
|
+
p e
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
migrations.each(&:up)
|
70
|
+
|
71
|
+
Rpush::Client::ActiveRecord::Notification.reset_column_information
|
72
|
+
Rpush::Client::ActiveRecord::App.reset_column_information
|
73
|
+
Rpush::Client::ActiveRecord::Apns::Feedback.reset_column_information
|
@@ -0,0 +1,90 @@
|
|
1
|
+
Bag Attributes
|
2
|
+
localKeyID: A4 1A DB 3E 3E 45 D9 C7 51 1E E6 DC 4E BC 29 19 E4 22 95 35
|
3
|
+
subject=/C=AU/ST=Some-State/O=Internet Widgits Pty Ltd
|
4
|
+
issuer=/C=UK/ST=Some-State/O=Internet Widgits Pty Ltd
|
5
|
+
-----BEGIN CERTIFICATE-----
|
6
|
+
MIIE/jCCAuYCAQEwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCVUsxEzARBgNV
|
7
|
+
BAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdp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grUHduLqOPDqLT5gefGRrL5fDqb86G08+Wz+Tnn1YmH+7
|
23
|
+
rfiQhCrdi4zxRv6ZEaKZeEm/q1UMttuUdXuzd25BEEtav4R0POdR+H1q3trlS0ol
|
24
|
+
EcWlAbRgVaT2tTyKGAW54fH8vZPqS6IP+mXIzfaOFECPEgAO8BL8t7hBDpkL4ASO
|
25
|
+
HbU7ktYamsr6PAei3kXAnJ1thXyQqrhelwLrQJyM8RVOJYUgVbl6Fpdtgu7YQF5G
|
26
|
+
kxTAfshSmDCQkf+tbUEs44rZ6BZ2TWnbXjQGkRntHcMCP/1rjsPPdX3oeZ7P3jMQ
|
27
|
+
XER3drdm1mOiSdDUKbem9GzQ9Dx7WkwKNLYAZ+IWzVRACzGxnkxXyxOEFIgesDgg
|
28
|
+
RIhczN+eLIR8iwcUxEVKFmmsbEIve3Uh1/NE6xGudbfZDNfhyOhiNYIBnQqVkk8l
|
29
|
+
c3gw2UDR3lXTayiiXhK2l1etsyxtYncT3pgDsCe72RODrGKbASt3FzfBbalzN0GG
|
30
|
+
9tiPSNtGqCch9q4eHfViUh9s3+8n4bknAYcwzQ96+gMEn8PUVtDBv9F8Kxffn/Jt
|
31
|
+
XMWKX76nTVuAuCLkXxrKwc01lq8SeuvCH650xsv0LBvxj9h6vR34vHGrj0C3sH2E
|
32
|
+
VQpelKNv8IEwkSiQcwDtU8H0jaPJNqmYlkrxasSrSeg6PA==
|
33
|
+
-----END CERTIFICATE-----
|
34
|
+
Bag Attributes
|
35
|
+
localKeyID: A4 1A DB 3E 3E 45 D9 C7 51 1E E6 DC 4E BC 29 19 E4 22 95 35
|
36
|
+
Key Attributes: <No Attributes>
|
37
|
+
-----BEGIN RSA PRIVATE KEY-----
|
38
|
+
Proc-Type: 4,ENCRYPTED
|
39
|
+
DEK-Info: DES-EDE3-CBC,874F2C982467BF08
|
40
|
+
|
41
|
+
dwt8Z0+2alFCo/YDjyd2xDhVCpmmxn5BT2wVTZiCEJrlSIY99oQyQWDy/152X5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oPFv5oKz5zqcKw9tCx5pL33vLRhEsd11/0jDWJpPvp1pbHq3D75by7xmJt9
|
87
|
+
Vh+RRQgVfrF0Z6QD9hD/rBChmZLGEkmLNuLgP5DB14ebzdxL4NF1GdcIuXTWtv22
|
88
|
+
lA032Iv2YQQUA/2fvp2XzAmE9Uvma2cj50e65Ky9iJ5O6suDfBwc4UPYQ6gI8BxA
|
89
|
+
Hzd1Xl9Zs3f7b4eRKhu+V1kjloW4tfCurPme72cgvTtZacgUTRJmlcq1OtXxpt+V
|
90
|
+
-----END RSA PRIVATE KEY-----
|
@@ -0,0 +1,59 @@
|
|
1
|
+
Bag Attributes
|
2
|
+
friendlyName: test certificate
|
3
|
+
localKeyID: 00 93 8F E4 A3 C3 75 64 3D 7E EA 14 0B 0A EA DD 15 85 8A D5
|
4
|
+
subject=/CN=test certificate/O=Example/OU=Example/ST=QLD/C=AU/L=Example/emailAddress=user@example.com
|
5
|
+
issuer=/CN=test certificate/O=Example/OU=Example/ST=QLD/C=AU/L=Example/emailAddress=user@example.com
|
6
|
+
-----BEGIN CERTIFICATE-----
|
7
|
+
MIID5jCCAs6gAwIBAgIBATALBgkqhkiG9w0BAQswgY0xGTAXBgNVBAMMEHRlc3Qg
|
8
|
+
Y2VydGlmaWNhdGUxEDAOBgNVBAoMB0V4YW1wbGUxEDAOBgNVBAsMB0V4YW1wbGUx
|
9
|
+
DDAKBgNVBAgMA1FMRDELMAkGA1UEBhMCQVUxEDAOBgNVBAcMB0V4YW1wbGUxHzAd
|
10
|
+
BgkqhkiG9w0BCQEWEHVzZXJAZXhhbXBsZS5jb20wHhcNMTIwOTA5MDMxODMyWhcN
|
11
|
+
MjIwOTA3MDMxODMyWjCBjTEZMBcGA1UEAwwQdGVzdCBjZXJ0aWZpY2F0ZTEQMA4G
|
12
|
+
A1UECgwHRXhhbXBsZTEQMA4GA1UECwwHRXhhbXBsZTEMMAoGA1UECAwDUUxEMQsw
|
13
|
+
CQYDVQQGEwJBVTEQMA4GA1UE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E-----
|
29
|
+
Bag Attributes
|
30
|
+
friendlyName: test certificate
|
31
|
+
localKeyID: 00 93 8F E4 A3 C3 75 64 3D 7E EA 14 0B 0A EA DD 15 85 8A D5
|
32
|
+
Key Attributes: <No Attributes>
|
33
|
+
-----BEGIN RSA PRIVATE KEY-----
|
34
|
+
MIIEpQIBAAKCAQEAoX5QOw3Wwt6fyD73s81OJaO737CRK/4fmtCW9vpgUs/HXVi+
|
35
|
+
qkryazqQVTU6ZZ4t+aFymxP5tm0q6kLtoY+hIbdFfPN/9hQyCz9lJcDSJ1kcDq2R
|
36
|
+
F4ATMhfqMvmi189Zto+W4JNShUx4/i73LCTrbzOWqH0hAcLUCCXRHXEYKlQsOTyS
|
37
|
+
fWA/ISKyXfzAjloNvPLqVhAY1Qo6q3XF9WO0gV7+PJj+/SzEWMgmVEtwAUG4nHix
|
38
|
+
FX4/BEGS6w5C1jBzCkiWgzEmP4ZB7rq54BNbzVoLiI5TroMAUUS4bPAjCbds6KWK
|
39
|
+
YYZBsZv3YXff1F+ZI6hM8C9WGxqQjebMRJviWQIDAQABAoIBAQCTiLIDQUFSBdAz
|
40
|
+
QFNLD+S0vkCEuunlJuP4q1c/ir006l1YChsluBJ/o6D4NwiCjV+zDquEwVsALftm
|
41
|
+
yH4PewfZpXT2Ef508T5GyEO/mchj6iSXxDkpHvhqay6qIyWBwwxSnBtaTzy0Soi+
|
42
|
+
rmlhCtmLXbXld2sQEM1kJChGnWtWPtvSyrn+mapNPZviGRtgRNK+YsrAti1nUext
|
43
|
+
2syO5mTdHf1D8GR7I98OaX6odREuSocEV9PzfapWZx2GK5tvRiS1skiug5ciieTd
|
44
|
+
Am5/C+bb31h4drFslihLb5BRGO5SFQJvMJL2Sx1f19BCC4XikS01P4/zZbxQNq79
|
45
|
+
kxEQuDGBAoGBANP4pIYZ5xshCkx7cTYqmxzWLClGKE2S7Oa8N89mtOwfmqT9AFun
|
46
|
+
t9Us9Ukbi8BaKlKhGpQ1HlLf/KVcpyW0x2qLou6AyIWYH+/5VaR3graNgUnzpK9f
|
47
|
+
1F5HoaNHbhlAoebqhzhASFlJI2aqUdQjdOv73z+s9szJU4gpILNwGDFnAoGBAMMJ
|
48
|
+
j+vIxtG9J2jldyoXzpg5mbMXSj9u/wFLBVdjXWyOoiqVMMBto53RnoqAom7Ifr9D
|
49
|
+
49LxRAT1Q3l4vs/YnM3ziMsIg2vQK1EbrLsY9OnD/kvPaLXOlNIOdfLM8UeVWZMc
|
50
|
+
I4LPbbZrhv/7CC8RjbRhMoWWdGYPvxmvD6V4ZDY/AoGBALoI6OxA45Htx4okdNHj
|
51
|
+
RstiNNPsnQaoQn6nBhxiubraafEPkzbd1fukP4pwQJELEUX/2sHkdL6rkqLW1GPF
|
52
|
+
a5dZAiBsqpCFWNJWdBGqSfBJ9QSgbxLz+gDcwUH6OOi0zuNJRm/aCyVBiW5bYQHc
|
53
|
+
NIvAPMk31ksZDtTbs7WIVdNVAoGBALZ1+KWNxKqs+fSBT5UahpUUtfy8miJz9a7A
|
54
|
+
/3M8q0cGvSF3Rw+OwpW/aEGMi+l2OlU27ykFuyukRAac9m296RwnbF79TO2M5ylO
|
55
|
+
6a5zb5ROXlWP6RbE96b4DlIidssQJqegmHwlEC+rsrVBpOtb0aThlYEyOxzMOGyP
|
56
|
+
wOR9l8rDAoGADZ4TUHFM6VrvPlUZBkGbqiyXH9IM/y9JWk+22JQCEGnM6RFZemSs
|
57
|
+
jxWqQiPAdJtb3xKryJSCMtFPH9azedoCrSgaMflJ1QgoXgpiKZyoEXWraVUggh/0
|
58
|
+
CEavgZcTZ6SvMuayqJdGGB+zb1V8XwXMtCjApR/kTm47DjxO4DmpOPs=
|
59
|
+
-----END RSA PRIVATE KEY-----
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# postgresql is the default if no ADAPTER environment variable is set when running specs.
|
2
|
+
|
3
|
+
postgresql:
|
4
|
+
adapter: postgresql
|
5
|
+
database: rpush_test
|
6
|
+
host: localhost
|
7
|
+
username: postgres
|
8
|
+
password: ""
|
9
|
+
|
10
|
+
jdbcpostgresql:
|
11
|
+
adapter: jdbcpostgresql
|
12
|
+
database: rpush_test
|
13
|
+
host: localhost
|
14
|
+
username: postgres
|
15
|
+
password: ""
|
16
|
+
|
17
|
+
mysql2:
|
18
|
+
adapter: mysql2
|
19
|
+
database: rpush_test
|
20
|
+
host: localhost
|
21
|
+
username: rpush_test
|
22
|
+
password: ""
|
23
|
+
encoding: utf8
|
24
|
+
|
25
|
+
jdbcmysql:
|
26
|
+
adapter: jdbcmysql
|
27
|
+
database: rpush_test
|
28
|
+
host: localhost
|
29
|
+
username: rpush_test
|
30
|
+
password: ""
|
31
|
+
encoding: utf8
|
32
|
+
|
33
|
+
jdbch2:
|
34
|
+
adapter: h2
|
35
|
+
url: jdbc:h2:file:/tmp/rpush_test;AUTO_SERVER=TRUE
|
36
|
+
username: rpush_test
|
37
|
+
password: ""
|
38
|
+
pool: 128
|
39
|
+
timeout: 5000
|
40
|
+
encoding: utf8
|
41
|
+
|
42
|
+
sqlite3:
|
43
|
+
adapter: sqlite3
|
44
|
+
database: spec/tmp/rpush_test.sqlite3
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require './spec/support/simplecov_quality_formatter'
|
3
|
+
|
4
|
+
module SimpleCovHelper
|
5
|
+
def start_simple_cov(name)
|
6
|
+
SimpleCov.start do
|
7
|
+
add_filter '/spec/'
|
8
|
+
add_filter '/lib/generators'
|
9
|
+
command_name name
|
10
|
+
|
11
|
+
formatters = [SimpleCov::Formatter::QualityFormatter]
|
12
|
+
|
13
|
+
if ENV['TRAVIS']
|
14
|
+
require 'codeclimate-test-reporter'
|
15
|
+
|
16
|
+
if CodeClimate::TestReporter.run?
|
17
|
+
formatters << CodeClimate::TestReporter::Formatter
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
formatter SimpleCov::Formatter::MultiFormatter[*formatters]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module SimpleCov
|
2
|
+
module Formatter
|
3
|
+
class QualityFormatter
|
4
|
+
def format(result)
|
5
|
+
SimpleCov::Formatter::HTMLFormatter.new.format(result)
|
6
|
+
File.open("coverage/covered_percent", "w") do |f|
|
7
|
+
f.puts result.source_files.covered_percent.to_f
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/spec/tmp/.gitkeep
ADDED
File without changes
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'unit_spec_helper'
|
2
|
+
|
3
|
+
describe Rpush, 'apns_feedback' do
|
4
|
+
let!(:apns_app) do
|
5
|
+
Rpush::Apns::App.create!(name: 'test', environment: 'production', certificate: TEST_CERT)
|
6
|
+
end
|
7
|
+
|
8
|
+
let!(:gcm_app) do
|
9
|
+
Rpush::Gcm::App.create!(name: 'MyApp', auth_key: 'abc123')
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:receiver) { double(check_for_feedback: nil) }
|
13
|
+
|
14
|
+
before do
|
15
|
+
allow(Rpush::Daemon::Apns::FeedbackReceiver).to receive(:new) { receiver }
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'initializes the daemon' do
|
19
|
+
expect(Rpush::Daemon).to receive(:common_init)
|
20
|
+
Rpush.apns_feedback
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'checks feedback for each app' do
|
24
|
+
expect(Rpush::Daemon::Apns::FeedbackReceiver).to receive(:new).with(apns_app).and_return(receiver)
|
25
|
+
expect(receiver).to receive(:check_for_feedback)
|
26
|
+
Rpush.apns_feedback
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'unit_spec_helper'
|
2
|
+
|
3
|
+
describe Rpush::Client::ActiveRecord::Adm::App do
|
4
|
+
subject { Rpush::Client::ActiveRecord::Adm::App.new(name: 'test', environment: 'development', client_id: 'CLIENT_ID', client_secret: 'CLIENT_SECRET') }
|
5
|
+
let(:existing_app) { Rpush::Client::ActiveRecord::Adm::App.create!(name: 'existing', environment: 'development', client_id: 'CLIENT_ID', client_secret: 'CLIENT_SECRET') }
|
6
|
+
|
7
|
+
it 'should be valid if properly instantiated' do
|
8
|
+
expect(subject).to be_valid
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should be invalid if name' do
|
12
|
+
subject.name = nil
|
13
|
+
expect(subject).not_to be_valid
|
14
|
+
expect(subject.errors[:name]).to eq ["can't be blank"]
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should be invalid if name is not unique within scope' do
|
18
|
+
subject.name = existing_app.name
|
19
|
+
expect(subject).not_to be_valid
|
20
|
+
expect(subject.errors[:name]).to eq ["has already been taken"]
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should be invalid if missing client_id' do
|
24
|
+
subject.client_id = nil
|
25
|
+
expect(subject).not_to be_valid
|
26
|
+
expect(subject.errors[:client_id]).to eq ["can't be blank"]
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should be invalid if missing client_secret' do
|
30
|
+
subject.client_secret = nil
|
31
|
+
expect(subject).not_to be_valid
|
32
|
+
expect(subject.errors[:client_secret]).to eq ["can't be blank"]
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#access_token_expired?' do
|
36
|
+
before(:each) do
|
37
|
+
Timecop.freeze(Time.now)
|
38
|
+
end
|
39
|
+
|
40
|
+
after do
|
41
|
+
Timecop.return
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should return true if access_token_expiration is nil' do
|
45
|
+
expect(subject.access_token_expired?).to eq(true)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should return true if expired' do
|
49
|
+
subject.access_token_expiration = Time.now - 5.minutes
|
50
|
+
expect(subject.access_token_expired?).to eq(true)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should return false if not expired' do
|
54
|
+
subject.access_token_expiration = Time.now + 5.minutes
|
55
|
+
expect(subject.access_token_expired?).to eq(false)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end if active_record?
|