def check18():
    '''
    check18 - Locate the "archived-expanded-entitlements.xcent"
    :return:
    '''

    logging.info("Check 18: Locate the 'archived-expanded-entitlements.xcent'")

    fileName = rootFolder + "PlugIns/GLAExtensionWatchKit.appex/archived-expanded-entitlements.xcent"

    checkMethods.checkFileExists(fileName)

    try:
        data = checkMethods.loadPlist(fileName)

        checkMethods.checkValue(
                "com.apple.security.application-groups",
                ["group.uk.co.guardian.iphone2"],
                data["com.apple.security.application-groups"]
        )

        checkMethods.checkValue(
                "keychain-access-groups",
                ["U9LTYR56M6.uk.co.guardian.SharedKeychain"],
                data["keychain-access-groups"]
        )
        logging.info('\n')
    except IOError:
        logging.error("ERROR file missing: " + fileName)
        sys.exit(1)
def check21():
    '''
    check21 - Locate the "archived-expanded-entitlements.xcent"
    :return:
    '''

    logging.info("Check 21: Locate the 'archived-expanded-entitlements.xcent'")

    fileName = rootFolder + "PlugIns/GLAExtensionWatchKit.appex/GLAWatchApp.app/archived-expanded-entitlements.xcent"

    checkMethods.checkFileExists(fileName)

    try:
        data = checkMethods.loadPlist(fileName)

        checkMethods.checkValue(
                "application-identifier",
                "U9LTYR56M6.uk.co.guardian.iphone2.watchapp",
                data["application-identifier"]
        )

        checkMethods.checkValue(
                "keychain-access-groups",
                ["U9LTYR56M6.uk.co.guardian.iphone2.watchapp"],
                data["keychain-access-groups"]
        )
        logging.info('\n')
    except IOError:
        logging.error("ERROR file missing: " + fileName)
        sys.exit(1)
def check14():
    '''
    check14 - Locate the "ADBMobileConfig.json" file
    '''

    logging.info("Check 14: Locate the 'ADBMobileConfig.json'")

    fileName = rootFolder + "PlugIns/GLAExtensionToday.appex/ADBMobileConfig.json"

    checkMethods.checkFileExists(fileName)

    try:
        with open(fileName) as data_file:
            checkData1 = json.load(data_file)

        rsids = checkData1["analytics"]["rsids"]
        server = checkData1["analytics"]["server"]

        checkMethods.checkValue("analytics.rsids", "guardiangu-globalapps-prod", rsids)
        checkMethods.checkValue("analytics.server", "hits-secure.theguardian.com", server)

        logging.info('\n')
    except IOError:
        logging.error("ERROR file missing: " + fileName)
        sys.exit(1)
def check3():
    '''
    check3 - Locate the "archived-expanded-entitlements.xcent)
    '''
    logging.info('\n')
    logging.info("Check 3: Locate the 'archived-expanded-entitlements.xcent'")

    fileName = rootFolder + "archived-expanded-entitlements.xcent"

    checkMethods.checkFileExists(fileName)

    try:
        data = checkMethods.loadPlist(fileName)

        checkMethods.checkListAny(
                "com.apple.developer.associated-domains",
                ["activitycontinuation:www.theguardian.com", "applinks:www.theguardian.com"],
                data["com.apple.developer.associated-domains"]
        )

        checkMethods.checkValue(
                "com.apple.security.application-groups",
                ["group.uk.co.guardian.iphone2"],
                data["com.apple.security.application-groups"]
        )

        checkMethods.checkValue(
                "keychain-access-groups",
                ["U9LTYR56M6.uk.co.guardian.SharedKeychain"],
                data["keychain-access-groups"]
        )
        logging.info('\n')
    except IOError:
        logging.error("ERROR file missing: " + fileName)
        sys.exit(1)
def check1():
    '''
    check1 - Locate the "ADBMobileConfig.json" file
    '''

    logging.info("Check 1: Locate the 'ADBMobileConfig.json'")

    fileName = rootFolder + "ADBMobileConfig.json"

    checkMethods.checkFileExists(fileName)

    try:
        with open(fileName) as data_file:
            checkData1 = json.load(data_file)
        # pprint(data) - this prints out the jSON to the console

        rsids = checkData1["analytics"]["rsids"]
        server = checkData1["analytics"]["server"]

        checkMethods.checkValue("analytics.rsids", "guardiangu-globalapps-prod", rsids)
        checkMethods.checkValue("analytics.server", "hits-secure.theguardian.com", server)

    except IOError:
        logging.error("ERROR file missing: " + fileName)
        exit
