Skip to content

Commit

Permalink
Merge branch 'main' into cleanup-warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jstvz authored Jan 26, 2024
2 parents 00d2bb0 + 68b769e commit e7915db
Show file tree
Hide file tree
Showing 136 changed files with 7,315 additions and 1,398 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/feature_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, sfdc-ubuntu-latest, sfdc-windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
exclude: # FIXME: Remove when lxml publishes a 311-windows wheel
- os: sfdc-windows-latest
python-version: "3.11"
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand Down Expand Up @@ -74,7 +71,7 @@ jobs:
- name: Install sfdx
run: |
mkdir sfdx
wget -qO- https://developer.salesforce.com/media/salesforce-cli/sfdx/channels/stable/sfdx-linux-x64.tar.xz | tar xJ -C sfdx --strip-components 1
wget -qO- https://developer.salesforce.com/media/salesforce-cli/sf/channels/stable/sf-linux-x64.tar.xz | tar xJ -C sfdx --strip-components 1
echo $(realpath sfdx/bin) >> $GITHUB_PATH
- name: Authenticate Dev Hub
run: |
Expand Down
2 changes: 2 additions & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ For example:

* Ed Rivas (jerivas)
* Gustavo Tandeciarz (dcinzona)
* Chandler Anderson (zenibako)
* Ben French (BenjaminFrench)
2 changes: 1 addition & 1 deletion cumulusci/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.75.1"
__version__ = "3.83.0"
18 changes: 15 additions & 3 deletions cumulusci/cli/org.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def calculate_org_days(info):
@pass_runtime(require_project=False, require_keychain=True)
def org_info(runtime, org_name, print_json):
org_name, org_config = runtime.get_org(org_name)
org_config.refresh_oauth_token(runtime.keychain)
org_config.refresh_oauth_token(runtime.keychain, print_json)
console = Console()
if print_json:
click.echo(
Expand All @@ -330,6 +330,7 @@ def org_info(runtime, org_name, print_json):
"instance_url",
"instance_name",
"is_sandbox",
"namespace",
"namespaced",
"org_id",
"org_type",
Expand Down Expand Up @@ -562,9 +563,20 @@ def org_remove(runtime, org_name, global_org):
@click.option(
"--no-password", is_flag=True, help="If set, don't set a password for the org"
)
@click.option(
"--release",
help="If provided, specify either previous or preview when creating a scratch org",
)
@pass_runtime(require_keychain=True)
def org_scratch(runtime, config_name, org_name, default, devhub, days, no_password):
def org_scratch(
runtime, config_name, org_name, default, devhub, days, no_password, release=None
):
runtime.check_org_overwrite(org_name)
release_options = ["previous", "preview"]
if release and release not in release_options:
raise click.UsageError(
"Release options value is not valid. Either specify preview or previous."
)

scratch_configs = runtime.project_config.lookup("orgs__scratch")
if not scratch_configs:
Expand All @@ -579,7 +591,7 @@ def org_scratch(runtime, config_name, org_name, default, devhub, days, no_passwo
scratch_config["devhub"] = devhub

runtime.keychain.create_scratch_org(
org_name, config_name, days, set_password=not (no_password)
org_name, config_name, days, set_password=not (no_password), release=release
)

if default:
Expand Down
8 changes: 4 additions & 4 deletions cumulusci/cli/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def callback(*args, **kwargs):
set_global_default = kwargs.pop("default", False)

serv_conf = dict(
(k, v) for k, v in list(kwargs.items()) if v is not None
(k, v.strip()) for k, v in list(kwargs.items()) if v is not None
) # remove None values

# A service can define a callable to validate the service config
Expand Down Expand Up @@ -305,7 +305,7 @@ def service_update(
for attr in attributes:
attr_name, attr_value = attr
if attr_name in service_config.config:
service_config.config[attr_name] = attr_value
service_config.config[attr_name] = attr_value.strip()
attributes_were_updated = True
else:
available_attributes = ", ".join(service_attributes)
Expand All @@ -324,7 +324,7 @@ def service_update(
)
if user_input != "":
attributes_were_updated = True
service_config.config[attr] = user_input
service_config.config[attr] = user_input.strip()

if attributes_were_updated:
runtime.keychain.set_service(service_type, service_name, service_config)
Expand Down Expand Up @@ -371,7 +371,7 @@ def get_service_data(service_config, sensitive_attributes) -> list:
click.style(k, bold=True),
(
(v[:5] + (len(v[5:]) * "*") if len(v) > 10 else "*" * len(v))
if k in sensitive_attributes
if k in sensitive_attributes and v is not None
else str(v)
),
]
Expand Down
64 changes: 51 additions & 13 deletions cumulusci/cli/tests/test_org.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
)
from cumulusci.core.keychain import BaseProjectKeychain
from cumulusci.core.tests.utils import MockLookup
from cumulusci.tests.util import CURRENT_SF_API_VERSION
from cumulusci.utils import parse_api_datetime

from .. import org
Expand Down Expand Up @@ -108,7 +109,7 @@ def test_org_connect(self, auth_code_flow):
)
responses.add(
method="GET",
url="https://instance/services/data/v45.0/sobjects/Organization/OODxxxxxxxxxxxx",
url=f"https://instance/services/data/v{CURRENT_SF_API_VERSION}/sobjects/Organization/OODxxxxxxxxxxxx",
json={
"TrialExpirationDate": None,
"OrganizationType": "Developer Edition",
Expand All @@ -118,7 +119,11 @@ def test_org_connect(self, auth_code_flow):
},
status=200,
)
responses.add("GET", "https://instance/services/data", json=[{"version": 45.0}])
responses.add(
"GET",
"https://instance/services/data",
json=[{"version": CURRENT_SF_API_VERSION}],
)

