mirror of
https://github.com/caronc/apprise.git
synced 2025-08-09 00:15:03 +02:00
Improved FCM Support Supporting both Legacy and OAuth2 Methods (#353)
This commit is contained in:
@ -604,50 +604,99 @@ TEST_URLS = (
|
||||
# We failed to identify any valid authentication
|
||||
'instance': TypeError,
|
||||
}),
|
||||
('fcm://apikey/', {
|
||||
# no project id specified
|
||||
'instance': TypeError,
|
||||
}),
|
||||
('fcm://project@%20%20/', {
|
||||
# invalid apikey
|
||||
'instance': TypeError,
|
||||
}),
|
||||
('fcm://project@apikey/', {
|
||||
# No targets specified; we will initialize but not notify anything
|
||||
('fcm://apikey/', {
|
||||
# no project id specified so we operate in legacy mode
|
||||
'instance': plugins.NotifyFCM,
|
||||
# but there are no targets specified so we return False
|
||||
'notify_response': False,
|
||||
}),
|
||||
('fcm://project@apikey/device', {
|
||||
('fcm://apikey/device', {
|
||||
# Valid device
|
||||
'instance': plugins.NotifyFCM,
|
||||
'privacy_url': 'fcm://project@a...y/device',
|
||||
'privacy_url': 'fcm://a...y/device',
|
||||
}),
|
||||
('fcm://project@apikey/#topic', {
|
||||
('fcm://apikey/#topic', {
|
||||
# Valid topic
|
||||
'instance': plugins.NotifyFCM,
|
||||
'privacy_url': 'fcm://project@a...y/%23topic',
|
||||
'privacy_url': 'fcm://a...y/%23topic',
|
||||
}),
|
||||
('fcm://project@apikey/#topic1/device/%20/', {
|
||||
('fcm://apikey/device?mode=invalid', {
|
||||
# Valid device, invalid mode
|
||||
'instance': TypeError,
|
||||
}),
|
||||
('fcm://apikey/#topic1/device/%20/', {
|
||||
# Valid topic, valid device, and invalid entry
|
||||
'instance': plugins.NotifyFCM,
|
||||
}),
|
||||
('fcm://project@apikey?to=#topic1,device', {
|
||||
('fcm://apikey?to=#topic1,device', {
|
||||
# Test to=
|
||||
'instance': plugins.NotifyFCM,
|
||||
}),
|
||||
('fcm://project@apikey/#topic1/device/', {
|
||||
('fcm://?apikey=abc123&to=device', {
|
||||
# Test apikey= to=
|
||||
'instance': plugins.NotifyFCM,
|
||||
}),
|
||||
('fcm://%20?to=device&keyfile=/invalid/path', {
|
||||
# invalid Project ID
|
||||
'instance': TypeError,
|
||||
}),
|
||||
('fcm://project_id?to=device&keyfile=/invalid/path', {
|
||||
# Test to= and auto detection of oauth mode
|
||||
'instance': plugins.NotifyFCM,
|
||||
# we'll fail to send our notification as a result
|
||||
'response': False,
|
||||
}),
|
||||
('fcm://?to=device&project=project_id&keyfile=/invalid/path', {
|
||||
# Test project= & to= and auto detection of oauth mode
|
||||
'instance': plugins.NotifyFCM,
|
||||
# we'll fail to send our notification as a result
|
||||
'response': False,
|
||||
}),
|
||||
('fcm://project_id?to=device&mode=oauth2', {
|
||||
# no keyfile was specified
|
||||
'instance': TypeError,
|
||||
}),
|
||||
('fcm://project_id?to=device&mode=oauth2&keyfile=/invalid/path', {
|
||||
# Same test as above except we explicitly set our oauth2 mode
|
||||
# Test to= and auto detection of oauth mode
|
||||
'instance': plugins.NotifyFCM,
|
||||
# we'll fail to send our notification as a result
|
||||
'response': False,
|
||||
}),
|
||||
('fcm://apikey/#topic1/device/?mode=legacy', {
|
||||
'instance': plugins.NotifyFCM,
|
||||
# throw a bizzare code forcing us to fail to look it up
|
||||
'response': False,
|
||||
'requests_response_code': 999,
|
||||
}),
|
||||
('fcm://project@apikey/#topic1/device/', {
|
||||
('fcm://apikey/#topic1/device/?mode=legacy', {
|
||||
'instance': plugins.NotifyFCM,
|
||||
# Throws a series of connection and transfer exceptions when this flag
|
||||
# is set and tests that we gracfully handle them
|
||||
'test_requests_exceptions': True,
|
||||
}),
|
||||
|
||||
('fcm://project/#topic1/device/?mode=oauth2&keyfile=file://{}'.format(
|
||||
os.path.join(
|
||||
os.path.dirname(__file__), 'var', 'fcm',
|
||||
'service_account.json')), {
|
||||
'instance': plugins.NotifyFCM,
|
||||
# throw a bizzare code forcing us to fail to look it up
|
||||
'response': False,
|
||||
'requests_response_code': 999,
|
||||
}),
|
||||
('fcm://projectid/#topic1/device/?mode=oauth2&keyfile=file://{}'.format(
|
||||
os.path.join(
|
||||
os.path.dirname(__file__), 'var', 'fcm',
|
||||
'service_account.json')), {
|
||||
'instance': plugins.NotifyFCM,
|
||||
# Throws a series of connection and transfer exceptions when
|
||||
# this flag is set and tests that we gracfully handle them
|
||||
'test_requests_exceptions': True,
|
||||
}),
|
||||
##################################
|
||||
# NotifyFlock
|
||||
##################################
|
||||
|
Reference in New Issue
Block a user