forked from OWASP/Nest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
365 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://raw.githubusercontent.com/OWASP/Nest/main/schema/chapter.json", | ||
"$defs": { | ||
"leader": { | ||
"type": "object", | ||
"title": "Leader", | ||
"description": "A chapter leader.", | ||
"required": ["github"], | ||
"properties": { | ||
"email": { | ||
"description": "The leader's email address.", | ||
"format": "email", | ||
"type": ["string", "null"] | ||
}, | ||
"github": { | ||
"type": "string", | ||
"description": "The GitHub username.", | ||
"pattern": "^[a-zA-Z0-9-]{1,39}$" | ||
}, | ||
"name": { | ||
"type": ["string", "null"], | ||
"description": "Leader's name." | ||
}, | ||
"slack": { | ||
"type": ["string", "null"], | ||
"description": "The Slack username.", | ||
"pattern": "^[a-zA-Z0-9._-]{1,21}$" | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"sponsor": { | ||
"type": "object", | ||
"title": "Sponsor", | ||
"description": "A chapter sponsor.", | ||
"required": [ | ||
"name", | ||
"url" | ||
], | ||
"properties": { | ||
"description": { | ||
"type": "string", | ||
"description": "A brief description of the sponsor." | ||
}, | ||
"logo": { | ||
"type": "string", | ||
"description": "The URL of the sponsor's logo.", | ||
"format": "uri" | ||
}, | ||
"name": { | ||
"type": "string", | ||
"description": "The name of the sponsor or organization." | ||
}, | ||
"url": { | ||
"type": "string", | ||
"description": "The URL of the sponsor.", | ||
"format": "uri" | ||
} | ||
}, | ||
"additionalProperties": false | ||
} | ||
}, | ||
|
||
"additionalProperties": false, | ||
"description": "OWASP chapter schema.", | ||
"properties": { | ||
"blog": { | ||
"description": "Chapter's blog.", | ||
"format": "uri", | ||
"type": ["string"] | ||
}, | ||
"country": { | ||
"description": "Country.", | ||
"type": "string" | ||
}, | ||
"events": { | ||
"description": "Event URLs related to the chapter.", | ||
"type": "array", | ||
"items": { | ||
"format": "uri", | ||
"type": "string" | ||
}, | ||
"minItems": 1, | ||
"uniqueItems": true | ||
}, | ||
"leaders": { | ||
"description": "Leaders of the chapter.", | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/$defs/leader" | ||
}, | ||
"minItems": 2, | ||
"uniqueItems": true | ||
}, | ||
"meetup-group": { | ||
"description": "Meetup group.", | ||
"type": "string" | ||
}, | ||
"name": { | ||
"description": "The unique name of the chapter.", | ||
"minLength": 10, | ||
"type": "string" | ||
}, | ||
"region": { | ||
"description": "Region.", | ||
"type": "string" | ||
}, | ||
"sponsors": { | ||
"description": "Sponsors of the chapter.", | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/$defs/sponsor" | ||
}, | ||
"minItems": 1 | ||
}, | ||
"tags": { | ||
"description": "Tags for the chapter", | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
}, | ||
"minItems": 3, | ||
"uniqueItems": true | ||
}, | ||
"website": { | ||
"description": "The official website of the chapter.", | ||
"type": "string", | ||
"format": "url" | ||
} | ||
}, | ||
"required": [ | ||
"country", | ||
"leaders", | ||
"name", | ||
"tags" | ||
], | ||
"title": "OWASP Chapter", | ||
"type": "object" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
import yaml | ||
from utils.validators import validate_data | ||
|
||
from tests.conftest import tests_data_dir | ||
|
||
|
||
def test_positive(chapter_schema): | ||
for file_path in Path(tests_data_dir / "chapter/positive").rglob("*.yaml"): | ||
assert ( | ||
validate_data( | ||
chapter_schema, | ||
yaml.safe_load( | ||
file_path.read_text(), | ||
), | ||
) | ||
is None | ||
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("file_path", "error_message"), | ||
[ | ||
("blog-none.yaml", "None is not of type 'string'"), | ||
("events-empty.yaml", "[] should be non-empty"), | ||
( | ||
"events-non-unique-urls.yaml", | ||
"['https://example.com/event1', 'https://example.com/event1'] has non-unique elements", | ||
), | ||
( | ||
"leader-email-empty.yaml", | ||
"[{'email': '', 'github': 'leader-1-github', 'name': 'Leader 1 Name'}] is too short", | ||
), | ||
( | ||
"leader-email-missing.yaml", | ||
"[{'email': None, 'github': 'leader-1-github', 'name': 'Leader 1 Name'}] is too short", | ||
), | ||
("name-empty.yaml", "'' is too short"), | ||
("name-none.yaml", "None is not of type 'string'"), | ||
("sponsors-empty-list.yaml", "[] should be non-empty"), | ||
("sponsors-name-missing.yaml", "'name' is a required property"), | ||
("sponsors-url-missing.yaml", "'url' is a required property"), | ||
("website-none.yaml", "None is not of type 'string'"), | ||
], | ||
) | ||
def test_negative(chapter_schema, file_path, error_message): | ||
assert ( | ||
validate_data( | ||
chapter_schema, | ||
yaml.safe_load( | ||
Path(tests_data_dir / "chapter/negative" / file_path).read_text(), | ||
), | ||
) | ||
== error_message | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
blog: | ||
country: India | ||
leaders: | ||
- github: leader-1-github | ||
name: Leader 1 Name | ||
- github: leader-2-github | ||
name: Leader 2 Name | ||
name: OWASP Chapter | ||
tags: | ||
- example-tag-1 | ||
- example-tag-2 | ||
- example-tag-3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
country: India | ||
leaders: | ||
- github: leader-1-github | ||
name: Leader 1 Name | ||
- github: leader-2-github | ||
name: Leader 2 Name | ||
slack: leader-2-slack | ||
name: OWASP Chapter | ||
tags: | ||
- example-tag-1 | ||
- example-tag-2 | ||
- example-tag-3 | ||
events: [] |
15 changes: 15 additions & 0 deletions
15
schema/tests/data/chapter/negative/events-non-unique-urls.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
country: India | ||
leaders: | ||
- github: leader-1-github | ||
name: Leader 1 Name | ||
- github: leader-2-github | ||
name: Leader 2 Name | ||
slack: leader-2-slack | ||
name: OWASP Chapter | ||
tags: | ||
- example-tag-1 | ||
- example-tag-2 | ||
- example-tag-3 | ||
events: | ||
- https://example.com/event1 | ||
- https://example.com/event1 |
10 changes: 10 additions & 0 deletions
10
schema/tests/data/chapter/negative/leader-email-empty.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
country: India | ||
leaders: | ||
- email: '' | ||
github: leader-1-github | ||
name: Leader 1 Name | ||
name: OWASP Chapter | ||
tags: | ||
- example-tag-1 | ||
- example-tag-2 | ||
- example-tag-3 |
10 changes: 10 additions & 0 deletions
10
schema/tests/data/chapter/negative/leader-email-missing.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
country: India | ||
leaders: | ||
- email: | ||
github: leader-1-github | ||
name: Leader 1 Name | ||
name: OWASP Chapter | ||
tags: | ||
- example-tag-1 | ||
- example-tag-2 | ||
- example-tag-3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
country: India | ||
leaders: | ||
- github: leader-name-1 | ||
name: Leader Name 1 | ||
- github: leader-name-2 | ||
name: Leader Name 2 | ||
name: '' | ||
tags: | ||
- example-tag-1 | ||
- example-tag-2 | ||
- example-tag-3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
country: India | ||
leaders: | ||
- github: leader-name-1 | ||
name: Leader Name 1 | ||
- github: leader-name-2 | ||
name: Leader Name 2 | ||
name: | ||
tags: | ||
- example-tag-1 | ||
- example-tag-2 | ||
- example-tag-3 |
12 changes: 12 additions & 0 deletions
12
schema/tests/data/chapter/negative/sponsors-empty-list.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
country: India | ||
leaders: | ||
- github: leader-1-github | ||
name: Leader 1 Name | ||
- github: leader-2-github | ||
name: Leader 2 Name | ||
name: OWASP Chapter | ||
tags: | ||
- example-tag-1 | ||
- example-tag-2 | ||
- example-tag-3 | ||
sponsors: [] |
15 changes: 15 additions & 0 deletions
15
schema/tests/data/chapter/negative/sponsors-name-missing.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
country: India | ||
leaders: | ||
- github: leader-name-1 | ||
name: Leader Name 1 | ||
- github: leader-name-2 | ||
name: Leader Name 2 | ||
name: OWASP Chapter | ||
tags: | ||
- example-tag-1 | ||
- example-tag-2 | ||
- example-tag-3 | ||
sponsors: | ||
- description: A great sponsor | ||
logo: https://sponsor1.com/logo.png | ||
url: https://sponsor1.com |
15 changes: 15 additions & 0 deletions
15
schema/tests/data/chapter/negative/sponsors-url-missing.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
country: India | ||
leaders: | ||
- github: leader-1-github | ||
name: Leader 1 Name | ||
- github: leader-2-github | ||
name: Leader 2 Name | ||
name: OWASP Chapter | ||
tags: | ||
- example-tag-1 | ||
- example-tag-2 | ||
- example-tag-3 | ||
sponsors: | ||
- description: A great sponsor | ||
logo: https://sponsor1.com/logo.png | ||
name: Sponsor 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
country: India | ||
leaders: | ||
- github: leader-1-github | ||
name: Leader 1 Name | ||
name: OWASP Chapter | ||
tags: | ||
- example-tag-1 | ||
website: |
17 changes: 17 additions & 0 deletions
17
schema/tests/data/chapter/positive/optional-properties.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
blog: https://blog.chapter.com | ||
country: India | ||
events: | ||
- https://example.com/event1 | ||
- https://example.com/event2 | ||
leaders: | ||
- github: leader-1-github | ||
name: Leader 1 Name | ||
- github: leader-2-github | ||
name: Leader 2 Name | ||
slack: leader-2-slack | ||
name: OWASP Chapter | ||
tags: | ||
- example-tag-1 | ||
- example-tag-2 | ||
- example-tag-3 | ||
website: https://chapter-website.com |
12 changes: 12 additions & 0 deletions
12
schema/tests/data/chapter/positive/required-properties.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
country: India | ||
leaders: | ||
- github: leader-1-github | ||
name: Leader 1 Name | ||
- github: leader-2-github | ||
name: Leader 2 Name | ||
slack: leader-2-slack | ||
name: OWASP Chapter | ||
tags: | ||
- chapter-tag-1 | ||
- chapter-tag-2 | ||
- chapter-tag-3 |