summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Gluck <justin.gluck@livio.io>2019-04-05 09:13:24 -0400
committerJustin Gluck <justin.gluck@livio.io>2019-04-05 09:13:24 -0400
commit851f58e740d07393fdadb320e3778f138c2b5a0f (patch)
tree3089956cb066d9090c5d1bef879635d2624d8bbe
parent72e78b22bf5b5084c28e8f303ed2f2304c0191af (diff)
downloadsdl_ios-851f58e740d07393fdadb320e3778f138c2b5a0f.tar.gz
Adding missing conditional check to stop the manager if SDLAppInterfaceUnregisteredReason is PROTOCOL_VIOLATION
-rw-r--r--SmartDeviceLink/SDLLifecycleManager.m2
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m27
2 files changed, 28 insertions, 1 deletions
diff --git a/SmartDeviceLink/SDLLifecycleManager.m b/SmartDeviceLink/SDLLifecycleManager.m
index e40159038..02ddfeb84 100644
--- a/SmartDeviceLink/SDLLifecycleManager.m
+++ b/SmartDeviceLink/SDLLifecycleManager.m
@@ -789,7 +789,7 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
[self sdl_transitionToState:SDLLifecycleStateStopped];
} else if ([self.lifecycleStateMachine isCurrentState:SDLLifecycleStateStopped]) {
return;
- } else if ([appUnregisteredNotification.reason isKindOfClass:[NSString class]] && [appUnregisteredNotification.reason isEqualToEnum:SDLAppInterfaceUnregisteredReasonAppUnauthorized]) {
+ } else if ([appUnregisteredNotification.reason isKindOfClass:[NSString class]] && ([appUnregisteredNotification.reason isEqualToEnum:SDLAppInterfaceUnregisteredReasonAppUnauthorized] || [appUnregisteredNotification.reason isEqualToString:SDLAppInterfaceUnregisteredReasonProtocolViolation])) {
// HAX: The string check is due to a core "feature" that could cause -1 to be sent as the enum value, which will crash here.
[self sdl_transitionToState:SDLLifecycleStateStopped];
} else {
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m
index 728dcc99f..1c326b2a7 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleManagerSpec.m
@@ -17,6 +17,7 @@
#import "SDLLogConfiguration.h"
#import "SDLManagerDelegate.h"
#import "SDLNotificationDispatcher.h"
+#import "SDLOnAppInterfaceUnregistered.h"
#import "SDLOnAppServiceData.h"
#import "SDLOnHashChange.h"
#import "SDLOnHMIStatus.h"
@@ -27,6 +28,7 @@
#import "SDLRegisterAppInterface.h"
#import "SDLRegisterAppInterfaceResponse.h"
#import "SDLResult.h"
+#import "SDLRPCNotificationNotification.h"
#import "SDLShow.h"
#import "SDLStateMachine.h"
#import "SDLStreamingMediaConfiguration.h"
@@ -513,7 +515,32 @@ describe(@"a lifecycle manager", ^{
[testManager sendRPC:testMessage];
}).to(raiseException());
});
+
+ describe(@"stopping the manager on certain SDLAppInterfaceUnregisteredReason", ^{
+ it(@"should attempt to stop the manager when a PROTOCOL_VIOLATION notification is recieved", ^{
+ SDLOnAppInterfaceUnregistered *unreg = [[SDLOnAppInterfaceUnregistered alloc] init];
+ unreg.reason = SDLAppInterfaceUnregisteredReasonProtocolViolation;
+
+ SDLRPCNotificationNotification *notification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidReceiveAppUnregisteredNotification object:testManager.notificationDispatcher rpcNotification:unreg];
+
+ [[NSNotificationCenter defaultCenter] postNotification:notification];
+ expect(testManager.lifecycleState).toEventually(match(SDLLifecycleStateStopped));
+ });
+
+ it(@"should attempt to stop the manager when an APP_UNAUTHORIZED notification is recieved", ^{
+
+ SDLOnAppInterfaceUnregistered *unreg = [[SDLOnAppInterfaceUnregistered alloc] init];
+ unreg.reason = SDLAppInterfaceUnregisteredReasonAppUnauthorized;
+
+ SDLRPCNotificationNotification *notification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidReceiveAppUnregisteredNotification object:testManager.notificationDispatcher rpcNotification:unreg];
+
+ [[NSNotificationCenter defaultCenter] postNotification:notification];
+ expect(testManager.lifecycleState).toEventually(match(SDLLifecycleStateStopped));
+ });
+ });
+
+
describe(@"stopping the manager", ^{
beforeEach(^{
[testManager stop];