Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release automation #193

Merged
merged 24 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/tests/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "sadlc-testing"
description = "Testing scripts for SOAR playbooks"
authors = [{ name = "Eric Li", email = "[email protected]" }]
requires-python = ">=3.10"
readme = "README.md"
dependencies = [
"black",
"isort",
"robotframework",
"robotframework-tidy",
"paramiko",
"mistletoe",
"beautifulsoup4",
"lxml"
]

dynamic = ["version", ]

[project.urls]
repository = "https://cd.splunkdev.com/sgs-soar/sadlc-testing"

[project.optional-dependencies]
dev = [
"pip-tools"
]

[tool.setuptools]
py-modules = []

[tool.black]
line-length = "120"
extend-exclude = "repos|(.*/)?test/data/|robot/data/"

[tool.isort]
line_length = "120"
profile = "black"
extend_skip_glob = ["repos/*", "test/data/*", "*/test/data/*", "robot/data/*"]
141 changes: 141 additions & 0 deletions .github/tests/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --extra=dev --no-emit-index-url --output-file=requirements-dev.txt
#
annotated-types==0.7.0
# via pydantic
anyio==4.4.0
# via httpx
bcrypt==4.2.0
# via paramiko
beautifulsoup4==4.12.3
# via sadlc-testing (pyproject.toml)
black==24.4.2
# via
# sadlc-testing (pyproject.toml)
# splunk-soar-sdk
build==1.2.1
# via pip-tools
certifi==2024.7.4
# via
# httpcore
# httpx
# requests
cffi==1.16.0
# via
# cryptography
# pynacl
charset-normalizer==3.3.2
# via requests
click==8.1.7
# via
# black
# pip-tools
# rich-click
# robotframework-tidy
colorama==0.4.6
# via robotframework-tidy
cryptography==43.0.0
# via paramiko
h11==0.14.0
# via httpcore
httpcore==1.0.5
# via httpx
httpx==0.27.0
# via splunk-soar-sdk
hvac==2.3.0
# via splunk-soar-sdk
idna==3.7
# via
# anyio
# httpx
# requests
isort==5.13.2
# via
# sadlc-testing (pyproject.toml)
# splunk-soar-sdk
jinja2==3.1.4
# via robotframework-tidy
lxml==5.2.2
# via sadlc-testing (pyproject.toml)
markdown-it-py==3.0.0
# via rich
markupsafe==2.1.5
# via jinja2
mdurl==0.1.2
# via markdown-it-py
mistletoe==1.4.0
# via sadlc-testing (pyproject.toml)
mypy-extensions==1.0.0
# via black
packaging==24.1
# via
# black
# build
paramiko==3.4.0
# via sadlc-testing (pyproject.toml)
pathspec==0.12.1
# via
# black
# robotframework-tidy
pip-tools==7.4.1
# via sadlc-testing (pyproject.toml)
platformdirs==4.2.2
# via black
pycparser==2.22
# via cffi
pydantic==2.8.2
# via splunk-soar-sdk
pydantic-core==2.20.1
# via pydantic
pygments==2.18.0
# via
# rich
# splunk-soar-sdk
pynacl==1.5.0
# via paramiko
pyproject-hooks==1.1.0
# via
# build
# pip-tools
pytz==2024.1
# via splunk-soar-sdk
requests==2.32.3
# via hvac
rich==13.7.1
# via rich-click
rich-click==1.7.3
# via robotframework-tidy
robotframework==7.0.1
# via
# robotframework-tidy
# sadlc-testing (pyproject.toml)
robotframework-tidy==4.13.0
# via sadlc-testing (pyproject.toml)
sniffio==1.3.1
# via
# anyio
# httpx
soupsieve==2.5
# via beautifulsoup4
splunk-soar-sdk @ git+ssh://[email protected]/sgs-soar/splunk-soar-sdk.git@open-source
# via sadlc-testing (pyproject.toml)
toml==0.10.2
# via splunk-soar-sdk
tomli==2.0.1
# via robotframework-tidy
typing-extensions==4.12.2
# via
# pydantic
# pydantic-core
# rich-click
urllib3==2.2.2
# via requests
wheel==0.43.0
# via pip-tools

