def test_get_access_token__default(self, Command): """Verify that with no args, get_access_token returns the default token""" config = ScratchOrgConfig({}, "test") _marker = object() config._sfdx_info = {"access_token": _marker} access_token = config.get_access_token() assert access_token is _marker
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": "******", "created": True }, "test") config._sfdx_info = {} config._sfdx_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._sfdx_info)
def test_user_id_from_org(self, Command): sf = mock.Mock() sf.query_all.return_value = {"records": [{"Id": "test"}]} config = ScratchOrgConfig({"username": "******"}, "test") config._sfdx_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_password_from_sfdx_info(self, Command): config = ScratchOrgConfig({}, "test") _marker = object() config._sfdx_info = {"password": _marker} self.assertIs(config.password, _marker)
def test_username_from_sfdx_info(self, Command): config = ScratchOrgConfig({}, "test") _marker = object() config._sfdx_info = {"username": _marker} self.assertIs(config.username, _marker)
def test_instance_url(self, Command): config = ScratchOrgConfig({}, "test") _marker = object() config._sfdx_info = {"instance_url": _marker} self.assertIs(config.instance_url, _marker)
def test_access_token(self, Command): config = ScratchOrgConfig({}, "test") _marker = object() config._sfdx_info = {"access_token": _marker} self.assertIs(config.access_token, _marker)