summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicoleYarroch <nicole@livio.io>2020-09-17 16:17:57 -0400
committerNicoleYarroch <nicole@livio.io>2020-09-17 16:17:57 -0400
commited730033a440a30992e76ab27b64267c9af35b7f (patch)
tree5c310d5121bf122974f37b7944803e134df0edaa
parentb2667d8f587f39577bcdd0c73054b5304e3ac397 (diff)
downloadsdl_ios-feature/0312_update_min_required_iOS_version_to_10.tar.gz
Fixed how appId is set in the lifecycle configfeature/0312_update_min_required_iOS_version_to_10
Signed-off-by: NicoleYarroch <nicole@livio.io>
-rw-r--r--SmartDeviceLink/public/SDLLifecycleConfiguration.h6
-rw-r--r--SmartDeviceLink/public/SDLLifecycleConfiguration.m14
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleConfigurationSpec.m40
-rw-r--r--SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLRegisterAppInterfaceSpec.m4
4 files changed, 37 insertions, 27 deletions
diff --git a/SmartDeviceLink/public/SDLLifecycleConfiguration.h b/SmartDeviceLink/public/SDLLifecycleConfiguration.h
index a7f3c71ba..455c1aec9 100644
--- a/SmartDeviceLink/public/SDLLifecycleConfiguration.h
+++ b/SmartDeviceLink/public/SDLLifecycleConfiguration.h
@@ -50,7 +50,7 @@ typedef NS_OPTIONS(NSUInteger, SDLSecondaryTransports) {
* A debug configuration that runs using TCP. Additional functionality should be customized on the properties.
*
* @param appName The name of the app.
- * @param fullAppId The full app id to be used. This should be registered with the head unit's manufacturer. When set, the `appId` parameter will be set automatically to the first 10 non-dash characters of the `fullAppId`.
+ * @param fullAppId The full app id to be used. This should be registered with the head unit's manufacturer. When set, the `appId` parameter will be set automatically to the first 10 non-dash characters of the `fullAppId` if the `fullAppId` is a valid UUID string.
* @param ipAddress The ip address of the server to connect to
* @param port The port of the server to connect to
*
@@ -85,14 +85,14 @@ typedef NS_OPTIONS(NSUInteger, SDLSecondaryTransports) {
*
* Required
*/
-@property (copy, nonatomic, readonly) NSString *appId;
+@property (copy, nonatomic) NSString *appId;
/**
* The full app id. This must be the same as the full app id received from the SDL developer portal.
*
* Optional
*
- * @discussion The `fullAppId` is used to authenticate apps that connect with head units that implement SDL Core v.5.0 and newer. If connecting with older head units, the `fullAppId` can be truncated to create the required `appId` needed to register the app. The `appId` is the first 10 non-dash ("-") characters of the `fullAppId` (e.g. if you have a `fullAppId` of 123e4567-e89b-12d3-a456-426655440000, the `appId` will be 123e4567e8).
+ * @discussion The `fullAppId` is used to authenticate apps that connect with modules that support RPC spec v.5.0 and newer. If connecting with older modules, the `fullAppId` can be truncated to create the required `appId` needed to register the app on older modules. The `appId` is the first 10 non-dash ("-") characters of the `fullAppId` (e.g. if you have a `fullAppId` of 123e4567-e89b-12d3-a456-426655440000, the `appId` will be 123e4567e8).
*/
@property (copy, nonatomic, nullable, readonly) NSString *fullAppId;
diff --git a/SmartDeviceLink/public/SDLLifecycleConfiguration.m b/SmartDeviceLink/public/SDLLifecycleConfiguration.m
index 18fb19535..47af7e63b 100644
--- a/SmartDeviceLink/public/SDLLifecycleConfiguration.m
+++ b/SmartDeviceLink/public/SDLLifecycleConfiguration.m
@@ -70,7 +70,7 @@ static NSUInteger const AppIdCharacterCount = 10;
_allowedSecondaryTransports = SDLSecondaryTransportsTCP;
_fullAppId = fullAppId;
- _appId = [self.class sdl_shortAppIdFromFullAppId:fullAppId];
+ _appId = [self.class sdl_isValidUUID:fullAppId] ? [self.class sdl_shortAppIdFromFullAppId:fullAppId] : fullAppId;
return self;
}
@@ -113,10 +113,6 @@ static NSUInteger const AppIdCharacterCount = 10;
* @return An `appID` made of the first 10 non-dash characters of the "fullAppID"
*/
+ (NSString *)sdl_shortAppIdFromFullAppId:(NSString *)fullAppId {
- // Do not generate a short app id unless the fullAppID is greater than 10 characters
- if (fullAppId.length <= AppIdCharacterCount) {
- return @"";
- }
NSString *filteredString = [self sdl_filterDashesFromText:fullAppId];
return [filteredString substringToIndex:MIN(AppIdCharacterCount, filteredString.length)];
}
@@ -132,6 +128,14 @@ static NSUInteger const AppIdCharacterCount = 10;
return [[text componentsSeparatedByCharactersInSet:supportedCharacters] componentsJoinedByString:@""];
}
+/// Checks if a string is a valid UUID
+/// @param uuidString A string
+/// @return True if the string is a valid UUID, false if not
++ (BOOL)sdl_isValidUUID:(NSString *)uuidString {
+ NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:uuidString];
+ return uuid == nil ? NO : YES;
+}
+
#pragma mark - NSCopying
- (id)copyWithZone:(nullable NSZone *)zone {
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleConfigurationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleConfigurationSpec.m
index 8b2776c22..da30cb2eb 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleConfigurationSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLifecycleConfigurationSpec.m
@@ -29,8 +29,8 @@ QuickSpecBegin(SDLLifecycleConfigurationSpec)
describe(@"A lifecycle configuration", ^{
__block SDLLifecycleConfiguration *testConfig = nil;
__block NSString *testAppName = @"An App Name";
- __block NSString *testFullAppId = @"-ab--987-adfa651kj-212346h3kjkaju";
- __block NSString *expectedGeneratedAppId = @"ab987adfa6";
+ __block NSString *testFullAppId = @"123e4567-e89b-12d3-a456-426614174000";
+ __block NSString *expectedGeneratedAppId = @"123e4567e8";
__block SDLVersion *baseVersion = nil;
beforeEach(^{
@@ -72,18 +72,20 @@ describe(@"A lifecycle configuration", ^{
__block NSArray<SDLTTSChunk *> *testTTSName = nil;
__block NSArray<NSString *> *testSynonyms = nil;
__block NSString *testResumeHashString = nil;
+ __block NSString *testAppId = nil;
beforeEach(^{
- testConfig = [SDLLifecycleConfiguration defaultConfigurationWithAppName:testAppName fullAppId:testFullAppId];
- });
-
- it(@"it should get and set correctly", ^{
testShortAppName = @"Short Name";
testTTSChunk = [[SDLTTSChunk alloc] initWithText:@"test tts name" type:SDLSpeechCapabilitiesText];
testTTSName = @[testTTSChunk];
testSynonyms = @[@"Test 1", @"Test 2", @"Test 3", @"Test 4"];
testResumeHashString = @"testing";
+ testAppId = @"pppppppppppppppppppppppppppppppppppppppppp";
+
+ testConfig = [SDLLifecycleConfiguration defaultConfigurationWithAppName:testAppName fullAppId:testFullAppId];
+ });
+ it(@"it should get and set correctly", ^{
testConfig.appType = SDLAppHMITypeMedia;
testConfig.additionalAppTypes = @[SDLAppHMITypeProjection];
testConfig.language = SDLLanguageArSa;
@@ -94,13 +96,14 @@ describe(@"A lifecycle configuration", ^{
testConfig.resumeHash = testResumeHashString;
testConfig.minimumProtocolVersion = [SDLVersion versionWithString:@"1.0.0"];
testConfig.minimumRPCVersion = [SDLVersion versionWithString:@"2.0.0"];
+ testConfig.appId = testAppId;
});
afterEach(^{
expect(testConfig.appName).to(match(testAppName));
expect(testConfig.shortAppName).to(match(testShortAppName));
expect(testConfig.fullAppId).to(match(testFullAppId));
- expect(testConfig.appId).to(match(expectedGeneratedAppId));
+ expect(testConfig.appId).to(match(testAppId));
expect(testConfig.tcpDebugMode).to(beFalse());
expect(testConfig.tcpDebugIPAddress).to(match(@"192.168.0.1"));
expect(@(testConfig.tcpDebugPort)).to(equal(@12345));
@@ -161,6 +164,7 @@ describe(@"A lifecycle configuration", ^{
__block NSArray<NSString *> *testSynonyms = nil;
__block NSString *testResumeHashString = nil;
__block SDLVersion *testVersion = nil;
+ __block NSString *testAppId = nil;
beforeEach(^{
testConfig = [SDLLifecycleConfiguration debugConfigurationWithAppName:testAppName fullAppId:testFullAppId ipAddress:testIPAddress port:testPort];
@@ -173,6 +177,7 @@ describe(@"A lifecycle configuration", ^{
testSynonyms = @[@"Test 1", @"Test 2", @"Test 3", @"Test 4"];
testResumeHashString = @"testing";
testVersion = [SDLVersion versionWithMajor:1 minor:0 patch:0];
+ testAppId = @"p&4rrqwervw-jolmk";
testConfig.appType = SDLAppHMITypeInformation;
testConfig.additionalAppTypes = @[SDLAppHMITypeProjection];
@@ -184,13 +189,14 @@ describe(@"A lifecycle configuration", ^{
testConfig.resumeHash = testResumeHashString;
testConfig.minimumRPCVersion = testVersion;
testConfig.minimumProtocolVersion = testVersion;
+ testConfig.appId = testAppId;
});
afterEach(^{
expect(testConfig.appName).to(match(testAppName));
expect(testConfig.shortAppName).to(match(testShortAppName));
expect(testConfig.fullAppId).to(match(testFullAppId));
- expect(testConfig.appId).to(match(expectedGeneratedAppId));
+ expect(testConfig.appId).to(match(testAppId));
expect(testConfig.tcpDebugMode).to(beTrue());
expect(testConfig.tcpDebugIPAddress).to(match(@"1.1.1.1"));
expect(@(testConfig.tcpDebugPort)).to(equal(@42));
@@ -217,22 +223,22 @@ describe(@"When generating the `appId` from the `fullAppId`", ^{
expect(appId).to(beEmpty());
});
- it(@"should return a string truncated to the first non-dash 10 characters", ^{
- NSString *testFullAppId = @"34-uipe--k-rtqwedeftg-1";
+ it(@"should return an empty string if the full app id only has dashes", ^{
+ NSString *testFullAppId = @"--";
NSString *appId = [SDLLifecycleConfiguration sdl_shortAppIdFromFullAppId:testFullAppId];
- expect(appId).to(match(@"34uipekrtq"));
+ expect(appId).to(beEmpty());
});
- it(@"should return an empty string if the full app id is equal to 10 characters", ^{
- NSString *testFullAppId = @"TenChars10";
+ it(@"should return a string truncated to the first non-dash 10 characters", ^{
+ NSString *testFullAppId = @"34-uipe--k-rtqwedeftg-1";
NSString *appId = [SDLLifecycleConfiguration sdl_shortAppIdFromFullAppId:testFullAppId];
- expect(appId).to(beEmpty());
+ expect(appId).to(match(@"34uipekrtq"));
});
- it(@"should return an empty string if the full app id is less than 10 characters", ^{
- NSString *testFullAppId = @"a";
+ it(@"should return the full app id if the full app id is less than 10 characters", ^{
+ NSString *testFullAppId = @"ab";
NSString *appId = [SDLLifecycleConfiguration sdl_shortAppIdFromFullAppId:testFullAppId];
- expect(appId).to(beEmpty());
+ expect(appId).to(equal(testFullAppId));
});
});
diff --git a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLRegisterAppInterfaceSpec.m b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLRegisterAppInterfaceSpec.m
index 2d7b0afd1..ae5adf8ad 100644
--- a/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLRegisterAppInterfaceSpec.m
+++ b/SmartDeviceLinkTests/RPCSpecs/RequestSpecs/SDLRegisterAppInterfaceSpec.m
@@ -28,8 +28,8 @@ describe(@"RegisterAppInterface Tests", ^{
__block SDLRegisterAppInterface *testRegisterAppInterface = nil;
__block NSString *appName = @"app56";
__block NSString *appId = @"123456789";
- __block NSString *fullAppId = @"123-e4567-e89b-12d3-a456-426655440000";
- __block NSString *expectedAppId = @"123e4567e8";
+ __block NSString *fullAppId = @"e5bafdfa-f921-11ea-adc1-0242ac120002";
+ __block NSString *expectedAppId = @"e5bafdfaf9";
__block NSString *shortAppName = @"whatisanngn";
__block NSString *resumeHash = @"gercd35grw2";
__block NSString *vrSynonyms = @"app56";