Esempio n. 1
0
    def test__request_signed_url(self):
        apkf = Common.create_mock_apk_file()
        store = Common.create_mock_store()

        test_md5 = 'l32k43h2lh532k32jkfods9ads348aisdfiuaoer034f7s9347u123'
        test_customer = 'mason'
        test_apk = Apk(apkf)

        self.mason.set_id_token('09ads09a8dsfa0re')
        self.mason.set_access_token('oads098fa9830924qdf09asfd')
        self.mason.store = store

        expected_headers = {
            'Content-Type':
            'application/json',
            'Authorization':
            'Bearer 09ads09a8dsfa0re',
            'Content-MD5':
            u'bDMyazQzaDJsaDUzMmszMmprZm9kczlhZHMzNDhhaXNkZml1YW9lcjAzNGY3czkzNDd1MTIz'
        }

        # test getting the signed url request headers
        assert (expected_headers == self.mason._get_signed_url_request_headers(
            test_md5))
        expected_url = store.registry_signer_url() \
              + '/{0}/{1}/{2}'.format(test_customer, test_apk.get_name(), test_apk.get_version()) \
              + '?type=' + test_apk.get_type()
        # test getting the signed url endpoint
        actual_url = self.mason._get_signed_url_request_endpoint(
            test_customer, test_apk)
        assert (expected_url == actual_url)
Esempio n. 2
0
    def test__register_to_mason(self):
        apkf = Common.create_mock_apk_file()
        store = Common.create_mock_store()

        test_download_url = 'https://signed.magic.url.in.the.sky'
        test_sha1 = 'l32k43h2lh532k32jkfods9ads348aisdfiuaoer034f7s9347u123'
        test_customer = 'mason'
        test_apk = Apk(apkf)

        self.mason.set_id_token('09ads09a8dsfa0re')
        self.mason.set_access_token('oads098fa9830924qdf09asfd')
        self.mason.store = store

        expected_payload = {
            'name': test_apk.get_name(),
            'version': test_apk.get_version(),
            'customer': test_customer,
            'url': test_download_url,
            'type': test_apk.get_type(),
            'checksum': {
                'sha1': test_sha1
            }
        }

        assert (expected_payload == self.mason._get_registry_payload(
            test_customer, test_download_url, test_sha1, test_apk))

        expected_updated_payload = {
            'name': test_apk.get_name(),
            'version': test_apk.get_version(),
            'customer': test_customer,
            'url': test_download_url,
            'type': test_apk.get_type(),
            'checksum': {
                'sha1': test_sha1
            },
            'apk': {
                'versionName': test_apk.apkf.get_androidversion_name(),
                'versionCode': test_apk.apkf.get_androidversion_code(),
                'packageName': test_apk.apkf.package
            },
        }

        expected_payload.update(test_apk.get_registry_meta_data())

        assert (expected_updated_payload == expected_payload)
Esempio n. 3
0
    def test__upload_to_signed_url(self):
        apkf = Common.create_mock_apk_file()
        store = Common.create_mock_store()

        test_md5 = 'l32k43h2lh532k32jkfods9ads348aisdfiuaoer034f7s9347u123'
        test_apk = Apk(apkf)

        self.mason.set_id_token('09ads09a8dsfa0re')
        self.mason.set_access_token('oads098fa9830924qdf09asfd')
        self.mason.store = store

        expected_headers = {
            'Content-Type':
            test_apk.get_content_type(),
            'Content-MD5':
            u'bDMyazQzaDJsaDUzMmszMmprZm9kczlhZHMzNDhhaXNkZml1YW9lcjAzNGY3czkzNDd1MTIz'
        }

        assert (expected_headers == self.mason._get_signed_url_post_headers(
            test_apk, test_md5))
Esempio n. 4
0
    def test_authenticate(self):
        test_user = '******'
        test_password = '******'

        store = Common.create_mock_store()
        self.mason.set_id_token('09ads09a8dsfa0re')
        self.mason.set_access_token('oads098fa9830924qdf09asfd')
        self.mason.store = store

        expected_payload = {
            'client_id': store.client_id(),
            'username': test_user,
            'password': test_password,
            'id_token': '09ads09a8dsfa0re',
            'connection': 'Username-Password-Authentication',
            'grant_type': 'password',
            'scope': 'openid',
            'device': ''
        }

        assert (expected_payload == self.mason._get_auth_payload(
            test_user, test_password))
Esempio n. 5
0
 def _create_test_config():
     test_config = Common.create_config_file()
     return OSConfig(test_config)
Esempio n. 6
0
 def _create_media():
     media = Common.create_mock_media_file()
     return media
Esempio n. 7
0
 def _create_test_apk():
     apkf = Common.create_mock_apk_file()
     return Apk(apkf)
Esempio n. 8
0
 def setUp(self):
     config = Common.create_mock_config()
     platform = Platform(config)
     self.mason = platform.get(IMason)