-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change port bind and add a unittest (#10208)
- Loading branch information
1 parent
eb71ad9
commit 0c08d7a
Showing
4 changed files
with
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Security | ||
body: Explicitly bind to localhost in docs serve | ||
time: 2024-05-22T09:45:40.748185-04:00 | ||
custom: | ||
Author: ChenyuLInx michelleark | ||
Issue: "10209" |
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
Empty file.
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,23 @@ | ||
from http.server import SimpleHTTPRequestHandler | ||
from unittest.mock import MagicMock, patch | ||
|
||
import pytest | ||
|
||
from dbt.task.docs.serve import ServeTask | ||
|
||
|
||
@pytest.fixture | ||
def serve_task(): | ||
# Set up | ||
task = ServeTask(config=MagicMock(), args=MagicMock()) | ||
task.config.project_target_path = "." | ||
task.args.port = 8000 | ||
return task | ||
|
||
|
||
def test_serve_bind_to_127(serve_task): | ||
serve_task.args.browser = False | ||
with patch("dbt.task.docs.serve.socketserver.TCPServer") as patched_TCPServer: | ||
patched_TCPServer.return_value = MagicMock() | ||
serve_task.run() | ||
patched_TCPServer.assert_called_once_with(("127.0.0.1", 8000), SimpleHTTPRequestHandler) |