diff options
-rw-r--r-- | SmartDeviceLink/SDLPermissionElement.h | 9 | ||||
-rw-r--r-- | SmartDeviceLink/SDLPermissionFilter.h | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLPermissionFilter.m | 4 | ||||
-rw-r--r-- | SmartDeviceLink/SDLPermissionManager.h | 5 | ||||
-rw-r--r-- | SmartDeviceLink/SDLPermissionManager.m | 10 | ||||
-rw-r--r-- | SmartDeviceLinkTests/DevAPISpecs/SDLPermissionFilterSpec.m | 4 | ||||
-rw-r--r-- | SmartDeviceLinkTests/DevAPISpecs/SDLPermissionsManagerSpec.m | 3 |
7 files changed, 17 insertions, 20 deletions
diff --git a/SmartDeviceLink/SDLPermissionElement.h b/SmartDeviceLink/SDLPermissionElement.h index f0f7e6543..7ab2d3b52 100644 --- a/SmartDeviceLink/SDLPermissionElement.h +++ b/SmartDeviceLink/SDLPermissionElement.h @@ -16,16 +16,13 @@ NS_ASSUME_NONNULL_BEGIN @interface SDLPermissionElement : NSObject <NSCopying> /** - Name of the individual RPC. - - Required + * Name of the individual RPC. + * Required */ @property (strong, nonatomic) SDLRPCFunctionName rpcName; /** - RPC parameters for the individual RPC - - Required + * RPC parameters for the individual RPC */ @property (strong, nonatomic) NSArray<NSString *> *parameterPermissions; diff --git a/SmartDeviceLink/SDLPermissionFilter.h b/SmartDeviceLink/SDLPermissionFilter.h index d2ba93956..8c073e041 100644 --- a/SmartDeviceLink/SDLPermissionFilter.h +++ b/SmartDeviceLink/SDLPermissionFilter.h @@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN @property (copy, nonatomic, readonly) SDLPermissionsChangedHandler handler; /** - * The block that will be called on status changes to RPC Permissions + * The block that will be called on status changes to RPC permission status objects */ @property (copy, nonatomic, readonly) SDLRPCPermissionStatusChangedHandler rpcPermissionStatusHandler; diff --git a/SmartDeviceLink/SDLPermissionFilter.m b/SmartDeviceLink/SDLPermissionFilter.m index bfa3f8540..a362fcf82 100644 --- a/SmartDeviceLink/SDLPermissionFilter.m +++ b/SmartDeviceLink/SDLPermissionFilter.m @@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)init { return [self initWithRPCNames:@[] groupType:SDLPermissionGroupTypeAny - permissionsHandler:^(NSDictionary<SDLPermissionElement *, NSNumber<SDLBool> *> *_Nonnull change, SDLPermissionGroupStatus status){ } rpcPermissionStatusHandler:^(NSDictionary<SDLPermissionRPCName,SDLRPCPermissionStatus *> * _Nonnull change, SDLPermissionGroupStatus status) { }]; + permissionsHandler:^(NSDictionary<SDLPermissionElement *, NSNumber<SDLBool> *> *_Nonnull change, SDLPermissionGroupStatus status){ } rpcPermissionStatusHandler:^(NSDictionary<SDLPermissionRPCName, SDLRPCPermissionStatus *> * _Nonnull change, SDLPermissionGroupStatus status) { }]; } - (instancetype)initWithRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType permissionsHandler:(nullable SDLPermissionsChangedHandler)observer rpcPermissionStatusHandler:(nullable SDLRPCPermissionStatusChangedHandler)permissionStatusHandler { @@ -80,7 +80,7 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Helpers - (NSArray<SDLPermissionRPCName> *)getRPCNamesFromPermissionElements:(NSArray<SDLPermissionElement *> *)permissionElements { - NSMutableArray *rpcNames = [NSMutableArray new]; + NSMutableArray *rpcNames = [[NSMutableArray alloc] init]; for (SDLPermissionElement *element in permissionElements) { [rpcNames addObject:element.rpcName]; } diff --git a/SmartDeviceLink/SDLPermissionManager.h b/SmartDeviceLink/SDLPermissionManager.h index 887c6ceef..ddea8a209 100644 --- a/SmartDeviceLink/SDLPermissionManager.h +++ b/SmartDeviceLink/SDLPermissionManager.h @@ -86,9 +86,9 @@ NS_ASSUME_NONNULL_BEGIN /** * Retrieve a dictionary with keys that are the passed in RPC names, and objects of an NSNumber<BOOL> specifying if that RPC is currently allowed * - * @param rpcNames An array of RPC names to check + * @param rpcNames An array of permission elements to check * - * @return A dictionary specifying if the passed in RPC names are currently allowed or not + * @return A dictionary with specific RPC info contained in a SDLRPCPermissionStatus */ - (NSDictionary<SDLRPCFunctionName, SDLRPCPermissionStatus *> *)statusesOfRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames; @@ -143,7 +143,6 @@ NS_ASSUME_NONNULL_BEGIN */ - (BOOL)rpcNameRequiresEncryption:(SDLRPCFunctionName)rpcName; - /** * Check whether a parameter of an RPC is allowed * diff --git a/SmartDeviceLink/SDLPermissionManager.m b/SmartDeviceLink/SDLPermissionManager.m index 773d6bdba..d1531ba1f 100644 --- a/SmartDeviceLink/SDLPermissionManager.m +++ b/SmartDeviceLink/SDLPermissionManager.m @@ -134,6 +134,8 @@ NS_ASSUME_NONNULL_BEGIN - (NSDictionary<SDLPermissionRPCName, NSNumber *> *)statusOfRPCs:(NSArray<SDLPermissionRPCName> *)rpcNames { NSArray *permissionElementsArray = [self sdl_createPermissionElementFromRPCNames:rpcNames]; + + // Convert the dictionary returned from statusesOfRPCNames: to the correct return type return [self sdl_convertPermissionsDictionary:[self statusesOfRPCNames:permissionElementsArray]]; } @@ -145,15 +147,15 @@ NS_ASSUME_NONNULL_BEGIN continue; } - NSMutableDictionary<NSString *, NSNumber *> *allowedParameters = [NSMutableDictionary dictionary]; + NSMutableDictionary<NSString *, NSNumber *> *rpcParameters = [NSMutableDictionary dictionary]; if (permissionElement.parameterPermissions != nil) { for (NSString *permissionParameter in permissionElement.parameterPermissions) { BOOL isParameterAllowed = [self isPermissionParameterAllowed:permissionElement.rpcName parameter:permissionParameter]; - [allowedParameters setObject:@(isParameterAllowed) forKey:permissionParameter]; + [rpcParameters setObject:@(isParameterAllowed) forKey:permissionParameter]; } } - SDLRPCPermissionStatus *permissionStatus = [[SDLRPCPermissionStatus alloc] initWithRPCName:permissionElement.rpcName isRPCAllowed:[self isRPCNameAllowed:permissionElement.rpcName] rpcParameters:allowedParameters]; + SDLRPCPermissionStatus *permissionStatus = [[SDLRPCPermissionStatus alloc] initWithRPCName:permissionElement.rpcName isRPCAllowed:[self isRPCNameAllowed:permissionElement.rpcName] rpcParameters:rpcParameters]; [permissionAllowedDict setObject:permissionStatus forKey:permissionElement.rpcName]; } @@ -335,7 +337,7 @@ NS_ASSUME_NONNULL_BEGIN * @return An array of permission elements. */ - (NSArray<SDLPermissionElement *> *)sdl_createPermissionElementFromRPCNames:(NSArray<NSString *> *)rpcNames { - NSMutableArray *permissionElements = [NSMutableArray new]; + NSMutableArray *permissionElements = [[NSMutableArray alloc] init]; for (NSString *rpcName in rpcNames) { SDLPermissionElement *permissionElement = [[SDLPermissionElement alloc] initWithRPCName:rpcName parameterPermissions:nil]; [permissionElements addObject:permissionElement]; diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionFilterSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionFilterSpec.m index 524fdf923..d93005337 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionFilterSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionFilterSpec.m @@ -76,7 +76,7 @@ describe(@"A filter", ^{ }]; }); - it(@"should set the rpcNames array correctly", ^{ + it(@"should set the permission elements array correctly", ^{ expect(testFilter.permissionElements).to(equal(testPermissionElements)); }); @@ -150,7 +150,7 @@ describe(@"A filter", ^{ }]; }); - it(@"should set the rpcNames array correctly", ^{ + it(@"should set the permission elements array correctly", ^{ expect(testFilter.permissionElements).to(equal(testPermissionElements)); }); diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionsManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionsManagerSpec.m index e0fedfadf..2eac0e8cf 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionsManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionsManagerSpec.m @@ -37,7 +37,6 @@ describe(@"SDLPermissionsManager", ^{ __block NSString *testRPCParameterNameAllAllowed = nil; __block NSString *testRPCParameterNameAllDisallowed = nil; __block NSString *testRPCParameterNameFullLimitedAllowed = nil; - __block NSString *testRPCParameterNameFullLimitedBackgroundAllowed = nil; __block SDLParameterPermissions *testParameterPermissionAllowed = nil; __block SDLParameterPermissions *testParameterPermissionUserDisallowed = nil; @@ -78,7 +77,6 @@ describe(@"SDLPermissionsManager", ^{ testRPCParameterNameAllAllowed = @"AllAllowed"; testRPCParameterNameAllDisallowed = @"AllDisallowed"; testRPCParameterNameFullLimitedAllowed = @"FullAndLimitedAllowed"; - testRPCParameterNameFullLimitedBackgroundAllowed = @"FullAndLimitedAndBackgroundAllowed"; // Create a manager testPermissionsManager = [[SDLPermissionManager alloc] init]; @@ -152,6 +150,7 @@ describe(@"SDLPermissionsManager", ^{ backgroundHMINotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeHMIStatusNotification object:nil rpcNotification:testBackgroundHMIStatus]; noneHMINotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeHMIStatusNotification object:nil rpcNotification:testNoneHMIStatus]; + // Permission Elements testPermissionElementAllAllowed = [[SDLPermissionElement alloc] initWithRPCName:testRPCNameAllAllowed parameterPermissions:@[testRPCParameterNameAllAllowed]]; testPermissionElementFullLimitedAllowed = [[SDLPermissionElement alloc] initWithRPCName:testRPCNameFullLimitedAllowed parameterPermissions:@[testRPCParameterNameFullLimitedAllowed]]; testPermissionElementDisallowed = [[SDLPermissionElement alloc] initWithRPCName:testRPCNameAllDisallowed parameterPermissions:@[testRPCParameterNameAllDisallowed]]; |