Skip to content

Commit

Permalink
feat(odbc): add username and password auth
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveitaly committed Feb 27, 2024
1 parent 58a9488 commit e01f601
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
15 changes: 13 additions & 2 deletions netsuite/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from .constants import DEFAULT_INI_PATH, DEFAULT_INI_SECTION

__all__ = ("Config", "TokenAuth")
__all__ = ("Config", "TokenAuth", "UsernamePasswordAuth")


class TokenAuth(BaseModel):
Expand All @@ -16,9 +16,20 @@ class TokenAuth(BaseModel):
token_secret: str


class UsernamePasswordAuth(BaseModel):
"""
This is a very old authentication method that is not recommended for use.
However, it's the only way to access the netsuite.com (NOT netsuite2.com) data source via ODBC.
"""

username: str
password: str


class Config(BaseModel):
account: str
auth: TokenAuth
auth: TokenAuth | UsernamePasswordAuth

log_level: t.Optional[str] = None

Expand Down
8 changes: 7 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pytest

from netsuite import Config


Expand All @@ -14,3 +13,10 @@ def dummy_config():
"token_secret": "abcdefghijklmnopqrstuvwxyz0123456789",
},
)


@pytest.fixture
def dummy_username_password_config():
return Config(
account="123456_SB1", auth={"username": "username", "password": "password"}
)
4 changes: 4 additions & 0 deletions tests/test_odbc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# TODO need more expanded tests here
def test_expected_hostname(dummy_username_password_config):
config = dummy_username_password_config
assert config.auth.username == "username"

0 comments on commit e01f601

Please sign in to comment.