Skip to content

Commit

Permalink
chore: rename webhooks to event streams
Browse files Browse the repository at this point in the history
Part of the investgigation to see the impact of changing
webhooks to event streams
  • Loading branch information
mkanoor committed Aug 18, 2024
1 parent 1812108 commit 45ae72b
Show file tree
Hide file tree
Showing 44 changed files with 1,830 additions and 1,466 deletions.
2 changes: 1 addition & 1 deletion .gitleaks.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ description = "Global Allowlist"
paths = [
'''tests\/unit\/data''',
'''tools\/docker\/redis-tls''',
'''tests\/integration\/api\/test_webhook.py'''
'''tests\/integration\/api\/test_event_stream_ecdsa.py'''
]
34 changes: 34 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Complete documentation with many more options at:
# https://docs.sonarqube.org/latest/analysis/analysis-parameters/

## The unique project identifier. This is mandatory.
# Do not duplicate or reuse!
# Available characters: [a-zA-Z0-9_:\.\-]
# Must have least one non-digit.
# Recommended format: <group>:<project>
sonar.projectKey=ansible_eda-server

sonar.organization=ansible

# Customize what paths to scan. Default is .
sonar.sources=.

# Verbose name of project displayed in WUI. Default is set to the projectKey. This field is optional.
sonar.projectName=eda-server

# Version of project. This field is optional.
#sonar.projectVersion=1.0

# Tell sonar scanner where coverage files exist
#sonar.python.coverage.reportPaths=coverage.xml

sonar.issue.ignore.multicriteria=e1
# Ignore "should be a variable"
#sonar.issue.ignore.multicriteria.e1.ruleKey=python:S1192
sonar.issue.ignore.multicriteria.e1.resourceKey=**/migrations/**/*

# Only scan with python3
sonar.python.version=3.9,3.10,3.11

# Ignore code dupe for the migrations
sonar.cpd.exclusions=**/migrations/*.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Module providing all webhook authentication types."""
"""Module providing all event stream authentication types."""

import base64
import hashlib
Expand All @@ -37,16 +37,16 @@
DEFAULT_TIMEOUT = 30


class WebhookAuthentication(ABC):
"""Base class for Webhook Authentication."""
class EventStreamAuthentication(ABC):
"""Base class for EventStream Authentication."""

@abstractmethod
def authenticate(self, body: Optional[bytes]):
"""Implement the authenticate maethod with body."""


@dataclass
class HMACAuthentication(WebhookAuthentication):
class HMACAuthentication(EventStreamAuthentication):
"""HMAC Parameters."""

signature: str
Expand Down Expand Up @@ -87,7 +87,7 @@ def authenticate(self, body: bytes):


@dataclass
class TokenAuthentication(WebhookAuthentication):
class TokenAuthentication(EventStreamAuthentication):
"""Token Authentication."""

token: str
Expand All @@ -102,7 +102,7 @@ def authenticate(self, _body=None):


@dataclass
class MTLSAuthentication(WebhookAuthentication):
class MTLSAuthentication(EventStreamAuthentication):
"""mTLS Authentication."""

subject: str
Expand All @@ -117,8 +117,8 @@ def authenticate(self, _body=None):


@dataclass
class BasicAuthentication(WebhookAuthentication):
"""Token Authentication."""
class BasicAuthentication(EventStreamAuthentication):
"""Basic Authentication."""

password: str
username: str
Expand All @@ -139,7 +139,7 @@ def authenticate(self, _body=None):


@dataclass
class Oauth2JwtAuthentication(WebhookAuthentication):
class Oauth2JwtAuthentication(EventStreamAuthentication):
"""OAuth2 JWT Authentication."""

jwks_url: str
Expand Down Expand Up @@ -187,7 +187,7 @@ def authenticate(self, _body=None):


@dataclass
class Oauth2Authentication(WebhookAuthentication):
class Oauth2Authentication(EventStreamAuthentication):
"""OAuth2 Authentication."""

introspection_url: str
Expand Down Expand Up @@ -225,7 +225,7 @@ def authenticate(self, _body=None):


@dataclass
class EcdsaAuthentication(WebhookAuthentication):
class EcdsaAuthentication(EventStreamAuthentication):
"""ECDSA Authentication."""

public_key: str
Expand Down
5 changes: 3 additions & 2 deletions src/aap_eda/api/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ class InvalidWebsocketHost(APIException):
)


class InvalidWebhookSource(APIException):
class InvalidEventStreamSource(APIException):
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
default_detail = (
"Configuration Error: Webhook source could not be updated in ruleset"
"Configuration Error: Event Stream source could not be "
"updated in ruleset"
)
6 changes: 3 additions & 3 deletions src/aap_eda/api/filters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from .credential_type import CredentialTypeFilter
from .decision_environment import DecisionEnvironmentFilter
from .eda_credential import EdaCredentialFilter
from .event_stream import EventStreamFilter
from .organization import OrganizationFilter
from .project import ProjectFilter
from .rulebook import (
Expand All @@ -30,7 +31,6 @@
)
from .team import OrganizationTeamFilter, TeamFilter
from .user import UserFilter
from .webhook import WebhookFilter

__all__ = (
# project
Expand All @@ -56,6 +56,6 @@
# team
"TeamFilter",
"OrganizationTeamFilter",
# Webhook
"WebhookFilter",
# EventStream
"EventStreamFilter",
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
from aap_eda.core import models


class WebhookFilter(django_filters.FilterSet):
class EventStreamFilter(django_filters.FilterSet):
name = django_filters.CharFilter(
field_name="name",
lookup_expr="istartswith",
label="Filter by webhook name.",
label="Filter by event stream name.",
)

class Meta:
model = models.Webhook
model = models.EventStream
fields = ["name"]
8 changes: 4 additions & 4 deletions src/aap_eda/api/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
EdaCredentialCreateSerializer,
EdaCredentialSerializer,
)
from .event_stream import EventStreamInSerializer, EventStreamOutSerializer
from .organization import (
OrganizationCreateSerializer,
OrganizationRefSerializer,
Expand Down Expand Up @@ -75,7 +76,6 @@
UserListSerializer,
UserSerializer,
)
from .webhook import WebhookInSerializer, WebhookOutSerializer

__all__ = (
# auth
Expand Down Expand Up @@ -129,7 +129,7 @@
"TeamCreateSerializer",
"TeamUpdateSerializer",
"TeamDetailSerializer",
# webhooks
"WebhookInSerializer",
"WebhookOutSerializer",
# event streams
"EventStreamInSerializer",
"EventStreamOutSerializer",
)
Loading

0 comments on commit 45ae72b

Please sign in to comment.