Exemple #1
0
    def test_refresh_oauth_token(self, Command):
        result = b"""{
    "result": {
        "instanceUrl": "url",
        "accessToken": "access!token",
        "username": "******",
        "password": "******",
        "createdDate": "1970-01-01T:00:00:00Z",
        "expirationDate": "1970-01-08"
    }
}"""
        Command.return_value = mock.Mock(stdout=io.BytesIO(result),
                                         stderr=io.BytesIO(b""),
                                         returncode=0)

        config = ScratchOrgConfig({"username": "******"}, "test")
        config._scratch_info = {}
        config._scratch_info_date = datetime.now() - timedelta(days=1)
        config.force_refresh_oauth_token = mock.Mock()
        config._load_orginfo = mock.Mock()

        config.refresh_oauth_token(keychain=None)

        config.force_refresh_oauth_token.assert_called_once()
        self.assertTrue(config._scratch_info)
Exemple #2
0
 def test_pasword_from_scratch_info(self, Command):
     config = ScratchOrgConfig({}, 'test')
     _marker = object()
     config._scratch_info = {
         'password': _marker
     }
     self.assertIs(config.password, _marker)
Exemple #3
0
 def test_instance_url(self, Command):
     config = ScratchOrgConfig({}, 'test')
     _marker = object()
     config._scratch_info = {
         'instance_url': _marker,
     }
     self.assertIs(config.instance_url, _marker)
Exemple #4
0
 def test_org_id_from_scratch_info(self, Command):
     config = ScratchOrgConfig({}, 'test')
     _marker = object()
     config._scratch_info = {
         'org_id': _marker
     }
     self.assertIs(config.org_id, _marker)
Exemple #5
0
 def test_access_token(self, Command):
     config = ScratchOrgConfig({}, 'test')
     _marker = object()
     config._scratch_info = {
         'access_token': _marker,
     }
     self.assertIs(config.access_token, _marker)
Exemple #6
0
    def test_user_id_from_org(self, Command):
        sf = mock.Mock()
        sf.query_all.return_value = {"records": [{"Id": "test"}]}

        config = ScratchOrgConfig({"username": "******"}, "test")
        config._scratch_info = {
            "instance_url": "test_instance",
            "access_token": "token",
        }
        with mock.patch("cumulusci.core.config.OrgConfig.salesforce_client",
                        sf):
            self.assertEqual(config.user_id, "test")
    def test_user_id_from_org(self, Command):
        sf = mock.Mock()
        sf.query_all.return_value = {"records": [{"Id": "test"}]}

        config = ScratchOrgConfig({"username": "******"}, "test")
        config._scratch_info = {
            "instance_url": "test_instance",
            "access_token": "token",
        }
        # This is ugly...since ScratchOrgConfig is in a module
        # with the same name that is imported in cumulusci.core.config's
        # __init__.py, we have no way to externally grab the
        # module without going through the function's globals.
        with mock.patch.dict(
            ScratchOrgConfig.user_id.fget.__globals__,
            Salesforce=mock.Mock(return_value=sf),
        ):
            self.assertEqual(config.user_id, "test")
    def test_user_id_from_org(self, Command):
        sf = mock.Mock()
        sf.query_all.return_value = {"records": [{"Id": "test"}]}

        config = ScratchOrgConfig({"username": "******"}, "test")
        config._scratch_info = {
            "instance_url": "test_instance",
            "access_token": "token",
        }
        # This is ugly...since ScratchOrgConfig is in a module
        # with the same name that is imported in cumulusci.core.config's
        # __init__.py, we have no way to externally grab the
        # module without going through the function's globals.
        with mock.patch.dict(
            ScratchOrgConfig.user_id.fget.__globals__,
            Salesforce=mock.Mock(return_value=sf),
        ):
            self.assertEqual(config.user_id, "test")
Exemple #9
0
    def test_user_id_from_org(self, Command):
        sf = mock.Mock()
        sf.query_all.return_value = {
            'records': [
                {
                    'Id': 'test',
                },
            ],
        }

        config = ScratchOrgConfig({'username': '******'}, 'test')
        config._scratch_info = {
            'instance_url': 'test_instance',
            'access_token': 'token',
        }
        # This is ugly...since ScratchOrgConfig is in a module
        # with the same name that is imported in cumulusci.core.config's
        # __init__.py, we have no way to externally grab the
        # module without going through the function's globals.
        with mock.patch.dict(ScratchOrgConfig.user_id.fget.__globals__,
                             Salesforce=mock.Mock(return_value=sf)):
            self.assertEqual(config.user_id, 'test')
Exemple #10
0
    def test_refresh_oauth_token(self, Command):
        result = b'''{
    "result": {
        "instanceUrl": "url",
        "accessToken": "access!token",
        "username": "******",
        "password": "******"
    }
}'''
        Command.return_value = mock.Mock(stdout=io.BytesIO(result),
                                         stderr=io.BytesIO(b''),
                                         returncode=0)

        config = ScratchOrgConfig({'username': '******'}, 'test')
        config._scratch_info = {}
        config._scratch_info_date = datetime.now() - timedelta(days=1)
        config.force_refresh_oauth_token = mock.Mock()

        config.refresh_oauth_token(keychain=None)

        config.force_refresh_oauth_token.assert_called_once()
        self.assertTrue(config._scratch_info)
    def test_refresh_oauth_token(self, Command):
        result = b"""{
    "result": {
        "instanceUrl": "url",
        "accessToken": "access!token",
        "username": "******",
        "password": "******"
    }
}"""
        Command.return_value = mock.Mock(
            stdout=io.BytesIO(result), stderr=io.BytesIO(b""), returncode=0
        )

        config = ScratchOrgConfig({"username": "******"}, "test")
        config._scratch_info = {}
        config._scratch_info_date = datetime.now() - timedelta(days=1)
        config.force_refresh_oauth_token = mock.Mock()
        config._load_orginfo = mock.Mock()

        config.refresh_oauth_token(keychain=None)

        config.force_refresh_oauth_token.assert_called_once()
        self.assertTrue(config._scratch_info)
 def test_access_token(self, Command):
     config = ScratchOrgConfig({}, "test")
     _marker = object()
     config._scratch_info = {"access_token": _marker}
     self.assertIs(config.access_token, _marker)
 def test_username_from_scratch_info(self, Command):
     config = ScratchOrgConfig({}, "test")
     _marker = object()
     config._scratch_info = {"username": _marker}
     self.assertIs(config.username, _marker)
 def test_instance_url(self, Command):
     config = ScratchOrgConfig({}, "test")
     _marker = object()
     config._scratch_info = {"instance_url": _marker}
     self.assertIs(config.instance_url, _marker)
 def test_access_token(self, Command):
     config = ScratchOrgConfig({}, "test")
     _marker = object()
     config._scratch_info = {"access_token": _marker}
     self.assertIs(config.access_token, _marker)
 def test_instance_url(self, Command):
     config = ScratchOrgConfig({}, "test")
     _marker = object()
     config._scratch_info = {"instance_url": _marker}
     self.assertIs(config.instance_url, _marker)
 def test_username_from_scratch_info(self, Command):
     config = ScratchOrgConfig({}, "test")
     _marker = object()
     config._scratch_info = {"username": _marker}
     self.assertIs(config.username, _marker)
 def test_password_from_scratch_info(self, Command):
     config = ScratchOrgConfig({}, "test")
     _marker = object()
     config._scratch_info = {"password": _marker}
     self.assertIs(config.password, _marker)