Example #1
0
    def test_download_everything(self):
        """Can we download all the things?"""
        register_valid_responses()
        api = ICloudApi(user=settings.get('test', 'user'), key=settings.get('test', 'key'))
        api.login(apple_id=settings.get('test', 'apple_id'), password=settings.get('test', 'password'))

        for device_id in api.devices.keys():
            data = api.backup_client.request_data(device_id=device_id)

            assert data is not None

            # Dump the data to our workspace folder for perusal
            filename = '%s.json' % api.devices[device_id]['device_name']
            with open(os.path.join(WORKSPACE_ROOT, filename), 'wb') as out:
                json.dump(data, out, indent=4)

            if len(data['photos']) > 0 and data['photos'][0] != 'Upgrade to view this data.':
                # We have some photos, let's download them too

                for photo in data['photos']:
                    filename = photo['filename']
                    file_id = photo['file_id']

                    with open(os.path.join(WORKSPACE_ROOT, filename), 'wb') as out:
                        api.backup_client.download_file(device_id=device_id, file_id=file_id, out=out)
Example #2
0
    def test_2fa_required(self):
        """What happens when 2FA is enabled?"""
        register_2fa_responses()
        api = ICloudApi(user=settings.get('test', 'user'), key=settings.get('test', 'key'))

        try:
            api.login(apple_id=settings.get('test', 'apple_id'), password=settings.get('test', 'password'))
            raise pytest.skip('2FA is not enabled for this account.')
        except TwoFactorAuthenticationRequired:
            pass

        # The trusted devices fields should now be populated
        assert len(api.trusted_devices) > 0
Example #3
0
 def test_log_in(self):
     """Can we log in successfull to the API?"""
     register_valid_responses()
     api = ICloudApi(user=settings.get('test', 'user'), key=settings.get('test', 'key'))
     api.login(apple_id=settings.get('test', 'apple_id'), password=settings.get('test', 'password'))