summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlapinskijw <jlapinski.dev@gmail.com>2020-06-30 12:35:33 -0400
committerlapinskijw <jlapinski.dev@gmail.com>2020-06-30 12:35:33 -0400
commit8fecff3903827c2877c4f32b60ca6c38193e39a6 (patch)
tree12fc5209fd3a669cc570e42b1bb2a3aa393cf3d1
parentc41fd57c44460511a2f884134d172c3f4b6bf87d (diff)
downloadsdl_ios-8fecff3903827c2877c4f32b60ca6c38193e39a6.tar.gz
updated value for permission element, updated filter spec and permissions manager spec tests, added new handler to filter
-rw-r--r--SmartDeviceLink-iOS.xcodeproj/project.pbxproj4
-rw-r--r--SmartDeviceLink/SDLPermissionConstants.h7
-rw-r--r--SmartDeviceLink/SDLPermissionElement.h6
-rw-r--r--SmartDeviceLink/SDLPermissionElement.m4
-rw-r--r--SmartDeviceLink/SDLPermissionFilter.h9
-rw-r--r--SmartDeviceLink/SDLPermissionFilter.m12
-rw-r--r--SmartDeviceLink/SDLPermissionManager.h5
-rw-r--r--SmartDeviceLink/SDLPermissionManager.m52
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLPermissionFilterSpec.m19
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLPermissionsManagerSpec.m37
10 files changed, 104 insertions, 51 deletions
diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
index 9496d5983..d0a5385d4 100644
--- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
+++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj
@@ -39,7 +39,7 @@
00EADD3322DFE54B0088B608 /* SDLEncryptionLifecycleManagerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 00EADD3222DFE54B0088B608 /* SDLEncryptionLifecycleManagerSpec.m */; };
00EADD3522DFE5670088B608 /* SDLEncryptionConfigurationSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 00EADD3422DFE5670088B608 /* SDLEncryptionConfigurationSpec.m */; };
106187B924AA75540045C4EC /* SDLRPCPermissionStatusSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 106187B824AA75540045C4EC /* SDLRPCPermissionStatusSpec.m */; };
- 106187BA24AA76550045C4EC /* SDLRPCPermissionStatus.h in Headers */ = {isa = PBXBuildFile; fileRef = 106982A824AA3B4700B1F649 /* SDLRPCPermissionStatus.h */; };
+ 106187BA24AA76550045C4EC /* SDLRPCPermissionStatus.h in Headers */ = {isa = PBXBuildFile; fileRef = 106982A824AA3B4700B1F649 /* SDLRPCPermissionStatus.h */; settings = {ATTRIBUTES = (Public, ); }; };
106412C6249FB80B0069A97A /* SDLPermissionElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 106412C4249FB80B0069A97A /* SDLPermissionElement.h */; settings = {ATTRIBUTES = (Public, ); }; };
106412C7249FB80B0069A97A /* SDLPermissionElement.m in Sources */ = {isa = PBXBuildFile; fileRef = 106412C5249FB80B0069A97A /* SDLPermissionElement.m */; };
106412C824A13F160069A97A /* SDLPermissionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D8204241BCEA8A600D0A41B /* SDLPermissionManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -6601,6 +6601,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
+ 106187BA24AA76550045C4EC /* SDLRPCPermissionStatus.h in Headers */,
106412C824A13F160069A97A /* SDLPermissionManager.h in Headers */,
106412C6249FB80B0069A97A /* SDLPermissionElement.h in Headers */,
9F425AD222DD980200BE3245 /* SDLWindowCapability.h in Headers */,
@@ -7035,7 +7036,6 @@
1E5AD04C1F1F79640029B8AF /* SDLDefrostZone.h in Headers */,
1E5AD0601F207AB10029B8AF /* SDLRadioState.h in Headers */,
1E5AD0801F20B73E0029B8AF /* SDLButtonPress.h in Headers */,
- 106187BA24AA76550045C4EC /* SDLRPCPermissionStatus.h in Headers */,
884554AC222453A800BAFB6C /* SDLNavigationServiceManifest.h in Headers */,
8816772C222097C3001FACFF /* SDLNavigationServiceData.h in Headers */,
1E5AD05C1F2064A80029B8AF /* SDLRDSData.h in Headers */,
diff --git a/SmartDeviceLink/SDLPermissionConstants.h b/SmartDeviceLink/SDLPermissionConstants.h
index 1e452f29d..375d6f2df 100644
--- a/SmartDeviceLink/SDLPermissionConstants.h
+++ b/SmartDeviceLink/SDLPermissionConstants.h
@@ -11,6 +11,7 @@
#import "NSNumber+NumberType.h"
#import "SDLRPCFunctionNames.h"
#import "SDLPermissionElement.h"
+#import "SDLRPCPermissionStatus.h"
NS_ASSUME_NONNULL_BEGIN
@@ -69,12 +70,12 @@ typedef NS_ENUM(NSUInteger, SDLPermissionGroupStatus) {
typedef void (^SDLPermissionsChangedHandler)(NSDictionary<SDLPermissionRPCName, NSNumber *> *_Nonnull change, SDLPermissionGroupStatus status);
/**
- * The PermissionObserver is a block that is passed in to some methods that will be stored and called when specified permissions change.
+ * The PermissionObserver is a block that is passed in to some methods that will be stored and called when specified permissions change. // to do update
*
- * @param change A dictionary of permission changes containing <key(String): Permission Element, object(BOOL): YES if the RPC is allowed, NO if it is not allowed>
+ * @param change A dictionary of permission changes containing <key(String): SDLPermissionRPCName, object(SDLRPCPermissionStatus)>
* @param status The change made to all of the RPCs in the changedDict. Allowed, if all RPCs are now allowed, Disallowed if all RPCs are now disallowed, or Mixed if some are allowed, and some are disallowed
*/
-typedef void (^SDLPermissionElementsChangedHandler)(NSDictionary<SDLPermissionElement *, NSNumber *> *_Nonnull change, SDLPermissionGroupStatus status);
+typedef void (^SDLRPCPermissionStatusChangedHandler)(NSDictionary<SDLPermissionRPCName, SDLRPCPermissionStatus *> *_Nonnull change, SDLPermissionGroupStatus status);
/**
* The SDLObservedPermissionsChangedHandler is a block that is passed in to subscribeToRPCNames:groupType:withHandler: that will be stored and called when specified permissions change.
diff --git a/SmartDeviceLink/SDLPermissionElement.h b/SmartDeviceLink/SDLPermissionElement.h
index b4afce9e1..b2e808532 100644
--- a/SmartDeviceLink/SDLPermissionElement.h
+++ b/SmartDeviceLink/SDLPermissionElement.h
@@ -27,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
Required
*/
-@property (strong, nonatomic) SDLParameterPermissions *parameterPermissions;
+@property (strong, nonatomic) NSArray<NSString *> *parameterPermissions;
/**
* Create a new permission element.
@@ -37,11 +37,11 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return An instance of `SDLPermissionElement`.
*/
-- (instancetype)initWithRPCName:(SDLRPCFunctionName)rpcName parameterPermissions:(nullable SDLParameterPermissions *)parameterPermissions;
+- (instancetype)initWithRPCName:(SDLRPCFunctionName)rpcName parameterPermissions:(nullable NSArray<NSString *> *)parameterPermissions;
- (SDLRPCFunctionName)getRPCName;
-- (SDLParameterPermissions*)getParameters;
+- (NSArray<NSString *> *)getParameters;
@end
diff --git a/SmartDeviceLink/SDLPermissionElement.m b/SmartDeviceLink/SDLPermissionElement.m
index be8150f43..552cdb908 100644
--- a/SmartDeviceLink/SDLPermissionElement.m
+++ b/SmartDeviceLink/SDLPermissionElement.m
@@ -10,7 +10,7 @@
@implementation SDLPermissionElement
-- (instancetype)initWithRPCName:(SDLRPCFunctionName)rpcName parameterPermissions:(SDLParameterPermissions *)parameterPermissions {
+- (instancetype)initWithRPCName:(SDLRPCFunctionName)rpcName parameterPermissions:(NSArray<NSString *> *)parameterPermissions {
self = [super init];
if (!self) { return nil; }
@@ -24,7 +24,7 @@
return self.rpcName;
}
-- (SDLParameterPermissions *)getParameters {
+- (NSArray<NSString *> *)getParameters {
return self.parameterPermissions;
}
diff --git a/SmartDeviceLink/SDLPermissionFilter.h b/SmartDeviceLink/SDLPermissionFilter.h
index b71c01be7..0dd19452b 100644
--- a/SmartDeviceLink/SDLPermissionFilter.h
+++ b/SmartDeviceLink/SDLPermissionFilter.h
@@ -32,6 +32,11 @@ NS_ASSUME_NONNULL_BEGIN
@property (copy, nonatomic, readonly) SDLPermissionsChangedHandler handler;
/**
+ * The block that will be called on status changes to RPC Permissions
+ */
+@property (copy, nonatomic, readonly) SDLRPCPermissionStatusChangedHandler rpcPermissionStatusHandler;
+
+/**
* All of the permission elements in this filter group.
*/
@property (copy, nonatomic, readonly) NSArray<SDLPermissionElement *> *permissionElements;
@@ -45,7 +50,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return An instance of `SDLPermissionFilter`.
*/
-- (instancetype)initWithRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(SDLPermissionsChangedHandler)handler NS_DESIGNATED_INITIALIZER;
+- (instancetype)initWithRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(nullable SDLPermissionsChangedHandler)handler rpcPermissionStatusHandler:(nullable SDLRPCPermissionStatusChangedHandler)permissionStatusHandler NS_DESIGNATED_INITIALIZER;
/**
* Create a new permission filter group.
@@ -56,7 +61,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return An instance of `SDLPermissionFilter`.
*/
-+ (instancetype)filterWithRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(SDLPermissionsChangedHandler)handler NS_SWIFT_UNAVAILABLE("Use the initializer");
++ (instancetype)filterWithRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(nullable SDLPermissionsChangedHandler)handler rpcPermissionStatusHandler:(nullable SDLRPCPermissionStatusChangedHandler)permissionStatusHandler NS_SWIFT_UNAVAILABLE("Use the initializer");
/**
* Whether the current filter is equivalent with another filter or not.
diff --git a/SmartDeviceLink/SDLPermissionFilter.m b/SmartDeviceLink/SDLPermissionFilter.m
index 7fee1a7f2..9507faf95 100644
--- a/SmartDeviceLink/SDLPermissionFilter.m
+++ b/SmartDeviceLink/SDLPermissionFilter.m
@@ -19,11 +19,10 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init {
return [self initWithRPCNames:@[]
groupType:SDLPermissionGroupTypeAny
- observer:^(NSDictionary<SDLPermissionElement *, NSNumber<SDLBool> *> *_Nonnull change, SDLPermissionGroupStatus status){
- }];
+ observer:^(NSDictionary<SDLPermissionElement *, NSNumber<SDLBool> *> *_Nonnull change, SDLPermissionGroupStatus status){ } rpcPermissionStatusHandler:^(NSDictionary<SDLPermissionRPCName,SDLRPCPermissionStatus *> * _Nonnull change, SDLPermissionGroupStatus status) { }];
}
-- (instancetype)initWithRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(SDLPermissionsChangedHandler)observer {
+- (instancetype)initWithRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(nullable SDLPermissionsChangedHandler)observer rpcPermissionStatusHandler:(nullable SDLRPCPermissionStatusChangedHandler)permissionStatusHandler {
self = [super init];
if (!self) {
return nil;
@@ -33,19 +32,20 @@ NS_ASSUME_NONNULL_BEGIN
_permissionElements = rpcNames;
_groupType = groupType;
_handler = observer;
+ _rpcPermissionStatusHandler = permissionStatusHandler;
return self;
}
-+ (instancetype)filterWithRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(SDLPermissionsChangedHandler)observer {
- return [[self alloc] initWithRPCNames:rpcNames groupType:groupType observer:observer];
++ (instancetype)filterWithRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType observer:(nullable SDLPermissionsChangedHandler)observer rpcPermissionStatusHandler:(nullable SDLRPCPermissionStatusChangedHandler)permissionStatusHandler {
+ return [[self alloc] initWithRPCNames:rpcNames groupType:groupType observer:observer rpcPermissionStatusHandler:permissionStatusHandler];
}
#pragma mark - NSCopying
- (id)copyWithZone:(nullable NSZone *)zone {
- SDLPermissionFilter *newFilter = [[self.class allocWithZone:zone] initWithRPCNames:[_permissionElements copyWithZone:zone] groupType:_groupType observer:[_handler copyWithZone:zone]];
+ SDLPermissionFilter *newFilter = [[self.class allocWithZone:zone] initWithRPCNames:[_permissionElements copyWithZone:zone] groupType:_groupType observer:[_handler copyWithZone:zone] rpcPermissionStatusHandler:[_rpcPermissionStatusHandler copyWithZone:zone]];
newFilter->_identifier = _identifier;
return newFilter;
diff --git a/SmartDeviceLink/SDLPermissionManager.h b/SmartDeviceLink/SDLPermissionManager.h
index 68cc91084..887c6ceef 100644
--- a/SmartDeviceLink/SDLPermissionManager.h
+++ b/SmartDeviceLink/SDLPermissionManager.h
@@ -11,6 +11,7 @@
#import "SDLHMILevel.h"
#import "SDLPermissionConstants.h"
#import "SDLRPCFunctionNames.h"
+#import "SDLRPCPermissionStatus.h"
@class SDLPermissionItem;
@class SDLRPCMessage;
@@ -89,7 +90,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return A dictionary specifying if the passed in RPC names are currently allowed or not
*/
-- (NSDictionary<SDLRPCFunctionName, NSNumber *> *)statusesOfRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames;
+- (NSDictionary<SDLRPCFunctionName, SDLRPCPermissionStatus *> *)statusesOfRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames;
/**
* Add an observer for specified RPC names, with a callback that will be called whenever the value changes, as well as immediately with the current status.
@@ -117,7 +118,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return An identifier that can be passed to removeObserverForIdentifer: to remove the observer
*/
-- (SDLPermissionObserverIdentifier)subscribeToRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType withHandler:(SDLPermissionsChangedHandler)handler;
+- (SDLPermissionObserverIdentifier)subscribeToRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType withHandler:(SDLRPCPermissionStatusChangedHandler)handler;
/**
* Remove every current observer
diff --git a/SmartDeviceLink/SDLPermissionManager.m b/SmartDeviceLink/SDLPermissionManager.m
index 57753618f..d28302440 100644
--- a/SmartDeviceLink/SDLPermissionManager.m
+++ b/SmartDeviceLink/SDLPermissionManager.m
@@ -133,14 +133,29 @@ NS_ASSUME_NONNULL_BEGIN
}
- (NSDictionary<SDLPermissionRPCName, NSNumber *> *)statusOfRPCs:(NSArray<SDLPermissionRPCName> *)rpcNames {
- return [self statusesOfRPCNames:[self sdl_createPermissionElementFromRPCNames:rpcNames]];
+ NSArray *permissionElementsArray = [self sdl_createPermissionElementFromRPCNames:rpcNames];
+ NSDictionary *dict = [self statusesOfRPCNames:permissionElementsArray];
+ return [self sdl_convertPermissionsDictionary:dict];
}
-- (NSDictionary<SDLRPCFunctionName, NSNumber *> *)statusesOfRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames {
- NSMutableDictionary<SDLRPCFunctionName, NSNumber *> *permissionAllowedDict = [NSMutableDictionary dictionary];
+- (NSDictionary<SDLRPCFunctionName, SDLRPCPermissionStatus *> *)statusesOfRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames {
+ NSMutableDictionary<SDLRPCFunctionName, SDLRPCPermissionStatus *> *permissionAllowedDict = [NSMutableDictionary dictionary];
for (SDLPermissionElement *permissionElement in rpcNames) {
- permissionAllowedDict[permissionElement.rpcName] = @([self isRPCNameAllowed:permissionElement.rpcName]);
+ if (permissionElement == nil) {
+ continue;
+ }
+
+ NSMutableDictionary<NSString *, NSNumber *> *allowedParameters = [NSMutableDictionary dictionary];
+ if (permissionElement.getParameters != nil) {
+ for (NSString *permissionParameter in permissionElement.parameterPermissions) {
+ BOOL isParameterAllowed = [self isPermissionParameterAllowed:permissionElement.rpcName parameter:permissionParameter];
+ [allowedParameters setObject:@(isParameterAllowed) forKey:permissionParameter];
+ }
+ }
+
+ SDLRPCPermissionStatus *permissionStatus = [[SDLRPCPermissionStatus alloc] initWithRPCName:permissionElement.rpcName isRPCAllowed:[self isRPCNameAllowed:permissionElement.rpcName] allowedParameters:allowedParameters];
+ [permissionAllowedDict setObject:permissionStatus forKey:permissionElement.rpcName];
}
return [permissionAllowedDict copy];
@@ -152,7 +167,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark Add Observers
- (SDLPermissionObserverIdentifier)addObserverForRPCs:(NSArray<SDLPermissionRPCName> *)rpcNames groupType:(SDLPermissionGroupType)groupType withHandler:(nonnull SDLPermissionsChangedHandler)handler {
- SDLPermissionFilter *filter = [SDLPermissionFilter filterWithRPCNames:[self sdl_createPermissionElementFromRPCNames:rpcNames] groupType:groupType observer:handler];
+ SDLPermissionFilter *filter = [SDLPermissionFilter filterWithRPCNames:[self sdl_createPermissionElementFromRPCNames:rpcNames] groupType:groupType observer:handler rpcPermissionStatusHandler:nil];
// Store the filter for later use
[self.filters addObject:filter];
@@ -163,8 +178,8 @@ NS_ASSUME_NONNULL_BEGIN
return filter.identifier;
}
-- (SDLPermissionObserverIdentifier)subscribeToRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType withHandler:(SDLPermissionsChangedHandler)handler {
- SDLPermissionFilter *filter = [SDLPermissionFilter filterWithRPCNames:rpcNames groupType:groupType observer:handler];
+- (SDLPermissionObserverIdentifier)subscribeToRPCNames:(NSArray<SDLPermissionElement *> *)rpcNames groupType:(SDLPermissionGroupType)groupType withHandler:(SDLRPCPermissionStatusChangedHandler)handler {
+ SDLPermissionFilter *filter = [SDLPermissionFilter filterWithRPCNames:rpcNames groupType:groupType observer:nil rpcPermissionStatusHandler:handler];
// Store the filter for later use
[self.filters addObject:filter];
@@ -179,10 +194,18 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)sdl_callFilterObserver:(SDLPermissionFilter *)filter {
- SDLPermissionGroupStatus permissionStatus = [self groupStatusOfRPCNames:filter.permissionElements];
- NSDictionary<SDLRPCFunctionName, NSNumber *> *allowedDict = [self statusesOfRPCNames:filter.permissionElements];
- filter.handler(allowedDict, permissionStatus);
+ if (filter.rpcPermissionStatusHandler != nil) {
+ SDLPermissionGroupStatus permissionStatus = [self groupStatusOfRPCNames:filter.permissionElements];
+ NSDictionary<SDLRPCFunctionName, SDLRPCPermissionStatus *> *allowedDict = [self statusesOfRPCNames:filter.permissionElements];
+ filter.rpcPermissionStatusHandler(allowedDict, permissionStatus);
+ }
+
+ if (filter.handler != nil) {
+ SDLPermissionGroupStatus permissionStatus = [self groupStatusOfRPCNames:filter.permissionElements];
+ NSDictionary<SDLRPCFunctionName, NSNumber *> *allowedDict = [self statusOfRPCs:[filter getRPCNamesFromPermissionElements:filter.permissionElements]];
+ filter.handler(allowedDict, permissionStatus);
+ }
}
#pragma mark Remove Observers
@@ -289,12 +312,11 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark Helper Methods
-- (NSDictionary<SDLPermissionRPCName, NSNumber *> *)sdl_convertPermissionElementsDictionary:(NSDictionary<SDLPermissionElement*, NSNumber *> *)permissionElementsDictionary {
+- (NSDictionary<SDLPermissionRPCName, NSNumber *> *)sdl_convertPermissionsDictionary:(NSDictionary<SDLRPCFunctionName, SDLRPCPermissionStatus*> *)permissionElementsDictionary {
NSMutableDictionary *rpcNameDictionary = [[NSMutableDictionary alloc] init];
- for (SDLPermissionElement *key in permissionElementsDictionary.allKeys) {
- SDLPermissionRPCName rpcName = key.rpcName;
- [rpcNameDictionary setObject:permissionElementsDictionary[key] forKey:rpcName];
- }
+ [permissionElementsDictionary enumerateKeysAndObjectsUsingBlock:^(SDLRPCFunctionName _Nonnull key, SDLRPCPermissionStatus * _Nonnull obj, BOOL * _Nonnull stop) {
+ [rpcNameDictionary setObject:@(obj.rpcAllowed) forKey:key];
+ }];
return rpcNameDictionary;
}
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionFilterSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionFilterSpec.m
index 9e9f3328b..c3e482f18 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionFilterSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionFilterSpec.m
@@ -34,9 +34,12 @@ describe(@"A filter", ^{
context(@"using initWithRPCNames:changeType:observer:", ^{
beforeEach(^{
- testFilter = [[SDLPermissionFilter alloc] initWithRPCNames:testPermissionElements groupType:testGroupType observer:^(NSDictionary<SDLPermissionRPCName, NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) {
- testObserverReturnChangedDict = changedDict;
- }];
+// testFilter = [[SDLPermissionFilter alloc] initWithRPCNames:testPermissionElements groupType:testGroupType observer:^(NSDictionary<SDLPermissionRPCName,NSNumber *> * _Nonnull change, SDLPermissionGroupStatus status) {
+//
+// } rpcPermissionStatusHandler:^(NSDictionary<SDLPermissionRPCName,SDLRPCPermissionStatus *> * _Nonnull change, SDLPermissionGroupStatus status) {
+//
+// }];
+ testFilter = [[SDLPermissionFilter alloc] initWithRPCNames:testPermissionElements groupType:testGroupType observer:^(NSDictionary<SDLPermissionRPCName,NSNumber *> * _Nonnull change, SDLPermissionGroupStatus status) { testObserverReturnChangedDict = change; } rpcPermissionStatusHandler:nil];
});
it(@"should set the rpcNames array correctly", ^{
@@ -71,9 +74,7 @@ describe(@"A filter", ^{
context(@"using filterWithRPCNames:changeType:observer:", ^{
beforeEach(^{
- testFilter = [SDLPermissionFilter filterWithRPCNames:testPermissionElements groupType:testGroupType observer:^(NSDictionary<SDLPermissionRPCName, NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) {
- testObserverReturnChangedDict = changedDict;
- }];
+ testFilter = [SDLPermissionFilter filterWithRPCNames:testPermissionElements groupType:testGroupType observer:^(NSDictionary<SDLPermissionRPCName, NSNumber<SDLBool> *> * _Nonnull change, SDLPermissionGroupStatus status) { testObserverReturnChangedDict = change; } rpcPermissionStatusHandler:nil];
});
it(@"should set the rpcNames array correctly", ^{
@@ -112,7 +113,7 @@ describe(@"A filter", ^{
__block SDLPermissionFilter *testCopiedFilter = nil;
beforeEach(^{
- testFilter = [SDLPermissionFilter filterWithRPCNames:@[testPermissionElement1] groupType:SDLPermissionGroupTypeAny observer:^(NSDictionary<SDLPermissionElement *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) {}];
+ testFilter = [SDLPermissionFilter filterWithRPCNames:@[testPermissionElement1] groupType:SDLPermissionGroupTypeAny observer:^(NSDictionary<SDLPermissionElement *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) {} rpcPermissionStatusHandler:nil];
testCopiedFilter = [testFilter copy];
});
@@ -139,10 +140,10 @@ describe(@"A filter", ^{
__block SDLPermissionFilter *testDifferentFilter = nil;
beforeEach(^{
- testSameFilter1 = [SDLPermissionFilter filterWithRPCNames:@[testPermissionElement1] groupType:SDLPermissionGroupTypeAny observer:^(NSDictionary<SDLPermissionElement *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) {}];
+ testSameFilter1 = [SDLPermissionFilter filterWithRPCNames:@[testPermissionElement1] groupType:SDLPermissionGroupTypeAny observer:^(NSDictionary<SDLPermissionElement *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) {} rpcPermissionStatusHandler:nil];
testSameFilter2 = [testSameFilter1 copy];
- testDifferentFilter = [SDLPermissionFilter filterWithRPCNames:@[testPermissionElement1] groupType:SDLPermissionGroupTypeAny observer:^(NSDictionary<SDLPermissionElement *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) {}];
+ testDifferentFilter = [SDLPermissionFilter filterWithRPCNames:@[testPermissionElement1] groupType:SDLPermissionGroupTypeAny observer:^(NSDictionary<SDLPermissionElement *,NSNumber<SDLBool> *> * _Nonnull changedDict, SDLPermissionGroupStatus status) {} rpcPermissionStatusHandler:nil];
});
it(@"should say copied filters are the same", ^{
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionsManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionsManagerSpec.m
index 2bf094624..bfcb9a3eb 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionsManagerSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLPermissionsManagerSpec.m
@@ -26,7 +26,7 @@
QuickSpecBegin(SDLPermissionsManagerSpec)
-describe(@"SDLPermissionsManager", ^{
+fdescribe(@"SDLPermissionsManager", ^{
__block SDLPermissionManager *testPermissionsManager = nil;
__block NSString *testRPCNameAllAllowed = nil;
@@ -67,6 +67,12 @@ describe(@"SDLPermissionsManager", ^{
__block SDLPermissionElement *testPermissionElementFullLimitedAllowed = nil;
__block SDLPermissionElement *testPermissionElementDisallowed = nil;
+ __block NSDictionary *testAllowedDict = nil;
+ __block SDLRPCPermissionStatus *testAllowedStatus = nil;
+
+ __block NSDictionary *testDisallowedDict = nil;
+ __block SDLRPCPermissionStatus *testDisallowedStatus = nil;
+
beforeEach(^{
// Permission Names
testRPCNameAllAllowed = @"AllAllowed";
@@ -152,9 +158,15 @@ describe(@"SDLPermissionsManager", ^{
backgroundHMINotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeHMIStatusNotification object:nil rpcNotification:testBackgroundHMIStatus];
noneHMINotification = [[SDLRPCNotificationNotification alloc] initWithName:SDLDidChangeHMIStatusNotification object:nil rpcNotification:testNoneHMIStatus];
- testPermissionElementAllAllowed = [[SDLPermissionElement alloc] initWithRPCName:testRPCNameAllAllowed parameterPermissions:testPermissionAllAllowed.parameterPermissions];
- testPermissionElementFullLimitedAllowed = [[SDLPermissionElement alloc] initWithRPCName:testRPCNameFullLimitedAllowed parameterPermissions:testPermissionFullLimitedAllowed.parameterPermissions];
- testPermissionElementDisallowed = [[SDLPermissionElement alloc] initWithRPCName:testRPCNameAllDisallowed parameterPermissions:testPermissionAllDisallowed.parameterPermissions];
+ testPermissionElementAllAllowed = [[SDLPermissionElement alloc] initWithRPCName:testRPCNameAllAllowed parameterPermissions:@[testRPCParameterNameAllAllowed]];
+ testPermissionElementFullLimitedAllowed = [[SDLPermissionElement alloc] initWithRPCName:testRPCNameFullLimitedAllowed parameterPermissions:@[testRPCParameterNameFullLimitedAllowed]];
+ testPermissionElementDisallowed = [[SDLPermissionElement alloc] initWithRPCName:testRPCNameAllDisallowed parameterPermissions:@[testRPCParameterNameAllDisallowed]];
+
+ testAllowedDict = [[NSDictionary alloc] initWithObjectsAndKeys:@(0),testRPCParameterNameAllAllowed, nil];
+ testAllowedStatus = [[SDLRPCPermissionStatus alloc] initWithRPCName:testPermissionElementAllAllowed.rpcName isRPCAllowed:YES allowedParameters:testAllowedDict];
+
+ testDisallowedDict = [[NSDictionary alloc] initWithObjectsAndKeys:@(0),testRPCParameterNameAllDisallowed, nil];
+ testDisallowedStatus = [[SDLRPCPermissionStatus alloc] initWithRPCName:testPermissionElementDisallowed.rpcName isRPCAllowed:YES allowedParameters:testDisallowedDict];
});
it(@"should clear when stopped", ^{
@@ -410,6 +422,10 @@ describe(@"SDLPermissionsManager", ^{
describe(@"checking the status of RPCs", ^{
__block NSDictionary<SDLPermissionRPCName, NSNumber *> *testResultPermissionStatusDict = nil;
+ __block NSDictionary<SDLRPCFunctionName, SDLRPCPermissionStatus *> *testResultRPCPermissionStatusDict = nil;
+ __block SDLRPCPermissionStatus *allowedResultStatus = nil;
+ __block SDLRPCPermissionStatus *disallowedResultStatus = nil;
+
context(@"with no permissions data", ^{
context(@"deprecated statusOfRPCs: method", ^{
beforeEach(^{
@@ -427,12 +443,19 @@ describe(@"SDLPermissionsManager", ^{
context(@"statusesOfRPCNames: method", ^{
beforeEach(^{
- testResultPermissionStatusDict = [testPermissionsManager statusesOfRPCNames:@[testPermissionElementAllAllowed, testPermissionElementDisallowed]];
+ testResultRPCPermissionStatusDict = [testPermissionsManager statusesOfRPCNames:@[testPermissionElementAllAllowed, testPermissionElementDisallowed]];
+ allowedResultStatus = testResultRPCPermissionStatusDict[testPermissionElementAllAllowed.rpcName];
+ disallowedResultStatus = testResultRPCPermissionStatusDict[testPermissionElementDisallowed.rpcName];
});
it(@"should return correct permission statuses", ^{
- expect(testResultPermissionStatusDict[testPermissionElementAllAllowed.rpcName]).to(equal(@NO));
- expect(testResultPermissionStatusDict[testPermissionElementDisallowed.rpcName]).to(equal(@NO));
+ expect(allowedResultStatus.rpcName).to(equal(testAllowedStatus.rpcName));
+ expect(allowedResultStatus.allowedParameters).to(equal(testAllowedStatus.allowedParameters));
+ expect(allowedResultStatus.rpcAllowed).to(equal(@NO));
+
+ expect(disallowedResultStatus.rpcName).to(equal(testDisallowedStatus.rpcName));
+ expect(disallowedResultStatus.allowedParameters).to(equal(testDisallowedStatus.allowedParameters));
+ expect(disallowedResultStatus.rpcAllowed).to(equal(@NO));
});
});
});