Capture ThinkStorm project: codebase state, workflows, and access control policies
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
"""
|
||||
URL Extraction & VirusTotal Safety Rule Tests
|
||||
PRD Section 14, 15:
|
||||
- Any VirusTotal malicious detection (malicious > 0) blocks automation and quarantines idea.
|
||||
- Safe URLs are approved.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import asyncio
|
||||
from thinkstorm.processors.pipeline import process_url_safety, URL_REGEX
|
||||
from thinkstorm.models import URLSafetyState, AutomationPolicy
|
||||
from thinkstorm.database import init_db
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_url_extraction():
|
||||
text = "Check out this repo https://github.com/thinkstorm/core and also http://test.com/docs for details."
|
||||
urls = URL_REGEX.findall(text)
|
||||
assert len(urls) == 2
|
||||
assert "https://github.com/thinkstorm/core" in urls
|
||||
assert "http://test.com/docs" in urls
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_safe_url_safety_check():
|
||||
init_db()
|
||||
idea_id = "TS-9901"
|
||||
now = "2026-08-19T09:00:00Z"
|
||||
from thinkstorm.database import get_db
|
||||
with get_db() as conn:
|
||||
conn.execute("INSERT OR IGNORE INTO ideas (id, original_text, submitted_at, created_at, updated_at) VALUES (?, ?, ?, ?, ?)", (idea_id, "text", now, now, now))
|
||||
|
||||
text = "Great idea with safe link https://example.com/project"
|
||||
url_records, quarantine_needed = await process_url_safety(idea_id, text)
|
||||
|
||||
assert len(url_records) == 1
|
||||
assert quarantine_needed is False
|
||||
assert url_records[0].safety_state == URLSafetyState.SAFE
|
||||
assert url_records[0].automation_policy == AutomationPolicy.APPROVED
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_malicious_url_safety_check_blocks_and_quarantines():
|
||||
init_db()
|
||||
idea_id = "TS-9902"
|
||||
now = "2026-08-19T09:00:00Z"
|
||||
from thinkstorm.database import get_db
|
||||
with get_db() as conn:
|
||||
conn.execute("INSERT OR IGNORE INTO ideas (id, original_text, submitted_at, created_at, updated_at) VALUES (?, ?, ?, ?, ?)", (idea_id, "text", now, now, now))
|
||||
|
||||
text = "Suspicious submission with bad link https://malicious-site.testmalicious/payload"
|
||||
url_records, quarantine_needed = await process_url_safety(idea_id, text)
|
||||
|
||||
assert len(url_records) == 1
|
||||
assert quarantine_needed is True
|
||||
assert url_records[0].safety_state == URLSafetyState.MALICIOUS
|
||||
assert url_records[0].automation_policy == AutomationPolicy.BLOCKED
|
||||
assert url_records[0].admin_review_required is True
|
||||
Reference in New Issue
Block a user