Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/OWASP/Nest into feature
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh3dev committed Feb 4, 2025
2 parents cfe1690 + 63815c9 commit 1978b89
Show file tree
Hide file tree
Showing 34 changed files with 539 additions and 309 deletions.
13 changes: 7 additions & 6 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ docker:
- 'docker-*.yaml'
- '**/Dockerfile.*'

documentation:
docs:
- changed-files:
- any-glob-to-any-file:
- '**/*.md'
Expand Down Expand Up @@ -67,11 +67,12 @@ nginx:
- 'nginx/**'

schema:
- changed-files:
- any-glob-to-any-file:
- 'schema/**'
- all-globs-to-all-files:
- '!schema/tests/**'
- all:
- changed-files:
- any-glob-to-any-file:
- 'schema/**'
- all-globs-to-all-files:
- '!schema/tests/**'

schema-tests:
- changed-files:
Expand Down
27 changes: 27 additions & 0 deletions backend/apps/github/graphql/nodes/repository.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""GitHub repository GraphQL node."""

import graphene

from apps.common.graphql.nodes import BaseNode
from apps.github.models.repository import Repository


class RepositoryNode(BaseNode):
"""GitHub repository node."""

url = graphene.String()

class Meta:
model = Repository
fields = (
"name",
"forks_count",
"stars_count",
"open_issues_count",
"subscribers_count",
"contributors_count",
)

def resolve_url(self, info):
"""Resolve URL."""
return self.url
5 changes: 5 additions & 0 deletions backend/apps/github/models/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ def top_languages(self):
if v >= LANGUAGE_PERCENTAGE_THRESHOLD and k.lower() not in IGNORED_LANGUAGES
)

@property
def url(self):
"""Return repository URL."""
return f"https://github.com/{self.path}"

def from_github(
self,
gh_repository,
Expand Down
6 changes: 6 additions & 0 deletions backend/apps/owasp/graphql/nodes/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from apps.common.graphql.nodes import BaseNode
from apps.github.graphql.nodes.issue import IssueNode
from apps.github.graphql.nodes.release import ReleaseNode
from apps.github.graphql.nodes.repository import RepositoryNode
from apps.owasp.models.project import Project

RECENT_ISSUES_LIMIT = 10
Expand All @@ -16,6 +17,7 @@ class ProjectNode(BaseNode):

recent_issues = graphene.List(IssueNode)
recent_releases = graphene.List(ReleaseNode)
repositories = graphene.List(RepositoryNode)

class Meta:
model = Project
Expand All @@ -28,3 +30,7 @@ def resolve_recent_issues(self, info):
def resolve_recent_releases(self, info):
"""Resolve project recent releases."""
return self.published_releases.order_by("-published_at")[:RECENT_RELEASES_LIMIT]

def resolve_repositories(self, info):
"""Resolve repositories."""
return self.repositories.order_by("-pushed_at", "-updated_at")
5 changes: 0 additions & 5 deletions backend/apps/slack/common/gsoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@
),
divider(),
markdown(
"We're building with modern frameworks and tools: *TypeScript, React, Chakra UI, "
f"Tailwind CSS, Python, Django, Docker, and Kubernetes*.{2*NL}"
"OWASP Nest has clean and well-documented code, automated CI/CD pipeline, great test "
"coverage for both the frontend and backend making the project reliable and easy "
f"to scale.{2*NL}"
f"Join the effort at <{OWASP_PROJECT_NEST_CHANNEL_ID}|project-nest> and help shape "
"the future :rocket:"
),
Expand Down
14 changes: 7 additions & 7 deletions backend/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions backend/tests/github/graphql/nodes/repository_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Test cases for RepositoryNode."""

from apps.common.graphql.nodes import BaseNode
from apps.github.graphql.nodes.repository import RepositoryNode
from apps.github.models.repository import Repository


class TestRepositoryNode:
"""Test cases for RepositoryNode class."""

def test_repository_node_inheritance(self):
"""Test if RepositoryNode inherits from BaseNode."""
assert issubclass(RepositoryNode, BaseNode)

def test_meta_configuration(self):
"""Test if Meta is properly configured."""
assert RepositoryNode._meta.model == Repository
expected_fields = {
"contributors_count",
"forks_count",
"name",
"open_issues_count",
"stars_count",
"subscribers_count",
"url",
}
assert set(RepositoryNode._meta.fields) == expected_fields

def test_resolve_url_field(self, mocker):
"""Test if URL field is properly defined."""
field = RepositoryNode._meta.fields.get("url")
assert field is not None
assert str(field.type) == "String"
2 changes: 1 addition & 1 deletion backend/tests/owasp/graphql/nodes/project_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_all_fields_exist_in_model(self):
model_fields = {f.name for f in Project._meta.get_fields()}
node_fields = set(ProjectNode._meta.fields.keys())

custom_fields = {"recent_issues", "recent_releases", "nest_url"}
custom_fields = {"recent_issues", "recent_releases", "repositories", "nest_url"}
node_fields = node_fields - custom_fields

assert all(field in model_fields for field in node_fields)
Loading

0 comments on commit 1978b89

Please # to comment.