result = run_cli_command("org", "connect", "test", "--default", runtime=runtime)

Expand Down Expand Up @@ -161,7 +166,7 @@ def test_org_connect__non_default_connected_app(self, auth_code_flow):
)
responses.add(
method="GET",
url="https://instance/services/data/v45.0/sobjects/Organization/OODxxxxxxxxxxxx",
url=f"https://instance/services/data/v{CURRENT_SF_API_VERSION}/sobjects/Organization/OODxxxxxxxxxxxx",
json={
"TrialExpirationDate": None,
"OrganizationType": "Developer Edition",
Expand All @@ -171,7 +176,11 @@ def test_org_connect__non_default_connected_app(self, auth_code_flow):
},
status=200,
)
responses.add("GET", "https://instance/services/data", json=[{"version": 45.0}])
responses.add(
"GET",
"https://instance/services/data",
json=[{"version": CURRENT_SF_API_VERSION}],
)

result = run_cli_command(
"org", "connect", "test", "--connected_app", "other", runtime=runtime
Expand Down Expand Up @@ -288,7 +297,7 @@ def test_org_connect_expires(self, oauth2client):
)
responses.add(
method="GET",
url="https://instance/services/data/v45.0/sobjects/Organization/OODxxxxxxxxxxxx",
url=f"https://instance/services/data/v{CURRENT_SF_API_VERSION}/sobjects/Organization/OODxxxxxxxxxxxx",
json={
"TrialExpirationDate": "1970-01-01T12:34:56.000+0000",
"OrganizationType": "Developer Edition",
Expand All @@ -298,7 +307,11 @@ def test_org_connect_expires(self, oauth2client):
},
status=200,
)
responses.add("GET", "https://instance/services/data", json=[{"version": 45.0}])
responses.add(
"GET",
"https://instance/services/data",
json=[{"version": CURRENT_SF_API_VERSION}],
)

run_click_command(
org.org_connect,
Expand Down Expand Up @@ -415,11 +428,11 @@ def test_org_import__persistent_org(self, cmd):
method="GET",
url="https://instance/services/data",
status=200,
json=[{"version": "54.0"}],
json=[{"version": CURRENT_SF_API_VERSION}],
)
responses.add(
method="GET",
url="https://instance/services/data/v54.0/sobjects/Organization/OODxxxxxxxxxxxx",
url=f"https://instance/services/data/v{CURRENT_SF_API_VERSION}/sobjects/Organization/OODxxxxxxxxxxxx",
json={
"TrialExpirationDate": None,
"OrganizationType": "Developer Edition",
Expand Down Expand Up @@ -470,11 +483,11 @@ def test_org_import__trial_org(self, cmd):
method="GET",
url="https://instance/services/data",
status=200,
json=[{"version": "54.0"}],
json=[{"version": CURRENT_SF_API_VERSION}],
)
responses.add(
method="GET",
url="https://instance/services/data/v54.0/sobjects/Organization/OODxxxxxxxxxxxx",
url=f"https://instance/services/data/v{CURRENT_SF_API_VERSION}/sobjects/Organization/OODxxxxxxxxxxxx",
json={
"TrialExpirationDate": api_datetime,
"OrganizationType": "Developer Edition",
Expand Down Expand Up @@ -540,6 +553,7 @@ def test_org_info(self):
"default": True,
"password": None,
"connected_app": "built-in",
"namespace": "test",
}
org_config.expires = date.today()
org_config.latest_api_version = "42.0"
Expand All @@ -557,6 +571,7 @@ def test_org_info(self):
["\x1b[1mconnected_app\x1b[0m", "built-in"],
["\x1b[1mdays\x1b[0m", "1"],
["\x1b[1mdefault\x1b[0m", "True"],
["\x1b[1mnamespace\x1b[0m", "test"],
["\x1b[1mpassword\x1b[0m", "None"],
],
)
Expand Down Expand Up @@ -1247,20 +1262,40 @@ def test_org_scratch(self):
devhub="hub",
days=7,
no_password=True,
release="previous",
)