def check10():
    '''
    check10 - Locate the "Info.plist"
    '''

    logging.info("Check 10: Locate the 'Info.plist'")

    fileName = rootFolder + "Watch/GLAWatchApp2.app/Info.plist"

    checkMethods.checkFileExists(fileName)

    try:
        data = checkMethods.loadPlist(fileName)

        checkMethods.checkValue(
                "CFBundleIdentifier",
                "uk.co.guardian.iphone2.watchapp",
                data["CFBundleIdentifier"]
        )

        checkMethods.checkValue(
                "CFBundleShortVersionString",
                CFBundleShortVersionString,
                data["CFBundleShortVersionString"]
        )

        checkMethods.checkValue(
                "CFBundleVersion",
                CFBundleVersion,
                data["CFBundleVersion"]
        )

        checkMethods.checkValue(
                "WKCompanionAppBundleIdentifier",
                "uk.co.guardian.iphone2",
                data["WKCompanionAppBundleIdentifier"]
        )

        checkMethods.checkValue(
                "UIDeviceFamily",
                [4],
                data["UIDeviceFamily"]
        )
        logging.info('\n')
    except IOError:
        logging.error("ERROR file missing: " + fileName)
        sys.exit(1)
def check13():
    '''
    check13: - Locate the 'Info.plist
    :return:
    '''

    logging.info("Check 13: Locate the 'Info.plist'")

    fileName = rootFolder + "Watch/GLAWatchApp2.app/PlugIns/GLAExtensionWatchKit2.appex/Info.plist"

    checkMethods.checkFileExists(fileName)

    try:
        data = checkMethods.loadPlist(fileName)

        checkMethods.checkValue("CFBundleIdentifier",
                                "uk.co.guardian.iphone2.watchapp.extw",
                                data["CFBundleIdentifier"]
                                )

        checkMethods.checkValue("CFBundleShortVersionString",
                                CFBundleShortVersionString,
                                data["CFBundleShortVersionString"]
                                )

        checkMethods.checkValue("CFBundleVersion",
                                CFBundleVersion,
                                data["CFBundleVersion"]
                                )

        application_groups = data["NSExtension"]["NSExtensionAttributes"]["WKAppBundleIdentifier"]
        checkMethods.checkValue(
                "WKAppBundleIdentifier",
                "uk.co.guardian.iphone2.watchapp",
                application_groups
        )

        checkMethods.checkValue(
                "UIDeviceFamily",
                [4],
                data["UIDeviceFamily"]
        )
        logging.info('\n')
    except IOError:
        logging.error("ERROR file missing: " + fileName)
        sys.exit(1)
def check6():
    '''
    check6 - Locate the "Info.plist"
    '''

    logging.info("Check 6: Locate the 'Info.plist'")

    fileName = rootFolder + "Info.plist"

    checkMethods.checkFileExists(fileName)

    try:
        data = checkMethods.loadPlist(fileName)

        checkMethods.checkValue(
                "BuildTier",
                "release",
                data["BuildTier"]
        )

        checkMethods.checkValue(
                "CFBundleIdentifier",
                "uk.co.guardian.iphone2",
                data["CFBundleIdentifier"]
        )

        checkMethods.checkValue(
                "CFBundleShortVersionString",
                CFBundleShortVersionString,
                data["CFBundleShortVersionString"]
        )

        checkMethods.checkValue(
                "CFBundleVersion",
                CFBundleVersion,
                data["CFBundleVersion"]
        )

        checkMethods.checkListAny(
                "UIDeviceFamily",
                [1, 2],
                data["UIDeviceFamily"]
        )
    except IOError:
        logging.error("ERROR file missing: " + fileName)
        sys.exit(1)
def check17():
    '''
    check17 - Locate the "Info.plist"
    '''

    logging.info("Check 17: Locate the 'Info.plist'")

    fileName = rootFolder + "PlugIns/GLAExtensionToday.appex/Info.plist"

    checkMethods.checkFileExists(fileName)

    try:

        data = checkMethods.loadPlist(fileName)

        checkMethods.checkValue(
                "CFBundleIdentifier",
                "uk.co.guardian.iphone2.extt",
                data["CFBundleIdentifier"]
        )

        checkMethods.checkValue(
                "CFBundleShortVersionString",
                CFBundleShortVersionString,
                data["CFBundleShortVersionString"]
        )

        checkMethods.checkValue(
                "CFBundleVersion",
                CFBundleVersion,
                data["CFBundleVersion"]
        )

        checkMethods.checkListAny(
                "UIDeviceFamily",
                [1, 2],
                data["UIDeviceFamily"]
        )
        logging.info('\n')
    except IOError:
        logging.error("ERROR file missing: " + fileName)
        sys.exit(1)