mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-10-01 10:15:04 -04:00
1 parent
c1141fc9a8
commit
d5d1684ef9
12 files changed
+38
-80
No files matched your search
@@ -3,8 +3,8 @@ name: 🧪 Manual Test Suite Selector
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
run_authoritative:
|
||||
description: '📂 authoritative_fields/ (Logic, Locks, IPs)'
|
||||
run_scan:
|
||||
description: '📂 scan/ (Scan, Logic, Locks, IPs)'
|
||||
type: boolean
|
||||
default: true
|
||||
run_api:
|
||||
@@ -43,7 +43,7 @@ jobs:
|
||||
run: |
|
||||
PATHS=""
|
||||
# Folder Mapping with 'test/' prefix
|
||||
if [ "${{ github.event.inputs.run_authoritative }}" == "true" ]; then PATHS="$PATHS test/authoritative_fields/"; fi
|
||||
if [ "${{ github.event.inputs.scan }}" == "true" ]; then PATHS="$PATHS test/scan/"; fi
|
||||
if [ "${{ github.event.inputs.run_api }}" == "true" ]; then PATHS="$PATHS test/api_endpoints/ test/server/"; fi
|
||||
if [ "${{ github.event.inputs.run_backend }}" == "true" ]; then PATHS="$PATHS test/backend/"; fi
|
||||
if [ "${{ github.event.inputs.run_docker_env }}" == "true" ]; then PATHS="$PATHS test/docker_tests/"; fi
|
||||
|
||||
File renamed without changes.
@@ -81,6 +81,41 @@ def scan_db():
|
||||
)
|
||||
""")
|
||||
|
||||
# 3. Events Table
|
||||
cur.execute("""
|
||||
CREATE TABLE Events (
|
||||
eve_MAC TEXT,
|
||||
eve_IP TEXT,
|
||||
eve_DateTime TEXT,
|
||||
eve_EventType TEXT,
|
||||
eve_AdditionalInfo TEXT,
|
||||
eve_PendingAlertEmail INTEGER
|
||||
)
|
||||
""")
|
||||
|
||||
# 4. LatestEventsPerMAC View
|
||||
cur.execute("""DROP VIEW IF EXISTS LatestEventsPerMAC;""")
|
||||
cur.execute("""
|
||||
CREATE VIEW LatestEventsPerMAC AS
|
||||
WITH RankedEvents AS (
|
||||
SELECT
|
||||
e.*,
|
||||
ROW_NUMBER() OVER (PARTITION BY e.eve_MAC ORDER BY e.eve_DateTime DESC) AS row_num
|
||||
FROM Events AS e
|
||||
)
|
||||
SELECT
|
||||
e.eve_MAC,
|
||||
e.eve_EventType,
|
||||
e.eve_DateTime,
|
||||
e.eve_PendingAlertEmail,
|
||||
d.devPresentLastScan,
|
||||
c.scanLastIP
|
||||
FROM RankedEvents AS e
|
||||
LEFT JOIN Devices AS d ON e.eve_MAC = d.devMac
|
||||
LEFT JOIN CurrentScan AS c ON e.eve_MAC = c.scanMac
|
||||
WHERE e.row_num = 1;
|
||||
""")
|
||||
|
||||
# 3. LatestDeviceScan View (Inner Join for Online Devices)
|
||||
cur.execute("""
|
||||
CREATE VIEW LatestDeviceScan AS
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,86 +1,9 @@
|
||||
import sqlite3
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from scan.session_events import process_scan
|
||||
|
||||
@pytest.fixture
|
||||
def scan_db():
|
||||
conn = sqlite3.connect(":memory:")
|
||||
conn.row_factory = sqlite3.Row
|
||||
cur = conn.cursor()
|
||||
|
||||
# Devices
|
||||
cur.execute("""
|
||||
CREATE TABLE Devices (
|
||||
devMac TEXT PRIMARY KEY,
|
||||
devLastIP TEXT,
|
||||
devPresentLastScan INTEGER,
|
||||
devAlertDown INTEGER,
|
||||
devAlertEvents INTEGER,
|
||||
devIsArchived INTEGER DEFAULT 0
|
||||
)
|
||||
""")
|
||||
|
||||
# Current scan
|
||||
cur.execute("""
|
||||
CREATE TABLE CurrentScan (
|
||||
scanMac TEXT,
|
||||
scanLastIP TEXT
|
||||
)
|
||||
""")
|
||||
|
||||
# Events
|
||||
cur.execute("""
|
||||
CREATE TABLE Events (
|
||||
eve_MAC TEXT,
|
||||
eve_IP TEXT,
|
||||
eve_DateTime TEXT,
|
||||
eve_EventType TEXT,
|
||||
eve_AdditionalInfo TEXT,
|
||||
eve_PendingAlertEmail INTEGER
|
||||
)
|
||||
""")
|
||||
|
||||
# LatestEventsPerMAC view
|
||||
cur.execute("""DROP VIEW IF EXISTS LatestEventsPerMAC;""")
|
||||
cur.execute("""
|
||||
CREATE VIEW LatestEventsPerMAC AS
|
||||
WITH RankedEvents AS (
|
||||
SELECT
|
||||
e.*,
|
||||
ROW_NUMBER() OVER (PARTITION BY e.eve_MAC ORDER BY e.eve_DateTime DESC) AS row_num
|
||||
FROM Events AS e
|
||||
)
|
||||
SELECT
|
||||
e.eve_MAC,
|
||||
e.eve_EventType,
|
||||
e.eve_DateTime,
|
||||
e.eve_PendingAlertEmail,
|
||||
d.devPresentLastScan,
|
||||
c.scanLastIP
|
||||
FROM RankedEvents AS e
|
||||
LEFT JOIN Devices AS d ON e.eve_MAC = d.devMac
|
||||
LEFT JOIN CurrentScan AS c ON e.eve_MAC = c.scanMac
|
||||
WHERE e.row_num = 1;
|
||||
""")
|
||||
|
||||
conn.commit()
|
||||
|
||||
db = Mock()
|
||||
db.sql_connection = conn
|
||||
db.sql = cur
|
||||
db.commitDB = conn.commit
|
||||
|
||||
def read(query):
|
||||
return [dict(cur.execute(query).fetchone())]
|
||||
|
||||
db.read = read
|
||||
|
||||
yield db
|
||||
conn.close()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def minimal_patches():
|
||||
Reference in new issue
Block a user