runtime.check_org_overwrite.assert_called_once()
runtime.keychain.create_scratch_org.assert_called_with(
"test", "dev", 7, set_password=False
"test", "dev", 7, set_password=False, release="previous"
)
runtime.keychain.set_default_org.assert_called_with("test")

def test_org_scratch__not_default(self):
def test_org_scratch_release_invalid(self):
runtime = mock.Mock()

runtime.project_config.lookup = MockLookup(
orgs__scratch={"dev": {"orgName": "Dev"}}
)
with pytest.raises(click.UsageError):
run_click_command(
org.org_scratch,
runtime=runtime,
config_name="dev",
org_name="test",
default=True,
devhub="hub",
days=7,
no_password=True,
release="next",
)
runtime.check_org_overwrite.assert_called_once()

def test_org_scratch__not_default(self):
runtime = mock.Mock()
runtime.project_config.lookup = MockLookup(
orgs__scratch={"dev": {"orgName": "Dev"}}
)
run_click_command(
org.org_scratch,
runtime=runtime,
Expand All @@ -1270,11 +1305,12 @@ def test_org_scratch__not_default(self):
devhub="hub",
days=7,
no_password=True,
release=None,
)

runtime.check_org_overwrite.assert_called_once()
runtime.keychain.create_scratch_org.assert_called_with(
"test", "dev", 7, set_password=False
"test", "dev", 7, set_password=False, release=None
)

def test_org_scratch_no_configs(self):
Expand All @@ -1291,6 +1327,7 @@ def test_org_scratch_no_configs(self):
devhub="hub",
days=7,
no_password=True,
release="previous",
)

def test_org_scratch_config_not_found(self):
Expand All @@ -1307,6 +1344,7 @@ def test_org_scratch_config_not_found(self):
devhub="hub",
days=7,
no_password=True,
release="previous",
)

def test_org_scratch_delete(self):
Expand Down
2 changes: 1 addition & 1 deletion cumulusci/cli/tests/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_plan_list(self, cli_table, runtime):

run_click_command(plan.plan_list, runtime=runtime, print_json=False)

cli_table.called_once_with(
cli_table.assert_called_once_with(
data=[
["Name", "Title", "Slug", "Tier"],
["plan 1", "Test Plan #1", "plan1_slug", "primary"],
Expand Down
53 changes: 53 additions & 0 deletions cumulusci/cli/tests/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,28 @@ def test_service_connect_validator_failure():
run_cli_command("service", "connect", "test", "test-alias", runtime=runtime)


def test_service_connect_without_whitespaces():
attr_value = " Sample attr value "
attr_value_without_whitespaces = "Sample attr value"
runtime = BaseCumulusCI(
config={"services": {"test": {"attributes": {"attr": {"required": False}}}}}
)

result = run_cli_command(
"service",
"connect",
"test",
"test-alias",
"--attr",
attr_value,
runtime=runtime,
)

result = runtime.keychain.get_service("test", "test-alias")
assert attr_value != result.attr
assert attr_value_without_whitespaces == result.attr


def test_service_update__success():
# Create a new color-picker service type
runtime = CliRuntime(
Expand Down Expand Up @@ -334,6 +356,37 @@ def test_service_update__success():
assert original_color not in result.output


def test_service_update_without_whitespaces():
# Create a new color-picker service type
runtime = CliRuntime(
config={
"services": {"color-picker": {"attributes": {"color": {"required": False}}}}
}
)
# Setup an existing service of type color-picker
original_color = "Turquoise"
runtime.keychain.set_service(
"color-picker",
"foo",
ServiceConfig({"color": original_color}),
)
# Update the existing service
chosen_color = " Maroon "
chosen_color_without_whitespaces = "Maroon"
result = run_cli_command(
"service",
"update",
"color-picker",
"foo",
input=f"{chosen_color}\n",
runtime=runtime,
)
# ensure info was written without whitespaces
result = runtime.keychain.get_service("color-picker", "foo")
assert chosen_color != result.color
assert chosen_color_without_whitespaces == result.color


def test_service_update_headless__success():
# Create a new color-picker service type
runtime = CliRuntime(
Expand Down
4 changes: 2 additions & 2 deletions cumulusci/core/config/oauth2_service_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class OAuth2ServiceConfig(ServiceConfig, ABC):
"""Base class for services that require an OAuth2 Client
for establishing a connection."""

@abstractclassmethod
def connect(self) -> Dict:
@abstractclassmethod # type: ignore
def connect(cls) -> Dict: # type: ignore
"""This method is called when the service is first connected
via `cci service connect`. This method should perform the necessary
OAuth flow and return a dict of values that the service would like
Expand Down
Loading

0 comments on commit e7915db

Please sign in to comment.