예제 #1
0
def main():
    project_name = os.environ["cxProject"]
    team_name = os.environ["cxTeam"]
    platform_tag = os.environ["cxPlatformTag"]

    project_api = ProjectsAPI()
    project_id = project_api.get_project_id_by_project_name_and_team_full_name(
        project_name, team_name
    )
    if not project_id:
        sys.exit(
            f"Your project {project_name} with team name {team_name} does not exist in checkmarx"
        )

    if not check_valid_platform_tag(platform_tag):
        sys.exit(f"You're platform tag {platform_tag} doesn't exist in cloudgov")

    # Get all the project details to update the project along with the new custom field
    project_details = project_api.get_project_details_by_id(project_id)
    # Get a custom field object to update project with.
    # In the object we set the custom_field_id to 1 to let it know we are referring to platform_tag
    # And we set the name to the platform_tag name we want to give it
    custom_fields = [CxCustomField.CxCustomField(custom_field_id=1, name=platform_tag)]
    # Update the project with the project attributes and platform tag custom_field
    project_api.update_project_by_id(
        project_id=project_details.project_id,
        project_name=project_details.name,
        team_id=project_details.team_id,
        custom_fields=custom_fields[0],
    )
예제 #2
0
def test_update_project_by_id():
    projects_api = ProjectsAPI()
    project_name = "test1"
    project_id = projects_api.get_project_id_by_project_name_and_team_full_name(
        project_name)

    branched_project_name = "test_update"
    projects_api.delete_project_if_exists_by_project_name_and_team_full_name(
        branched_project_name)
    team_id = TeamAPI().get_team_id_by_team_full_name()
    result = projects_api.update_project_by_id(
        project_id, project_name=branched_project_name, team_id=team_id)
    assert result is True