# The following packages are considered to be unsafe in a requirements file:
# pip
# setuptools
122 changes: 122 additions & 0 deletions .github/tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --no-emit-index-url
#
annotated-types==0.7.0
# via pydantic
anyio==4.4.0
# via httpx
bcrypt==4.2.0
# via paramiko
beautifulsoup4==4.12.3
# via sadlc-testing (pyproject.toml)
black==24.4.2
# via
# sadlc-testing (pyproject.toml)
#
certifi==2024.7.4
# via
# httpcore
# httpx
# requests
cffi==1.16.0
# via
# cryptography
# pynacl
charset-normalizer==3.3.2
# via requests
click==8.1.7
# via
# black
# rich-click
# robotframework-tidy
colorama==0.4.6
# via robotframework-tidy
cryptography==43.0.0
# via paramiko
h11==0.14.0
# via httpcore
httpcore==1.0.5
# via httpx
httpx==0.27.0
# via
hvac==2.3.0
# via
idna==3.7
# via
# anyio
# httpx
# requests
isort==5.13.2
# via
# sadlc-testing (pyproject.toml)
#
jinja2==3.1.4
# via robotframework-tidy
lxml==5.2.2
# via sadlc-testing (pyproject.toml)
markdown-it-py==3.0.0
# via rich
markupsafe==2.1.5
# via jinja2
mdurl==0.1.2
# via markdown-it-py
mistletoe==1.4.0
# via sadlc-testing (pyproject.toml)
mypy-extensions==1.0.0
# via black
packaging==24.1
# via black
paramiko==3.4.0
# via sadlc-testing (pyproject.toml)
pathspec==0.12.1
# via
# black
# robotframework-tidy
platformdirs==4.2.2
# via black
pycparser==2.22
# via cffi
pydantic==2.8.2
# via
pydantic-core==2.20.1
# via pydantic
pygments==2.18.0
# via
# rich
#
pynacl==1.5.0
# via paramiko
pytz==2024.1
# via
requests==2.32.3
# via hvac
rich==13.7.1
# via rich-click
rich-click==1.7.3
# via robotframework-tidy
robotframework==7.0.1
# via
# robotframework-tidy
# sadlc-testing (pyproject.toml)
robotframework-tidy==4.13.0
# via sadlc-testing (pyproject.toml)
sniffio==1.3.1
# via
# anyio
# httpx
soupsieve==2.5
# via beautifulsoup4
toml==0.10.2
# via
tomli==2.0.1
# via robotframework-tidy
typing-extensions==4.12.2
# via
# pydantic
# pydantic-core
# rich-click
urllib3==2.2.2
# via requests
71 changes: 71 additions & 0 deletions .github/tests/robot/DynamicTestCases.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"""Supports dynamically adding a test case during robot framework execution.

Adapted from https://stackoverflow.com/a/77484465 .
"""

# While this import does not seem necessary, it was useful in the python console.
from robot.running.model import Keyword, TestCase, TestSuite


class DynamicTestCases(object):
ROBOT_LISTENER_API_VERSION = 3
ROBOT_LIBRARY_SCOPE = "TEST SUITE"

def __init__(self):
self.ROBOT_LIBRARY_LISTENER = self
self._current_suite = None

def _start_suite(self, suite, result):
# Don't change the name of this method.
# save current suite so that we can modify it later
self._current_suite = suite

def dynamic_test_cases_create(self, name, *tags):
"""Adds a test case to the current suite.

Args:
name: is the test case name
tags: is a list of tags to add to the test case

Returns: The test case that was added
"""
test_case = self._current_suite.tests.create(name=name, tags=tags)
return test_case

def dynamic_test_cases_set_body(self, test_case: TestCase, keyword_name: str, *args) -> Keyword:
"""Sets the body keyword of the given test case.

Args:
test_case: The test case to add the keyword to.
keyword_name: The name of the keyword to add.
args: The arguments to pass to the keyword. Currently only support
positional arguments.
"""
keyword = test_case.body.create_keyword(name=keyword_name, args=args)
return keyword

def dynamic_test_cases_set_setup(self, test_case: TestCase, keyword_name: str, *args) -> Keyword:
"""Sets the setup keyword of the given test case.

Args:
test_case: The test case to add the keyword to.
keyword_name: The name of the keyword to add.
args: The arguments to pass to the keyword. Currently only support
positional arguments.
"""
keyword = test_case.body.create_keyword(name=keyword_name, args=args, type="setup")
test_case.setup = keyword
return keyword

def dynamic_test_cases_set_teardown(self, test_case: TestCase, keyword_name: str, *args) -> Keyword:
"""Sets the teardown keyword of the given test case.

Args:
test_case: The test case to add the keyword to.
keyword_name: The name of the keyword to add.
args: The arguments to pass to the keyword. Currently only support
positional arguments.
"""
keyword = test_case.body.create_keyword(name=keyword_name, args=args, type="teardown")
test_case.teardown = keyword
return keyword
Loading
Loading