123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999 |
- // _____ _
- // |_ _| |_ _ _ ___ ___ _ __ __ _
- // | | | ' \| '_/ -_) -_) ' \/ _` |_
- // |_| |_||_|_| \___\___|_|_|_\__,_(_)
- //
- // Threema iOS Client
- // Copyright (c) 2019-2020 Threema GmbH
- //
- // This program is free software: you can redistribute it and/or modify
- // it under the terms of the GNU Affero General Public License, version 3,
- // as published by the Free Software Foundation.
- //
- // This program is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- // GNU Affero General Public License for more details.
- //
- // You should have received a copy of the GNU Affero General Public License
- // along with this program. If not, see <https://www.gnu.org/licenses/>.
- #import <XCTest/XCTest.h>
- #import <OCMockito/OCMockito.h>
- #import <OCHamcrest/OCHamcrest.h>
- #import <ThreemaFramework/MDMSetup.h>
- #import "MyIdentityStore.h"
- #import "LicenseStore.h"
- #import "UserSettings.h"
- #define MOCKITO_SHORTHAND
- @interface MdmSetupTests : XCTestCase
- @end
- @implementation MdmSetupTests {
- __strong Class _mockMyIdentityStoreClass;
- MyIdentityStore* _mockMyIdentityStore;
- __strong Class _mockUserSettingsClass;
- UserSettings* _mockUserSettings;
- __strong Class _mockLicenseStoreClass;
- LicenseStore* _mockLicenseStore;
-
- NSNumber *_yes;
- NSNumber *_no;
- }
- - (void)setUp {
- [super setUp];
- _mockUserSettingsClass = mockClass([UserSettings class]);
- _mockUserSettings = mock([UserSettings class]);
- stubSingleton(_mockUserSettingsClass, sharedUserSettings);
- [given([UserSettings sharedUserSettings]) willReturn:_mockUserSettings];
- _mockLicenseStoreClass = mockClass([LicenseStore class]);
- _mockLicenseStore = mock([LicenseStore class]);
- stubSingleton(_mockLicenseStoreClass, sharedLicenseStore);
- [given([LicenseStore sharedLicenseStore]) willReturn:_mockLicenseStore];
- _mockMyIdentityStoreClass = mockClass([MyIdentityStore class]);
- _mockMyIdentityStore = mock([MyIdentityStore class]);
- stubSingleton(_mockMyIdentityStoreClass, sharedMyIdentityStore);
- [given([MyIdentityStore sharedMyIdentityStore]) willReturn:_mockMyIdentityStore];
-
- [self delMdm];
- _yes = [[NSNumber alloc] initWithUnsignedInt:1];
- _no = [[NSNumber alloc] initWithUnsignedInt:0];
- }
- - (void)tearDown {
- stopMocking(_mockUserSettings);
- stopMocking(_mockUserSettingsClass);
- _mockUserSettings = nil;
- _mockUserSettingsClass = nil;
-
- stopMocking(_mockLicenseStore);
- stopMocking(_mockLicenseStoreClass);
- _mockLicenseStore = nil;
- _mockLicenseStoreClass = nil;
- stopMocking(_mockMyIdentityStore);
- stopMocking(_mockMyIdentityStoreClass);
- _mockMyIdentityStore = nil;
- _mockMyIdentityStoreClass = nil;
-
- [self delMdm];
- [super tearDown];
- }
- - (void)delMdm {
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- [defaults removeObjectForKey:MDM_CONFIGURATION_KEY];
- [defaults removeObjectForKey:MDM_THREEMA_CONFIGURATION_KEY];
- [defaults synchronize];
- [MDMSetup clearMdmCache];
- }
- - (void)setMdm:(NSDictionary*)companyMdm threemaMdm:(NSDictionary*)threemaMdm {
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- if (companyMdm != nil) {
- [defaults setObject:companyMdm forKey:MDM_CONFIGURATION_KEY];
- }
- if (threemaMdm != nil) {
- [defaults setObject:threemaMdm forKey:MDM_THREEMA_CONFIGURATION_KEY];
- }
- [defaults synchronize];
- }
- - (void)testIsManaged {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
- id keys[] = { @"test"};
- id objects[] = { @"test"};
- NSUInteger count = sizeof(objects) / sizeof(id);
- NSDictionary* companyMdm = [NSDictionary dictionaryWithObjects:objects forKeys:keys count:count];
- [self setMdm:companyMdm threemaMdm:nil];
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:NO];
-
- XCTAssertTrue(mdmSetup.isManaged);
- }
- - (void)testIsManagedWithoutMdm {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
-
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:NO];
-
- XCTAssertFalse(mdmSetup.isManaged);
- }
- - (void)testLoadLicenseInfo {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
- id keys[] = { MDM_KEY_LICENSE_USERNAME, MDM_KEY_LICENSE_PASSWORD };
- id objects[] = { @"tester", @"testi123"};
- NSUInteger count = sizeof(objects) / sizeof(id);
- NSDictionary* companyMdm = [NSDictionary dictionaryWithObjects:objects forKeys:keys count:count];
- [self setMdm:companyMdm threemaMdm:nil];
-
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:NO];
-
- [mdmSetup loadLicenseInfo];
- [verify(_mockLicenseStore) setLicenseUsername:@"tester"];
- [verify(_mockLicenseStore) setLicensePassword:@"testi123"];
- }
- - (void)testLoadRenewableValues {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
-
- // Company-MDM
- [self setMdm:[self getAllMdmParameters:NO] threemaMdm:nil];
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:NO];
- [mdmSetup loadRenewableValues];
-
- [verify(_mockLicenseStore) setLicenseUsername:@"tester"];
- [verify(_mockLicenseStore) setLicensePassword:@"test1234"];
-
- [verifyCount(_mockMyIdentityStore, times(0)) setPushFromName:anything()];
- [verifyCount(_mockMyIdentityStore, times(0)) setFirstName:anything()];
- [verifyCount(_mockMyIdentityStore, times(0)) setLastName:anything()];
- [verifyCount(_mockMyIdentityStore, times(0)) setCsi:anything()];
- [verifyCount(_mockMyIdentityStore, times(0)) setCategory:anything()];
- [verifyCount(_mockMyIdentityStore, times(0)) setCreateIDEmail:anything()];
- [verifyCount(_mockMyIdentityStore, times(0)) setCreateIDPhone:anything()];
- XCTAssertTrue([mdmSetup readonlyProfile]);
- [verifyCount(_mockUserSettings, times(1)) setBlockUnknown:YES];
- [verifyCount(_mockUserSettings, times(1)) setSyncContacts:YES];
-
- XCTAssertTrue([mdmSetup disableSaveToGallery]);
- XCTAssertTrue([mdmSetup disableAddContact]);
- XCTAssertTrue([mdmSetup disableExport]);
- XCTAssertTrue([mdmSetup disableBackups]);
- XCTAssertTrue([mdmSetup disableIdExport]);
- XCTAssertTrue([mdmSetup disableSystemBackups]);
- XCTAssertTrue([mdmSetup disableMessagePreview]);
- XCTAssertTrue([mdmSetup disableSendProfilePicture]);
- XCTAssertTrue([mdmSetup disableCalls]);
- XCTAssertTrue([mdmSetup disableVideoCalls]);
- XCTAssertTrue([mdmSetup disableCreateGroup]);
- XCTAssertTrue([mdmSetup disableWeb]);
-
- XCTAssertTrue([mdmSetup skipWizard]);
- XCTAssertTrue([mdmSetup safeEnable]);
- XCTAssertEqual(@"87654321", [mdmSetup safePassword]);
- XCTAssertEqual(@"http://test.com", [mdmSetup safeServerUrl]);
- XCTAssertEqual(@"server-user", [mdmSetup safeServerUsername]);
- XCTAssertEqual(@"server-password", [mdmSetup safeServerPassword]);
- XCTAssertFalse([mdmSetup safeRestoreEnable]);
- XCTAssertEqual(@"ECHOECHO", [mdmSetup safeRestoreId]);
- XCTAssertEqual(@"^[0-9]{1,15}$", [mdmSetup safePasswordPattern]);
- XCTAssertEqual(@"Wrong-password-pattern", [mdmSetup safePasswordMessage]);
- XCTAssertEqual(@"threema.ch", [mdmSetup webHosts]);
- }
- - (void)testLoadIDCreationValues {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
-
- // Company-MDM
- [self setMdm:[self getAllMdmParameters:NO] threemaMdm:nil];
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:NO];
-
- [mdmSetup loadIDCreationValues];
-
- [verifyCount(_mockLicenseStore, times(0)) setLicenseUsername:anything()];
- [verifyCount(_mockLicenseStore, times(0)) setLicensePassword:anything()];
-
- [verifyCount(_mockMyIdentityStore, times(1)) setPushFromName:@"Eieri"];
- [verifyCount(_mockMyIdentityStore, times(1)) setFirstName:@"Heiri"];
- [verifyCount(_mockMyIdentityStore, times(1)) setLastName:@"Heirassa"];
- [verifyCount(_mockMyIdentityStore, times(1)) setCsi:@"customer-id"];
- [verifyCount(_mockMyIdentityStore, times(1)) setCategory:@"category"];
- [verifyCount(_mockMyIdentityStore, times(1)) setCreateIDEmail:@"linked@email.com"];
- [verifyCount(_mockMyIdentityStore, times(1)) setCreateIDPhone:@"111"];
-
- XCTAssertTrue([mdmSetup readonlyProfile]);
-
- [verifyCount(_mockUserSettings, times(0)) setBlockUnknown:anything()];
- [verifyCount(_mockUserSettings, times(1)) setSyncContacts:anything()];
-
- XCTAssertTrue([mdmSetup disableSaveToGallery]);
- XCTAssertTrue([mdmSetup disableAddContact]);
- XCTAssertTrue([mdmSetup disableExport]);
- XCTAssertTrue([mdmSetup disableBackups]);
- XCTAssertTrue([mdmSetup disableIdExport]);
- XCTAssertTrue([mdmSetup disableSystemBackups]);
- XCTAssertTrue([mdmSetup disableMessagePreview]);
- XCTAssertTrue([mdmSetup disableSendProfilePicture]);
- XCTAssertTrue([mdmSetup disableCalls]);
- XCTAssertTrue([mdmSetup disableVideoCalls]);
- XCTAssertTrue([mdmSetup disableCreateGroup]);
- XCTAssertTrue([mdmSetup disableWeb]);
-
- XCTAssertTrue([mdmSetup skipWizard]);
- XCTAssertEqual(_yes, [mdmSetup safeEnable]);
- XCTAssertEqual(@"87654321", [mdmSetup safePassword]);
- XCTAssertEqual(@"http://test.com", [mdmSetup safeServerUrl]);
- XCTAssertEqual(@"server-user", [mdmSetup safeServerUsername]);
- XCTAssertEqual(@"server-password", [mdmSetup safeServerPassword]);
- XCTAssertFalse([mdmSetup safeRestoreEnable]);
- XCTAssertEqual(@"ECHOECHO", [mdmSetup safeRestoreId]);
- XCTAssertEqual(@"^[0-9]{1,15}$", [mdmSetup safePasswordPattern]);
- XCTAssertEqual(@"Wrong-password-pattern", [mdmSetup safePasswordMessage]);
- XCTAssertEqual(@"threema.ch", [mdmSetup webHosts]);
- }
- - (void)testHasIDBackup {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
-
- id keys[] = { MDM_KEY_ID_BACKUP };
- id objects[] = { @"XXXX-XXXX-..." };
- NSUInteger count = sizeof(objects) / sizeof(id);
- NSDictionary *companyMdm = [NSDictionary dictionaryWithObjects:objects forKeys:keys count:count];
- [self setMdm:companyMdm threemaMdm:nil];
-
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:YES];
- BOOL result = [mdmSetup hasIDBackup];
-
- XCTAssertTrue(result);
- XCTAssertEqual(@"XXXX-XXXX-...", mdmSetup.idBackup);
- XCTAssertNil(mdmSetup.idBackupPassword);
- }
- /// Bestehende Firmen/Threema MDM-Parameter werden von renewable Threema MDM Parameter überschrieben (kein "setup" sync)
- - (void)testApplyThreemaMdmWithCompanyMdmAndThreemaMdmDoOverrideSetupNo {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
- // Company-MDM and "old" Threema-MDM are equal
- NSDictionary *oldWorkData = @{MDM_KEY_THREEMA_OVERRIDE:@true,MDM_KEY_THREEMA_PARAMS:[self getAllMdmParameters:YES]};
- [self setMdm:[self getAllMdmParameters:NO] threemaMdm:oldWorkData];
- // new Threema-MDM (override)
- id keysThreemaMdm[] = { MDM_KEY_LICENSE_USERNAME, MDM_KEY_LICENSE_PASSWORD, MDM_KEY_NICKNAME, MDM_KEY_FIRST_NAME, MDM_KEY_LAST_NAME, MDM_KEY_CSI, MDM_KEY_CATEGORY, MDM_KEY_LINKED_EMAIL, MDM_KEY_LINKED_PHONE, MDM_KEY_CONTACT_SYNC, MDM_KEY_READONLY_PROFILE, MDM_KEY_BLOCK_UNKNOWN, MDM_KEY_HIDE_INACTIVE_IDS, MDM_KEY_DISABLE_SAVE_TO_GALLERY, MDM_KEY_DISABLE_ADD_CONTACT, MDM_KEY_DISABLE_EXPORT, MDM_KEY_DISABLE_BACKUPS, MDM_KEY_DISABLE_ID_EXPORT, MDM_KEY_DISABLE_SYSTEM_BACKUPS, MDM_KEY_DISABLE_MESSAGE_PREVIEW, MDM_KEY_DISABLE_SEND_PROFILE_PICTURE, MDM_KEY_DISABLE_CALLS, MDM_KEY_DISABLE_VIDEO_CALLS, MDM_KEY_SKIP_WIZARD, MDM_KEY_DISABLE_CREATE_GROUP, MDM_KEY_DISABLE_WEB, MDM_KEY_SAFE_ENABLE, MDM_KEY_SAFE_SERVER_URL, MDM_KEY_SAFE_SERVER_USERNAME, MDM_KEY_SAFE_SERVER_PASSWORD, MDM_KEY_SAFE_RESTORE_ENABLE, MDM_KEY_SAFE_RESTORE_ID, MDM_KEY_SAFE_PASSWORD_PATTERN, MDM_KEY_SAFE_PASSWORD_MESSAGE, MDM_KEY_WEB_HOSTS, MDM_KEY_DISABLE_SHARE_MEDIA};
- id objectsThreemaMdm[] = { @"new-tester", @"new-test1234", @"New-Eieri", @"New-Heiri", @"New-Heirassa", @"new-customer-id", @"new-category", @"new-linked@email.com", @"222", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", _no, @"http://new-test.com", @"new-server-user", @"new-server-password", @"1", @"EINSZWEI", @"new-^[0-9]{1,15}$", @"New-Wrong-password-pattern", @"new.threema.ch", @"0"};
- NSUInteger countThreemaMdm = sizeof(objectsThreemaMdm) / sizeof(id);
- NSDictionary *threemaMdm = [NSDictionary dictionaryWithObjects:objectsThreemaMdm forKeys:keysThreemaMdm count:countThreemaMdm];
- NSDictionary *workData = @{MDM_KEY_THREEMA_CONFIGURATION: @{MDM_KEY_THREEMA_OVERRIDE:@true,MDM_KEY_THREEMA_PARAMS:threemaMdm}};
-
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:NO];
- [mdmSetup applyThreemaMdm:workData];
-
- [verify(_mockLicenseStore) setLicenseUsername:@"new-tester"];
- [verify(_mockLicenseStore) setLicensePassword:@"new-test1234"];
-
- [verifyCount(_mockMyIdentityStore, times(1)) setPushFromName:@"New-Eieri"];
- [verifyCount(_mockMyIdentityStore, times(1)) setFirstName:@"New-Heiri"];
- [verifyCount(_mockMyIdentityStore, times(1)) setLastName:@"New-Heirassa"];
- [verifyCount(_mockMyIdentityStore, times(1)) setCsi:@"new-customer-id"];
- [verifyCount(_mockMyIdentityStore, times(1)) setCategory:@"new-category"];
- [verifyCount(_mockMyIdentityStore, times(1)) setCreateIDEmail:@"linked@email.com"]; // not renewable
- [verifyCount(_mockMyIdentityStore, times(1)) setCreateIDPhone:@"111"]; // not renewable
-
- XCTAssertFalse([mdmSetup readonlyProfile]);
-
- [verifyCount(_mockUserSettings, times(1)) setBlockUnknown:NO];
- [verifyCount(_mockUserSettings, times(1)) setHideStaleContacts:NO];
- [verifyCount(_mockUserSettings, times(2)) setSyncContacts:NO];
-
- XCTAssertFalse([mdmSetup disableSaveToGallery]);
- XCTAssertFalse([mdmSetup disableAddContact]);
- XCTAssertFalse([mdmSetup disableExport]);
- XCTAssertFalse([mdmSetup disableBackups]);
- XCTAssertFalse([mdmSetup disableIdExport]);
- XCTAssertFalse([mdmSetup disableSystemBackups]);
- XCTAssertFalse([mdmSetup disableMessagePreview]);
- XCTAssertFalse([mdmSetup disableSendProfilePicture]);
- XCTAssertFalse([mdmSetup disableCalls]);
- XCTAssertFalse([mdmSetup disableVideoCalls]);
- XCTAssertFalse([mdmSetup disableCreateGroup]);
- XCTAssertFalse([mdmSetup disableWeb]);
- XCTAssertFalse([mdmSetup disableShareMedia]);
-
- XCTAssertTrue([mdmSetup skipWizard]); // not renewable
- XCTAssertEqual(_no, [mdmSetup safeEnable]);
- XCTAssertEqual(@"87654321", [mdmSetup safePassword]);
- XCTAssertEqual(@"http://new-test.com", [mdmSetup safeServerUrl]);
- XCTAssertEqual(@"new-server-user", [mdmSetup safeServerUsername]);
- XCTAssertEqual(@"new-server-password", [mdmSetup safeServerPassword]);
- XCTAssertFalse([mdmSetup safeRestoreEnable]); // not renewable
- XCTAssertEqual(@"ECHOECHO", [mdmSetup safeRestoreId]); // not renewable
- XCTAssertEqual(@"new-^[0-9]{1,15}$", [mdmSetup safePasswordPattern]);
- XCTAssertEqual(@"New-Wrong-password-pattern", [mdmSetup safePasswordMessage]);
- XCTAssertEqual(@"new.threema.ch", [mdmSetup webHosts]);
- }
- /// Bestehende Firmen MDM-Parameter werden von renewable Threema MDM-Parameter überschrieben (kein "setup" sync)
- - (void)testApplyThreemaMdmWithCompanyMdmAndNoThreemaMdmDoOverrideSetupNo {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
-
- // Company-MDM and NO "old" Threema-MDM
- [self setMdm:[self getAllMdmParameters:NO] threemaMdm:nil];
-
- // "new" Threema-MDM (override)
- id keysThreemaMdm[] = { MDM_KEY_LICENSE_USERNAME, MDM_KEY_LICENSE_PASSWORD, MDM_KEY_NICKNAME, MDM_KEY_FIRST_NAME, MDM_KEY_LAST_NAME, MDM_KEY_CSI, MDM_KEY_CATEGORY, MDM_KEY_LINKED_EMAIL, MDM_KEY_LINKED_PHONE, MDM_KEY_CONTACT_SYNC, MDM_KEY_READONLY_PROFILE, MDM_KEY_BLOCK_UNKNOWN, MDM_KEY_HIDE_INACTIVE_IDS, MDM_KEY_DISABLE_SAVE_TO_GALLERY, MDM_KEY_DISABLE_ADD_CONTACT, MDM_KEY_DISABLE_EXPORT, MDM_KEY_DISABLE_BACKUPS, MDM_KEY_DISABLE_ID_EXPORT, MDM_KEY_DISABLE_SYSTEM_BACKUPS, MDM_KEY_DISABLE_MESSAGE_PREVIEW, MDM_KEY_DISABLE_SEND_PROFILE_PICTURE, MDM_KEY_DISABLE_CALLS, MDM_KEY_DISABLE_VIDEO_CALLS, MDM_KEY_SKIP_WIZARD, MDM_KEY_DISABLE_CREATE_GROUP, MDM_KEY_DISABLE_WEB, MDM_KEY_SAFE_ENABLE, MDM_KEY_SAFE_SERVER_URL, MDM_KEY_SAFE_SERVER_USERNAME, MDM_KEY_SAFE_SERVER_PASSWORD, MDM_KEY_SAFE_RESTORE_ENABLE, MDM_KEY_SAFE_RESTORE_ID, MDM_KEY_SAFE_PASSWORD_PATTERN, MDM_KEY_SAFE_PASSWORD_MESSAGE, MDM_KEY_WEB_HOSTS, MDM_KEY_DISABLE_SHARE_MEDIA};
- id objectsThreemaMdm[] = { @"new-tester", @"new-test1234", @"New-Eieri", @"New-Heiri", @"New-Heirassa", @"new-customer-id", @"new-category", @"new-linked@email.com", @"222", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", _no, @"http://new-test.com", @"new-server-user", @"new-server-password", @"1", @"EINSZWEI", @"new-^[0-9]{1,15}$", @"New-Wrong-password-pattern", @"new.threema.ch", @"0" };
- NSUInteger countThreemaMdm = sizeof(objectsThreemaMdm) / sizeof(id);
- NSDictionary *threemaMdm = [NSDictionary dictionaryWithObjects:objectsThreemaMdm forKeys:keysThreemaMdm count:countThreemaMdm];
-
- NSDictionary *workData = @{MDM_KEY_THREEMA_CONFIGURATION: @{MDM_KEY_THREEMA_OVERRIDE:@true,MDM_KEY_THREEMA_PARAMS:threemaMdm}};
-
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:NO];
- [mdmSetup applyThreemaMdm:workData];
-
- [verify(_mockLicenseStore) setLicenseUsername:@"new-tester"];
- [verify(_mockLicenseStore) setLicensePassword:@"new-test1234"];
-
- [verifyCount(_mockMyIdentityStore, times(1)) setPushFromName:@"New-Eieri"];
- [verifyCount(_mockMyIdentityStore, times(1)) setFirstName:@"New-Heiri"];
- [verifyCount(_mockMyIdentityStore, times(1)) setLastName:@"New-Heirassa"];
- [verifyCount(_mockMyIdentityStore, times(1)) setCsi:@"new-customer-id"];
- [verifyCount(_mockMyIdentityStore, times(1)) setCategory:@"new-category"];
- [verifyCount(_mockMyIdentityStore, times(1)) setCreateIDEmail:@"linked@email.com"]; // not renewable
- [verifyCount(_mockMyIdentityStore, times(1)) setCreateIDPhone:@"111"]; // not renewable
-
- XCTAssertFalse([mdmSetup readonlyProfile]);
- [verifyCount(_mockUserSettings, times(1)) setBlockUnknown:NO];
- [verifyCount(_mockUserSettings, times(2)) setSyncContacts:NO];
- [verifyCount(_mockUserSettings, times(1)) setHideStaleContacts:NO];
- XCTAssertFalse([mdmSetup disableSaveToGallery]);
- XCTAssertFalse([mdmSetup disableAddContact]);
- XCTAssertFalse([mdmSetup disableExport]);
- XCTAssertFalse([mdmSetup disableBackups]);
- XCTAssertFalse([mdmSetup disableIdExport]);
- XCTAssertFalse([mdmSetup disableSystemBackups]);
- XCTAssertFalse([mdmSetup disableMessagePreview]);
- XCTAssertFalse([mdmSetup disableSendProfilePicture]);
- XCTAssertFalse([mdmSetup disableCalls]);
- XCTAssertFalse([mdmSetup disableVideoCalls]);
- XCTAssertFalse([mdmSetup disableCreateGroup]);
- XCTAssertFalse([mdmSetup disableWeb]);
- XCTAssertFalse([mdmSetup disableShareMedia]);
-
- XCTAssertTrue([mdmSetup skipWizard]); // not renewable
- XCTAssertEqual(_no, [mdmSetup safeEnable]);
- XCTAssertEqual(@"87654321", [mdmSetup safePassword]);
- XCTAssertEqual(@"http://new-test.com", [mdmSetup safeServerUrl]);
- XCTAssertEqual(@"new-server-user", [mdmSetup safeServerUsername]);
- XCTAssertEqual(@"new-server-password", [mdmSetup safeServerPassword]);
- XCTAssertFalse([mdmSetup safeRestoreEnable]); // not renewable
- XCTAssertEqual(@"ECHOECHO", [mdmSetup safeRestoreId]); // not renewable
- XCTAssertEqual(@"new-^[0-9]{1,15}$", [mdmSetup safePasswordPattern]);
- XCTAssertEqual(@"New-Wrong-password-pattern", [mdmSetup safePasswordMessage]);
- XCTAssertEqual(@"new.threema.ch", [mdmSetup webHosts]);
- }
- /// Keine bestehende MDM-Parameter, alle renewable Threema MDM-Parameter werden übernommen (kein "setup" sync)
- - (void)testApplyThreemaMdmWithNoCompanyMdmAndNoThreemaMdmDoOverrideSetupNo {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
-
- // No Company-MDM and no "old" Threema-MDM are equal
-
- // new Threema-MDM (override)
- id keysThreemaMdm[] = { MDM_KEY_LICENSE_USERNAME, MDM_KEY_LICENSE_PASSWORD, MDM_KEY_NICKNAME, MDM_KEY_FIRST_NAME, MDM_KEY_LAST_NAME, MDM_KEY_CSI, MDM_KEY_CATEGORY, MDM_KEY_LINKED_EMAIL, MDM_KEY_LINKED_PHONE, MDM_KEY_CONTACT_SYNC, MDM_KEY_READONLY_PROFILE, MDM_KEY_BLOCK_UNKNOWN, MDM_KEY_HIDE_INACTIVE_IDS, MDM_KEY_DISABLE_SAVE_TO_GALLERY, MDM_KEY_DISABLE_ADD_CONTACT, MDM_KEY_DISABLE_EXPORT, MDM_KEY_DISABLE_BACKUPS, MDM_KEY_DISABLE_ID_EXPORT, MDM_KEY_DISABLE_SYSTEM_BACKUPS, MDM_KEY_DISABLE_MESSAGE_PREVIEW, MDM_KEY_DISABLE_SEND_PROFILE_PICTURE, MDM_KEY_DISABLE_CALLS, MDM_KEY_DISABLE_VIDEO_CALLS, MDM_KEY_SKIP_WIZARD, MDM_KEY_DISABLE_CREATE_GROUP, MDM_KEY_DISABLE_WEB, MDM_KEY_SAFE_ENABLE, MDM_KEY_SAFE_SERVER_URL, MDM_KEY_SAFE_SERVER_USERNAME, MDM_KEY_SAFE_SERVER_PASSWORD, MDM_KEY_SAFE_RESTORE_ENABLE, MDM_KEY_SAFE_RESTORE_ID, MDM_KEY_SAFE_PASSWORD_PATTERN, MDM_KEY_SAFE_PASSWORD_MESSAGE, MDM_KEY_WEB_HOSTS, MDM_KEY_DISABLE_SHARE_MEDIA};
- id objectsThreemaMdm[] = { @"new-tester", @"new-test1234", @"New-Eieri", @"New-Heiri", @"New-Heirassa", @"new-customer-id", @"new-category", @"new-linked@email.com", @"222", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", @"0", _no, @"http://new-test.com", @"new-server-user", @"new-server-password", @"1", @"EINSZWEI", @"new-^[0-9]{1,15}$", @"New-Wrong-password-pattern", @"new.threema.ch", @"0" };
- NSUInteger countThreemaMdm = sizeof(objectsThreemaMdm) / sizeof(id);
- NSDictionary *threemaMdm = [NSDictionary dictionaryWithObjects:objectsThreemaMdm forKeys:keysThreemaMdm count:countThreemaMdm];
-
- NSDictionary *workData = @{MDM_KEY_THREEMA_CONFIGURATION: @{MDM_KEY_THREEMA_OVERRIDE:@true,MDM_KEY_THREEMA_PARAMS:threemaMdm}};
-
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:NO];
- [mdmSetup applyThreemaMdm:workData];
-
- [verify(_mockLicenseStore) setLicenseUsername:@"new-tester"];
- [verify(_mockLicenseStore) setLicensePassword:@"new-test1234"];
-
- [verifyCount(_mockMyIdentityStore, times(0)) setPushFromName:@"New-Heiri"];
- [verifyCount(_mockMyIdentityStore, times(1)) setFirstName:@"New-Heiri"];
- [verifyCount(_mockMyIdentityStore, times(1)) setLastName:@"New-Heirassa"];
- [verifyCount(_mockMyIdentityStore, times(1)) setCsi:@"new-customer-id"];
- [verifyCount(_mockMyIdentityStore, times(1)) setCategory:@"new-category"];
- [verifyCount(_mockMyIdentityStore, times(0)) setCreateIDEmail:anything()]; // not renewable
- [verifyCount(_mockMyIdentityStore, times(0)) setCreateIDPhone:anything()]; // not renewable
-
- XCTAssertFalse([mdmSetup readonlyProfile]);
- [verifyCount(_mockUserSettings, times(1)) setBlockUnknown:NO];
- XCTAssertTrue([mdmSetup existsMdmKey:MDM_KEY_BLOCK_UNKNOWN]);
- [verifyCount(_mockUserSettings, times(2)) setSyncContacts:NO];
- XCTAssertTrue([mdmSetup existsMdmKey:MDM_KEY_CONTACT_SYNC]);
- [verifyCount(_mockUserSettings, times(1)) setHideStaleContacts:NO];
- XCTAssertTrue([mdmSetup existsMdmKey:MDM_KEY_HIDE_INACTIVE_IDS]);
- XCTAssertFalse([mdmSetup disableSaveToGallery]);
- XCTAssertFalse([mdmSetup disableAddContact]);
- XCTAssertFalse([mdmSetup disableExport]);
- XCTAssertFalse([mdmSetup disableBackups]);
- XCTAssertFalse([mdmSetup disableIdExport]);
- XCTAssertFalse([mdmSetup disableSystemBackups]);
- XCTAssertFalse([mdmSetup disableMessagePreview]);
- XCTAssertFalse([mdmSetup disableSendProfilePicture]);
- XCTAssertFalse([mdmSetup disableCalls]);
- XCTAssertFalse([mdmSetup disableVideoCalls]);
- XCTAssertFalse([mdmSetup disableCreateGroup]);
- XCTAssertFalse([mdmSetup disableWeb]);
- XCTAssertFalse([mdmSetup disableShareMedia]);
-
- XCTAssertFalse([mdmSetup skipWizard]); // not renewable
- XCTAssertEqual(_no, [mdmSetup safeEnable]);
- XCTAssertNil([mdmSetup safePassword]);
- XCTAssertEqual(@"http://new-test.com", [mdmSetup safeServerUrl]);
- XCTAssertEqual(@"new-server-user", [mdmSetup safeServerUsername]);
- XCTAssertEqual(@"new-server-password", [mdmSetup safeServerPassword]);
- XCTAssertTrue([mdmSetup safeRestoreEnable]); // not renewable
- XCTAssertNil([mdmSetup safeRestoreId]); // not renewable
- XCTAssertEqual(@"new-^[0-9]{1,15}$", [mdmSetup safePasswordPattern]);
- XCTAssertEqual(@"New-Wrong-password-pattern", [mdmSetup safePasswordMessage]);
- XCTAssertEqual(@"new.threema.ch", [mdmSetup webHosts]);
- }
- /// Bestehende Threema MDM-Parameter weden entfernt
- - (void)testApplyThreemaMdmMissingParametersDoOverrideSetupNo {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
-
- // "old" Threema-MDM
- NSDictionary *oldWorkData = @{MDM_KEY_THREEMA_OVERRIDE:@true,MDM_KEY_THREEMA_PARAMS:[self getAllMdmParameters:YES]};
- [self setMdm:nil threemaMdm:oldWorkData];
-
- // "new" Threema-MDM (+)
- id keysThreemaMdm[] = { MDM_KEY_LICENSE_USERNAME, MDM_KEY_LICENSE_PASSWORD, MDM_KEY_LINKED_EMAIL, MDM_KEY_LINKED_PHONE, MDM_KEY_SKIP_WIZARD, };
- id objectsThreemaMdm[] = { @"new-tester", @"new-test1234", @"new-linked@email.com", @"222", @"0" };
- NSUInteger countThreemaMdm = sizeof(objectsThreemaMdm) / sizeof(id);
- NSDictionary *threemaMdm = [NSDictionary dictionaryWithObjects:objectsThreemaMdm forKeys:keysThreemaMdm count:countThreemaMdm];
-
- NSDictionary *workData = @{MDM_KEY_THREEMA_CONFIGURATION: @{MDM_KEY_THREEMA_OVERRIDE:@true,MDM_KEY_THREEMA_PARAMS:threemaMdm}};
-
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:NO];
- [mdmSetup applyThreemaMdm:workData];
-
- [verify(_mockLicenseStore) setLicenseUsername:@"new-tester"];
- [verify(_mockLicenseStore) setLicensePassword:@"new-test1234"];
-
- [verifyCount(_mockMyIdentityStore, times(0)) setPushFromName:anything()];
- [verifyCount(_mockMyIdentityStore, times(0)) setFirstName:anything()];
- [verifyCount(_mockMyIdentityStore, times(0)) setLastName:anything()];
- [verifyCount(_mockMyIdentityStore, times(0)) setCsi:anything()];
- [verifyCount(_mockMyIdentityStore, times(0)) setCategory:anything()];
- [verifyCount(_mockMyIdentityStore, times(0)) setCreateIDEmail:anything()]; // not renewable
- [verifyCount(_mockMyIdentityStore, times(0)) setCreateIDPhone:anything()]; // not renewable
-
- XCTAssertFalse([mdmSetup readonlyProfile]);
- [verifyCount(_mockUserSettings, times(0)) setBlockUnknown:anything()];
- XCTAssertFalse([mdmSetup existsMdmKey:MDM_KEY_BLOCK_UNKNOWN]);
- [verifyCount(_mockUserSettings, times(0)) setSyncContacts:anything()];
- XCTAssertFalse([mdmSetup existsMdmKey:MDM_KEY_CONTACT_SYNC]);
- [verifyCount(_mockUserSettings, times(0)) setHideStaleContacts:anything()];
- XCTAssertFalse([mdmSetup existsMdmKey:MDM_KEY_HIDE_INACTIVE_IDS]);
- XCTAssertFalse([mdmSetup disableSaveToGallery]);
- XCTAssertFalse([mdmSetup disableAddContact]);
- XCTAssertFalse([mdmSetup disableExport]);
- XCTAssertFalse([mdmSetup disableBackups]);
- XCTAssertFalse([mdmSetup disableIdExport]);
- XCTAssertFalse([mdmSetup disableSystemBackups]);
- XCTAssertFalse([mdmSetup disableMessagePreview]);
- XCTAssertFalse([mdmSetup disableSendProfilePicture]);
- XCTAssertFalse([mdmSetup disableCalls]);
- XCTAssertFalse([mdmSetup disableVideoCalls]);
- XCTAssertFalse([mdmSetup disableCreateGroup]);
- XCTAssertFalse([mdmSetup disableWeb]);
-
- XCTAssertFalse([mdmSetup skipWizard]); // not renewable
- XCTAssertNil([mdmSetup safeEnable]);
- XCTAssertNil([mdmSetup safePassword]);
- XCTAssertNil([mdmSetup safeServerUrl]);
- XCTAssertNil([mdmSetup safeServerUsername]);
- XCTAssertNil([mdmSetup safeServerPassword]);
- XCTAssertTrue([mdmSetup safeRestoreEnable]);
- XCTAssertNil([mdmSetup safeRestoreId]);
- XCTAssertNil([mdmSetup safePasswordPattern]);
- XCTAssertNil([mdmSetup safePasswordMessage]);
- XCTAssertNil([mdmSetup webHosts]);
- }
- /// Bestehendes Threema MDM wird deaktiviert
- - (void)testApplyThreemaMdmWithNoThreemaMdmDoOverrideSetupNo {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
-
- // "old" Threema-MDM
- NSDictionary *oldWorkData = @{MDM_KEY_THREEMA_OVERRIDE:@true,MDM_KEY_THREEMA_PARAMS:[self getAllMdmParameters:YES]};
- [self setMdm:nil threemaMdm:oldWorkData];
-
- // NO "new" Threema-MDM
- NSDictionary *workData = @{};
-
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:NO];
- [mdmSetup applyThreemaMdm:workData];
- [verifyCount(_mockLicenseStore, times(0)) setLicenseUsername:anything()];
- [verifyCount(_mockLicenseStore, times(0)) setLicensePassword:anything()];
-
- [verifyCount(_mockMyIdentityStore, times(0)) setPushFromName:anything()];
- [verifyCount(_mockMyIdentityStore, times(0)) setFirstName:anything()];
- [verifyCount(_mockMyIdentityStore, times(0)) setLastName:anything()];
- [verifyCount(_mockMyIdentityStore, times(0)) setCsi:anything()];
- [verifyCount(_mockMyIdentityStore, times(0)) setCategory:anything()];
- [verifyCount(_mockMyIdentityStore, times(0)) setCreateIDEmail:anything()];
- [verifyCount(_mockMyIdentityStore, times(0)) setCreateIDPhone:anything()];
-
- XCTAssertFalse([mdmSetup readonlyProfile]);
- [verifyCount(_mockUserSettings, times(0)) setBlockUnknown:anything()];
- XCTAssertFalse([mdmSetup existsMdmKey:MDM_KEY_BLOCK_UNKNOWN]);
- [verifyCount(_mockUserSettings, times(0)) setSyncContacts:anything()];
- XCTAssertFalse([mdmSetup existsMdmKey:MDM_KEY_CONTACT_SYNC]);
- [verifyCount(_mockUserSettings, times(0)) setHideStaleContacts:anything()];
- XCTAssertFalse([mdmSetup existsMdmKey:MDM_KEY_HIDE_INACTIVE_IDS]);
- XCTAssertFalse([mdmSetup disableSaveToGallery]);
- XCTAssertFalse([mdmSetup disableAddContact]);
- XCTAssertFalse([mdmSetup disableExport]);
- XCTAssertFalse([mdmSetup disableBackups]);
- XCTAssertFalse([mdmSetup disableIdExport]);
- XCTAssertFalse([mdmSetup disableSystemBackups]);
- XCTAssertFalse([mdmSetup disableMessagePreview]);
- XCTAssertFalse([mdmSetup disableSendProfilePicture]);
- XCTAssertFalse([mdmSetup disableCalls]);
- XCTAssertFalse([mdmSetup disableVideoCalls]);
- XCTAssertFalse([mdmSetup disableCreateGroup]);
- XCTAssertFalse([mdmSetup disableWeb]);
-
- XCTAssertFalse([mdmSetup skipWizard]);
- XCTAssertNil([mdmSetup safeEnable]);
- XCTAssertNil([mdmSetup safePassword]);
- XCTAssertNil([mdmSetup safeServerUrl]);
- XCTAssertNil([mdmSetup safeServerUsername]);
- XCTAssertNil([mdmSetup safeServerPassword]);
- XCTAssertTrue([mdmSetup safeRestoreEnable]);
- XCTAssertNil([mdmSetup safeRestoreId]);
- XCTAssertNil([mdmSetup safePasswordPattern]);
- XCTAssertNil([mdmSetup safePasswordMessage]);
- XCTAssertNil([mdmSetup webHosts]);
- }
- /// Bestehendes Firmen MDM wird mit Threema MDM aktulisiert ("normaler" sync: NICHT renewable Parameter werden NICHT übernommen)
- - (void)testApplyThreemaMdmWithCompanyMdmAddingThreemaMdmDoOverrideSetupNo {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
-
- // Company-MDM and NO "old" Threema-MDM
- id keysCompanyMdm[] = { MDM_KEY_LICENSE_USERNAME, MDM_KEY_LICENSE_PASSWORD, MDM_KEY_LINKED_EMAIL, MDM_KEY_LINKED_PHONE, MDM_KEY_SKIP_WIZARD, MDM_KEY_SAFE_PASSWORD, };
- id objectsCompanyMdm[] = { @"company-tester", @"company-test1234", @"company-linked@email.com", @"555", @"0", @"12345678" };
- NSUInteger countCompanyMdm = sizeof(objectsCompanyMdm) / sizeof(id);
- NSDictionary *companyMdm = [NSDictionary dictionaryWithObjects:objectsCompanyMdm forKeys:keysCompanyMdm count:countCompanyMdm];
- [self setMdm:companyMdm threemaMdm:nil];
-
- // "new" Threema-MDM (override)
- id keysMdm[] = { MDM_KEY_NICKNAME, MDM_KEY_FIRST_NAME, MDM_KEY_LAST_NAME, MDM_KEY_CSI, MDM_KEY_CATEGORY, MDM_KEY_CONTACT_SYNC, MDM_KEY_READONLY_PROFILE, MDM_KEY_BLOCK_UNKNOWN, MDM_KEY_HIDE_INACTIVE_IDS, MDM_KEY_DISABLE_SAVE_TO_GALLERY, MDM_KEY_DISABLE_ADD_CONTACT, MDM_KEY_DISABLE_EXPORT, MDM_KEY_DISABLE_BACKUPS, MDM_KEY_DISABLE_ID_EXPORT, MDM_KEY_DISABLE_SYSTEM_BACKUPS, MDM_KEY_DISABLE_MESSAGE_PREVIEW, MDM_KEY_DISABLE_SEND_PROFILE_PICTURE, MDM_KEY_DISABLE_CALLS, MDM_KEY_DISABLE_VIDEO_CALLS, MDM_KEY_SKIP_WIZARD, MDM_KEY_DISABLE_CREATE_GROUP, MDM_KEY_DISABLE_WEB, MDM_KEY_SAFE_ENABLE, MDM_KEY_SAFE_SERVER_URL, MDM_KEY_SAFE_SERVER_USERNAME, MDM_KEY_SAFE_SERVER_PASSWORD, MDM_KEY_SAFE_RESTORE_ENABLE, MDM_KEY_SAFE_RESTORE_ID, MDM_KEY_SAFE_PASSWORD_PATTERN, MDM_KEY_SAFE_PASSWORD_MESSAGE, MDM_KEY_WEB_HOSTS, MDM_KEY_DISABLE_SHARE_MEDIA };
- id objectsMdm[] = { @"Eieri", @"Heiri", @"Heirassa", @"customer-id", @"category" ,@"1" ,@"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", _yes, @"http://test.com", @"server-user", @"server-password", @"0", @"ECHOECHO", @"^[0-9]{1,15}$", @"Wrong-password-pattern", @"new.threema.ch", @"1" };
- NSUInteger countMdm = sizeof(objectsMdm) / sizeof(id);
- NSDictionary *mdm = [NSDictionary dictionaryWithObjects:objectsMdm forKeys:keysMdm count:countMdm];
-
- NSDictionary *workData = @{MDM_KEY_THREEMA_CONFIGURATION: @{MDM_KEY_THREEMA_OVERRIDE:@true,MDM_KEY_THREEMA_PARAMS:mdm}};
-
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:NO];
- [mdmSetup applyThreemaMdm:workData];
-
- [verify(_mockLicenseStore) setLicenseUsername:@"company-tester"];
- [verify(_mockLicenseStore) setLicensePassword:@"company-test1234"];
-
- [verifyCount(_mockMyIdentityStore, times(1)) setPushFromName:@"Eieri"];
- [verifyCount(_mockMyIdentityStore, times(1)) setFirstName:@"Heiri"];
- [verifyCount(_mockMyIdentityStore, times(1)) setLastName:@"Heirassa"];
- [verifyCount(_mockMyIdentityStore, times(1)) setCsi:@"customer-id"];
- [verifyCount(_mockMyIdentityStore, times(1)) setCategory:@"category"];
- [verifyCount(_mockMyIdentityStore, times(1)) setCreateIDEmail:@"company-linked@email.com"]; // not renewable
- [verifyCount(_mockMyIdentityStore, times(1)) setCreateIDPhone:@"555"]; // not renewable
-
- XCTAssertTrue([mdmSetup readonlyProfile]);
- [verifyCount(_mockUserSettings, times(1)) setBlockUnknown:YES];
- XCTAssertTrue([mdmSetup existsMdmKey:MDM_KEY_BLOCK_UNKNOWN]);
- [verifyCount(_mockUserSettings, times(2)) setSyncContacts:YES];
- XCTAssertTrue([mdmSetup existsMdmKey:MDM_KEY_CONTACT_SYNC]);
- [verifyCount(_mockUserSettings, times(1)) setHideStaleContacts:YES];
- XCTAssertTrue([mdmSetup existsMdmKey:MDM_KEY_HIDE_INACTIVE_IDS]);
- XCTAssertTrue([mdmSetup disableSaveToGallery]);
- XCTAssertTrue([mdmSetup disableAddContact]);
- XCTAssertTrue([mdmSetup disableExport]);
- XCTAssertTrue([mdmSetup disableBackups]);
- XCTAssertTrue([mdmSetup disableIdExport]);
- XCTAssertTrue([mdmSetup disableSystemBackups]);
- XCTAssertTrue([mdmSetup disableMessagePreview]);
- XCTAssertTrue([mdmSetup disableSendProfilePicture]);
- XCTAssertTrue([mdmSetup disableCalls]);
- XCTAssertTrue([mdmSetup disableVideoCalls]);
- XCTAssertTrue([mdmSetup disableCreateGroup]);
- XCTAssertTrue([mdmSetup disableWeb]);
- XCTAssertTrue([mdmSetup disableShareMedia]);
-
- XCTAssertFalse([mdmSetup skipWizard]); // not renewable
- XCTAssertTrue([mdmSetup safeEnable]);
- XCTAssertEqual(@"12345678", [mdmSetup safePassword]);
- XCTAssertEqual(@"http://test.com", [mdmSetup safeServerUrl]);
- XCTAssertEqual(@"server-user", [mdmSetup safeServerUsername]);
- XCTAssertEqual(@"server-password", [mdmSetup safeServerPassword]);
- XCTAssertTrue([mdmSetup safeRestoreEnable]); // not renewable
- XCTAssertNil([mdmSetup safeRestoreId]); // not renewable
- XCTAssertEqual(@"^[0-9]{1,15}$", [mdmSetup safePasswordPattern]);
- XCTAssertEqual(@"Wrong-password-pattern", [mdmSetup safePasswordMessage]);
- XCTAssertEqual(@"new.threema.ch", [mdmSetup webHosts]);
- }
- /// Bestehendes Firmen MDM wird mit Threema MDM aktulisiert ("setup" sync: NICHT renewable Parameter werden übernommen)
- - (void)testApplyThreemaMdmWithCompanyMdmAddingThreemaMdmDoOverrideSetupYes {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
-
- // Company-MDM and NO "old" Threema-MDM
- id keysCompanyMdm[] = { MDM_KEY_LICENSE_USERNAME, MDM_KEY_LICENSE_PASSWORD, MDM_KEY_LINKED_EMAIL, MDM_KEY_LINKED_PHONE, MDM_KEY_SKIP_WIZARD, MDM_KEY_SAFE_PASSWORD, };
- id objectsCompanyMdm[] = { @"company-tester", @"company-test1234", @"company-linked@email.com", @"555", @"0", @"12345678" };
- NSUInteger countCompanyMdm = sizeof(objectsCompanyMdm) / sizeof(id);
- NSDictionary *companyMdm = [NSDictionary dictionaryWithObjects:objectsCompanyMdm forKeys:keysCompanyMdm count:countCompanyMdm];
- [self setMdm:companyMdm threemaMdm:nil];
- // "new" Threema-MDM (override)
- id keysMdm[] = { MDM_KEY_NICKNAME, MDM_KEY_FIRST_NAME, MDM_KEY_LAST_NAME, MDM_KEY_CSI, MDM_KEY_CATEGORY, MDM_KEY_CONTACT_SYNC, MDM_KEY_READONLY_PROFILE, MDM_KEY_BLOCK_UNKNOWN, MDM_KEY_HIDE_INACTIVE_IDS, MDM_KEY_DISABLE_SAVE_TO_GALLERY, MDM_KEY_DISABLE_ADD_CONTACT, MDM_KEY_DISABLE_EXPORT, MDM_KEY_DISABLE_BACKUPS, MDM_KEY_DISABLE_ID_EXPORT, MDM_KEY_DISABLE_SYSTEM_BACKUPS, MDM_KEY_DISABLE_MESSAGE_PREVIEW, MDM_KEY_DISABLE_SEND_PROFILE_PICTURE, MDM_KEY_DISABLE_CALLS, MDM_KEY_DISABLE_VIDEO_CALLS, MDM_KEY_SKIP_WIZARD, MDM_KEY_DISABLE_CREATE_GROUP, MDM_KEY_DISABLE_WEB, MDM_KEY_SAFE_ENABLE, MDM_KEY_SAFE_SERVER_URL, MDM_KEY_SAFE_SERVER_USERNAME, MDM_KEY_SAFE_SERVER_PASSWORD, MDM_KEY_SAFE_RESTORE_ENABLE, MDM_KEY_SAFE_RESTORE_ID, MDM_KEY_SAFE_PASSWORD_PATTERN, MDM_KEY_SAFE_PASSWORD_MESSAGE, MDM_KEY_WEB_HOSTS, MDM_KEY_DISABLE_SHARE_MEDIA };
- id objectsMdm[] = { @"Eieri", @"Heiri", @"Heirassa", @"customer-id", @"category" ,@"1" ,@"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", _yes, @"http://test.com", @"server-user", @"server-password", @"0", @"ECHOECHO", @"^[0-9]{1,15}$", @"Wrong-password-pattern", @"new.threema.ch", @"1" };
- NSUInteger countMdm = sizeof(objectsMdm) / sizeof(id);
- NSDictionary *mdm = [NSDictionary dictionaryWithObjects:objectsMdm forKeys:keysMdm count:countMdm];
-
- NSDictionary *workData = @{MDM_KEY_THREEMA_CONFIGURATION: @{MDM_KEY_THREEMA_OVERRIDE:@true,MDM_KEY_THREEMA_PARAMS:mdm}};
-
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:YES];
- [mdmSetup applyThreemaMdm:workData];
-
- [verify(_mockLicenseStore) setLicenseUsername:@"company-tester"];
- [verify(_mockLicenseStore) setLicensePassword:@"company-test1234"];
-
- [verifyCount(_mockMyIdentityStore, times(1)) setPushFromName:@"Eieri"]; // not renewable
- [verifyCount(_mockMyIdentityStore, times(1)) setFirstName:@"Heiri"];
- [verifyCount(_mockMyIdentityStore, times(1)) setLastName:@"Heirassa"];
- [verifyCount(_mockMyIdentityStore, times(1)) setCsi:@"customer-id"];
- [verifyCount(_mockMyIdentityStore, times(1)) setCategory:@"category"];
- [verifyCount(_mockMyIdentityStore, times(1)) setCreateIDEmail:@"company-linked@email.com"]; // not renewable
- [verifyCount(_mockMyIdentityStore, times(1)) setCreateIDPhone:@"555"]; // not renewable
-
- XCTAssertTrue([mdmSetup readonlyProfile]);
- [verifyCount(_mockUserSettings, times(1)) setBlockUnknown:YES];
- XCTAssertTrue([mdmSetup existsMdmKey:MDM_KEY_BLOCK_UNKNOWN]);
- [verifyCount(_mockUserSettings, times(2)) setSyncContacts:YES];
- XCTAssertTrue([mdmSetup existsMdmKey:MDM_KEY_CONTACT_SYNC]);
- [verifyCount(_mockUserSettings, times(1)) setHideStaleContacts:YES];
- XCTAssertTrue([mdmSetup existsMdmKey:MDM_KEY_HIDE_INACTIVE_IDS]);
- XCTAssertTrue([mdmSetup disableSaveToGallery]);
- XCTAssertTrue([mdmSetup disableAddContact]);
- XCTAssertTrue([mdmSetup disableExport]);
- XCTAssertTrue([mdmSetup disableBackups]);
- XCTAssertTrue([mdmSetup disableIdExport]);
- XCTAssertTrue([mdmSetup disableSystemBackups]);
- XCTAssertTrue([mdmSetup disableMessagePreview]);
- XCTAssertTrue([mdmSetup disableSendProfilePicture]);
- XCTAssertTrue([mdmSetup disableCalls]);
- XCTAssertTrue([mdmSetup disableVideoCalls]);
- XCTAssertTrue([mdmSetup disableCreateGroup]);
- XCTAssertTrue([mdmSetup disableWeb]);
- XCTAssertTrue([mdmSetup disableShareMedia]);
-
- XCTAssertTrue([mdmSetup skipWizard]); // not renewable
- XCTAssertTrue([mdmSetup safeEnable]);
- XCTAssertEqual(@"12345678", [mdmSetup safePassword]);
- XCTAssertEqual(@"http://test.com", [mdmSetup safeServerUrl]);
- XCTAssertEqual(@"server-user", [mdmSetup safeServerUsername]);
- XCTAssertEqual(@"server-password", [mdmSetup safeServerPassword]);
- XCTAssertFalse([mdmSetup safeRestoreEnable]); // not renewable
- XCTAssertEqual(@"ECHOECHO", [mdmSetup safeRestoreId]); // not renewable
- XCTAssertEqual(@"^[0-9]{1,15}$", [mdmSetup safePasswordPattern]);
- XCTAssertEqual(@"Wrong-password-pattern", [mdmSetup safePasswordMessage]);
- XCTAssertEqual(@"new.threema.ch", [mdmSetup webHosts]);
- }
- /// Work-Lizenz nicht gültig, gewisse renewable "MDM" Settings werden zurückgesetzt
- - (void)testNoLicenseRequired {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:NO];
-
- // "old" Threema-MDM
- NSDictionary *oldWorkData = @{MDM_KEY_THREEMA_OVERRIDE:@true,MDM_KEY_THREEMA_PARAMS:[self getAllMdmParameters:YES]};
- [self setMdm:nil threemaMdm:oldWorkData];
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:NO];
-
- XCTAssertFalse(mdmSetup.isManaged);
- [verifyCount(_mockLicenseStore, times(0)) setLicenseUsername:anything()]; // not reset
- [verifyCount(_mockLicenseStore, times(0)) setLicensePassword:anything()]; // not reset
-
- [verifyCount(_mockMyIdentityStore, times(0)) setPushFromName:anything()]; // not reset
- [verifyCount(_mockMyIdentityStore, times(0)) setFirstName:anything()]; // not reset
- [verifyCount(_mockMyIdentityStore, times(0)) setLastName:anything()]; // not reset
- [verifyCount(_mockMyIdentityStore, times(0)) setCsi:anything()]; // not reset
- [verifyCount(_mockMyIdentityStore, times(0)) setCategory:anything()]; // not reset
- [verifyCount(_mockMyIdentityStore, times(0)) setCreateIDEmail:anything()]; // not reset
- [verifyCount(_mockMyIdentityStore, times(0)) setCreateIDPhone:anything()]; // not reset
-
- XCTAssertFalse([mdmSetup readonlyProfile]);
- [verifyCount(_mockUserSettings, times(0)) setBlockUnknown:anything()]; // not reset
- XCTAssertFalse([mdmSetup existsMdmKey:MDM_KEY_BLOCK_UNKNOWN]);
- [verifyCount(_mockUserSettings, times(0)) setSyncContacts:anything()];
- XCTAssertFalse([mdmSetup existsMdmKey:MDM_KEY_CONTACT_SYNC]);
- [verifyCount(_mockUserSettings, times(0)) setHideStaleContacts:anything()]; // not reset
- XCTAssertFalse([mdmSetup existsMdmKey:MDM_KEY_HIDE_INACTIVE_IDS]);
- XCTAssertFalse([mdmSetup disableSaveToGallery]);
- XCTAssertFalse([mdmSetup disableAddContact]);
- XCTAssertFalse([mdmSetup disableExport]);
- XCTAssertFalse([mdmSetup disableBackups]);
- XCTAssertFalse([mdmSetup disableIdExport]);
- XCTAssertFalse([mdmSetup disableSystemBackups]);
- XCTAssertFalse([mdmSetup disableMessagePreview]);
- XCTAssertFalse([mdmSetup disableSendProfilePicture]);
- XCTAssertFalse([mdmSetup disableCalls]);
- XCTAssertFalse([mdmSetup disableVideoCalls]);
- XCTAssertFalse([mdmSetup disableCreateGroup]);
- XCTAssertFalse([mdmSetup disableWeb]);
-
- XCTAssertFalse([mdmSetup skipWizard]);
- XCTAssertNil([mdmSetup safeEnable]);
- XCTAssertNil([mdmSetup safePassword]);
- XCTAssertNil([mdmSetup safeServerUrl]);
- XCTAssertNil([mdmSetup safeServerUsername]);
- XCTAssertNil([mdmSetup safeServerPassword]);
- XCTAssertTrue([mdmSetup safeRestoreEnable]);
- XCTAssertNil([mdmSetup safeRestoreId]);
- XCTAssertNil([mdmSetup safePasswordPattern]);
- XCTAssertNil([mdmSetup safePasswordMessage]);
- XCTAssertNil([mdmSetup webHosts]);
- }
- - (void)testSafeBackupDisable {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
-
- // Company-MDM
- id keysCompanyMdm[] = { MDM_KEY_DISABLE_BACKUPS };
- id objectsCompanyMdm[] = { @"1" };
- NSUInteger countCompanyMdm = sizeof(objectsCompanyMdm) / sizeof(id);
- NSDictionary *companyMdm = [NSDictionary dictionaryWithObjects:objectsCompanyMdm forKeys:keysCompanyMdm count:countCompanyMdm];
- [self setMdm:companyMdm threemaMdm:nil];
-
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:YES];
-
- XCTAssertTrue([mdmSetup isSafeBackupDisable]);
- XCTAssertFalse([mdmSetup isSafeBackupForce]);
- XCTAssertFalse([mdmSetup isSafeBackupPasswordPreset]);
- XCTAssertFalse([mdmSetup isSafeBackupServerPreset]);
-
- XCTAssertTrue([mdmSetup isSafeRestoreDisable]);
- XCTAssertFalse([mdmSetup isSafeRestoreForce]);
- XCTAssertFalse([mdmSetup isSafeRestorePasswordPreset]);
- XCTAssertFalse([mdmSetup isSafeRestoreServerPreset]);
- }
- - (void)testSafeBackupEnable {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
-
- // Company-MDM
- id keysCompanyMdm[] = { MDM_KEY_DISABLE_BACKUPS };
- id objectsCompanyMdm[] = { @"0" };
- NSUInteger countCompanyMdm = sizeof(objectsCompanyMdm) / sizeof(id);
- NSDictionary *companyMdm = [NSDictionary dictionaryWithObjects:objectsCompanyMdm forKeys:keysCompanyMdm count:countCompanyMdm];
- [self setMdm:companyMdm threemaMdm:nil];
-
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:YES];
-
- XCTAssertFalse([mdmSetup isSafeBackupDisable]);
- XCTAssertFalse([mdmSetup isSafeBackupForce]);
- XCTAssertFalse([mdmSetup isSafeBackupServerPreset]);
- XCTAssertFalse([mdmSetup isSafeBackupPasswordPreset]);
-
- XCTAssertFalse([mdmSetup isSafeRestoreDisable]);
- XCTAssertFalse([mdmSetup isSafeRestoreForce]);
- XCTAssertFalse([mdmSetup isSafeRestoreServerPreset]);
- XCTAssertFalse([mdmSetup isSafeRestorePasswordPreset]);
- }
- - (void)testBackupForce {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
-
- // Company-MDM
- id keysCompanyMdm[] = { MDM_KEY_DISABLE_BACKUPS, MDM_KEY_SAFE_ENABLE };
- id objectsCompanyMdm[] = { @"0", [[NSNumber alloc] initWithInt:1] };
- NSUInteger countCompanyMdm = sizeof(objectsCompanyMdm) / sizeof(id);
- NSDictionary *companyMdm = [NSDictionary dictionaryWithObjects:objectsCompanyMdm forKeys:keysCompanyMdm count:countCompanyMdm];
- [self setMdm:companyMdm threemaMdm:nil];
-
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:YES];
-
- XCTAssertFalse([mdmSetup isSafeBackupDisable]);
- XCTAssertTrue([mdmSetup isSafeBackupForce]);
- XCTAssertFalse([mdmSetup isSafeBackupServerPreset]);
- XCTAssertFalse([mdmSetup isSafeBackupPasswordPreset]);
-
- XCTAssertFalse([mdmSetup isSafeRestoreDisable]);
- XCTAssertFalse([mdmSetup isSafeRestoreForce]);
- XCTAssertFalse([mdmSetup isSafeRestoreServerPreset]);
- XCTAssertFalse([mdmSetup isSafeRestorePasswordPreset]);
- }
- - (void)testBackupWithServerAndPassword {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
-
- // Company-MDM
- id keysCompanyMdm[] = { MDM_KEY_DISABLE_BACKUPS, MDM_KEY_SAFE_SERVER_URL, MDM_KEY_SAFE_PASSWORD };
- id objectsCompanyMdm[] = { @"0", @"https://example.com", @"password" };
- NSUInteger countCompanyMdm = sizeof(objectsCompanyMdm) / sizeof(id);
- NSDictionary *companyMdm = [NSDictionary dictionaryWithObjects:objectsCompanyMdm forKeys:keysCompanyMdm count:countCompanyMdm];
- [self setMdm:companyMdm threemaMdm:nil];
-
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:YES];
-
- XCTAssertFalse([mdmSetup isSafeBackupDisable]);
- XCTAssertFalse([mdmSetup isSafeBackupForce]);
- XCTAssertTrue([mdmSetup isSafeBackupServerPreset]);
- XCTAssertFalse([mdmSetup isSafeBackupPasswordPreset]);
-
- XCTAssertFalse([mdmSetup isSafeRestoreDisable]);
- XCTAssertFalse([mdmSetup isSafeRestoreForce]);
- XCTAssertTrue([mdmSetup isSafeRestoreServerPreset]);
- XCTAssertFalse([mdmSetup isSafeRestorePasswordPreset]);
- }
- - (void)testBackupForceWithServerAndPassword {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
-
- // Company-MDM
- id keysCompanyMdm[] = { MDM_KEY_DISABLE_BACKUPS, MDM_KEY_SAFE_ENABLE, MDM_KEY_SAFE_SERVER_URL, MDM_KEY_SAFE_PASSWORD };
- id objectsCompanyMdm[] = { @"0", [[NSNumber alloc] initWithInt:1], @"https://example.com", @"password" };
- NSUInteger countCompanyMdm = sizeof(objectsCompanyMdm) / sizeof(id);
- NSDictionary *companyMdm = [NSDictionary dictionaryWithObjects:objectsCompanyMdm forKeys:keysCompanyMdm count:countCompanyMdm];
- [self setMdm:companyMdm threemaMdm:nil];
-
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:YES];
-
- XCTAssertFalse([mdmSetup isSafeBackupDisable]);
- XCTAssertTrue([mdmSetup isSafeBackupForce]);
- XCTAssertTrue([mdmSetup isSafeBackupServerPreset]);
- XCTAssertTrue([mdmSetup isSafeBackupPasswordPreset]);
-
- XCTAssertFalse([mdmSetup isSafeRestoreDisable]);
- XCTAssertFalse([mdmSetup isSafeRestoreForce]);
- XCTAssertTrue([mdmSetup isSafeRestoreServerPreset]);
- XCTAssertFalse([mdmSetup isSafeRestorePasswordPreset]);
- }
- - (void)testRestoreDisable {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
-
- // Company-MDM
- id keysCompanyMdm[] = { MDM_KEY_SAFE_RESTORE_ENABLE };
- id objectsCompanyMdm[] = { @"0" };
- NSUInteger countCompanyMdm = sizeof(objectsCompanyMdm) / sizeof(id);
- NSDictionary *companyMdm = [NSDictionary dictionaryWithObjects:objectsCompanyMdm forKeys:keysCompanyMdm count:countCompanyMdm];
- [self setMdm:companyMdm threemaMdm:nil];
-
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:YES];
-
- XCTAssertFalse([mdmSetup isSafeBackupDisable]);
- XCTAssertFalse([mdmSetup isSafeBackupForce]);
- XCTAssertFalse([mdmSetup isSafeBackupServerPreset]);
- XCTAssertFalse([mdmSetup isSafeBackupPasswordPreset]);
-
- XCTAssertTrue([mdmSetup isSafeRestoreDisable]);
- XCTAssertFalse([mdmSetup isSafeRestoreForce]);
- XCTAssertFalse([mdmSetup isSafeRestoreServerPreset]);
- XCTAssertFalse([mdmSetup isSafeRestorePasswordPreset]);
- }
- - (void)testRestoreEnable {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
-
- // Company-MDM
- id keysCompanyMdm[] = { MDM_KEY_SAFE_RESTORE_ENABLE };
- id objectsCompanyMdm[] = { @"1" };
- NSUInteger countCompanyMdm = sizeof(objectsCompanyMdm) / sizeof(id);
- NSDictionary *companyMdm = [NSDictionary dictionaryWithObjects:objectsCompanyMdm forKeys:keysCompanyMdm count:countCompanyMdm];
- [self setMdm:companyMdm threemaMdm:nil];
-
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:YES];
-
- XCTAssertFalse([mdmSetup isSafeBackupDisable]);
- XCTAssertFalse([mdmSetup isSafeBackupForce]);
- XCTAssertFalse([mdmSetup isSafeBackupServerPreset]);
- XCTAssertFalse([mdmSetup isSafeBackupPasswordPreset]);
-
- XCTAssertFalse([mdmSetup isSafeRestoreDisable]);
- XCTAssertFalse([mdmSetup isSafeRestoreForce]);
- XCTAssertFalse([mdmSetup isSafeRestoreServerPreset]);
- XCTAssertFalse([mdmSetup isSafeRestorePasswordPreset]);
- }
- - (void)testRestoreEnableWithServerAndPassword {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
-
- // Company-MDM
- id keysCompanyMdm[] = { MDM_KEY_SAFE_SERVER_URL, MDM_KEY_SAFE_PASSWORD, MDM_KEY_SAFE_RESTORE_ENABLE };
- id objectsCompanyMdm[] = { @"https://example.com", @"password", @"1" };
- NSUInteger countCompanyMdm = sizeof(objectsCompanyMdm) / sizeof(id);
- NSDictionary *companyMdm = [NSDictionary dictionaryWithObjects:objectsCompanyMdm forKeys:keysCompanyMdm count:countCompanyMdm];
- [self setMdm:companyMdm threemaMdm:nil];
-
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:YES];
-
- XCTAssertFalse([mdmSetup isSafeBackupDisable]);
- XCTAssertFalse([mdmSetup isSafeBackupForce]);
- XCTAssertTrue([mdmSetup isSafeBackupServerPreset]);
- XCTAssertFalse([mdmSetup isSafeBackupPasswordPreset]);
-
- XCTAssertFalse([mdmSetup isSafeRestoreDisable]);
- XCTAssertFalse([mdmSetup isSafeRestoreForce]);
- XCTAssertTrue([mdmSetup isSafeRestoreServerPreset]);
- XCTAssertFalse([mdmSetup isSafeRestorePasswordPreset]);
- }
- - (void)testRestoreForceWithServerAndPassword {
- [given([_mockLicenseStore getRequiresLicenseKey]) willReturnBool:YES];
-
- // Company-MDM
- id keysCompanyMdm[] = { MDM_KEY_SAFE_SERVER_URL, MDM_KEY_SAFE_PASSWORD, MDM_KEY_SAFE_RESTORE_ENABLE, MDM_KEY_SAFE_RESTORE_ID };
- id objectsCompanyMdm[] = { @"https://example.com", @"password", @"1", @"EINSZWEI" };
- NSUInteger countCompanyMdm = sizeof(objectsCompanyMdm) / sizeof(id);
- NSDictionary *companyMdm = [NSDictionary dictionaryWithObjects:objectsCompanyMdm forKeys:keysCompanyMdm count:countCompanyMdm];
- [self setMdm:companyMdm threemaMdm:nil];
-
- MDMSetup *mdmSetup = [[MDMSetup alloc] initWithSetup:YES];
-
- XCTAssertFalse([mdmSetup isSafeBackupDisable]);
- XCTAssertFalse([mdmSetup isSafeBackupForce]);
- XCTAssertTrue([mdmSetup isSafeBackupServerPreset]);
- XCTAssertFalse([mdmSetup isSafeBackupPasswordPreset]);
- XCTAssertFalse([mdmSetup isSafeRestoreDisable]);
- XCTAssertTrue([mdmSetup isSafeRestoreForce]);
- XCTAssertTrue([mdmSetup isSafeRestoreServerPreset]);
- XCTAssertTrue([mdmSetup isSafeRestorePasswordPreset]);
- }
- - (NSDictionary*)getAllMdmParameters:(BOOL)isThreemaMdm {
- id keysMdm[] = { MDM_KEY_LICENSE_USERNAME, MDM_KEY_LICENSE_PASSWORD, MDM_KEY_NICKNAME, MDM_KEY_FIRST_NAME, MDM_KEY_LAST_NAME, MDM_KEY_CSI, MDM_KEY_CATEGORY, MDM_KEY_LINKED_EMAIL, MDM_KEY_LINKED_PHONE, MDM_KEY_CONTACT_SYNC, MDM_KEY_READONLY_PROFILE, MDM_KEY_BLOCK_UNKNOWN, MDM_KEY_HIDE_INACTIVE_IDS, MDM_KEY_DISABLE_SAVE_TO_GALLERY, MDM_KEY_DISABLE_ADD_CONTACT, MDM_KEY_DISABLE_EXPORT, MDM_KEY_DISABLE_BACKUPS, MDM_KEY_DISABLE_ID_EXPORT, MDM_KEY_DISABLE_SYSTEM_BACKUPS, MDM_KEY_DISABLE_MESSAGE_PREVIEW, MDM_KEY_DISABLE_SEND_PROFILE_PICTURE, MDM_KEY_DISABLE_CALLS, MDM_KEY_DISABLE_VIDEO_CALLS, MDM_KEY_SKIP_WIZARD, MDM_KEY_DISABLE_CREATE_GROUP, MDM_KEY_DISABLE_WEB, MDM_KEY_SAFE_ENABLE, MDM_KEY_SAFE_SERVER_URL, MDM_KEY_SAFE_SERVER_USERNAME, MDM_KEY_SAFE_SERVER_PASSWORD, MDM_KEY_SAFE_RESTORE_ENABLE, MDM_KEY_SAFE_RESTORE_ID, MDM_KEY_SAFE_PASSWORD_PATTERN, MDM_KEY_SAFE_PASSWORD_MESSAGE, MDM_KEY_WEB_HOSTS, MDM_KEY_DISABLE_SHARE_MEDIA};
- id objectsMdm[] = { @"tester", @"test1234", @"Eieri", @"Heiri", @"Heirassa", @"customer-id", @"category", @"linked@email.com", @"111", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", @"1", _yes, @"http://test.com", @"server-user", @"server-password", @"0", @"ECHOECHO", @"^[0-9]{1,15}$", @"Wrong-password-pattern", @"threema.ch", @"1"};
-
- NSUInteger countMdm = sizeof(objectsMdm) / sizeof(id);
- NSMutableDictionary *mdm = [NSMutableDictionary dictionaryWithObjects:objectsMdm forKeys:keysMdm count:countMdm];
- // add parameter if not Threema-MDM
- if (!isThreemaMdm) {
- NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:@"87654321", MDM_KEY_SAFE_PASSWORD, nil];
- [mdm addEntriesFromDictionary:dic];
- }
- return mdm;
- }
- /*
- - (void)testPerformanceExample {
- // This is an example of a performance test case.
- [self measureBlock:^{
- // Put the code you want to measure the time of here.
- }];
- }
- */
- @end
|