fix(version): update version flag logic (#4771)

Co-authored-by: Sergio Garcia <38561120+sergargar@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2024-08-16 12:44:28 -04:00
committed by GitHub
parent d5d4b7fc1d
commit cdf063a35d
2 changed files with 15 additions and 1 deletions
+2 -1
View File
@@ -5,6 +5,7 @@ from os import getcwd
import requests
import yaml
from packaging import version
from prowler.lib.logger import logger
@@ -86,7 +87,7 @@ def check_current_version():
"https://api.github.com/repos/prowler-cloud/prowler/tags", timeout=1
)
latest_version = release_response.json()[0]["name"]
if latest_version != prowler_version:
if version.parse(latest_version) > version.parse(prowler_version):
return f"{prowler_version_string} (latest is {latest_version}, upgrade for the latest features)"
else:
return (
+13
View File
@@ -15,6 +15,7 @@ from prowler.providers.aws.aws_provider import get_aws_available_regions
MOCK_PROWLER_VERSION = "3.3.0"
MOCK_OLD_PROWLER_VERSION = "0.0.0"
MOCK_PROWLER_MASTER_VERSION = "3.4.0"
def mock_prowler_get_latest_release(_, **kwargs):
@@ -326,6 +327,18 @@ class Test_Config:
== f"Prowler {MOCK_OLD_PROWLER_VERSION} (latest is {MOCK_PROWLER_VERSION}, upgrade for the latest features)"
)
@mock.patch(
"prowler.config.config.requests.get", new=mock_prowler_get_latest_release
)
@mock.patch(
"prowler.config.config.prowler_version", new=MOCK_PROWLER_MASTER_VERSION
)
def test_check_current_version_with_master_version(self):
assert (
check_current_version()
== f"Prowler {MOCK_PROWLER_MASTER_VERSION} (You are running the latest version, yay!)"
)
def test_get_available_compliance_frameworks(self):
compliance_frameworks = [
"cisa_aws",