Skip to content
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
26dd394
feat(cache): initial
buschNT Feb 14, 2022
def647a
feat(cache): basic user cache
buschNT Feb 17, 2022
5dbb1ca
feat(cache): XXX_list functions from cache
buschNT Feb 18, 2022
84200e3
fix: test + remove graphgl queries
buschNT Feb 22, 2022
39c4807
fix: refresh + timestamp + more
buschNT Feb 22, 2022
098d5c1
feat(cache): initial
buschNT Feb 14, 2022
eb0db3f
feat(cache): basic user cache
buschNT Feb 17, 2022
77662c1
feat(cache): XXX_list functions from cache
buschNT Feb 18, 2022
e48116d
fix: test + remove graphgl queries
buschNT Feb 22, 2022
b03ca93
fix: refresh + timestamp + more
buschNT Feb 22, 2022
9ab36b1
Merge branch 'feature/cache'
buschNT Feb 25, 2022
17fd139
fix(cache): rebase
buschNT Feb 25, 2022
d6402eb
fix(cache): tests
buschNT Feb 25, 2022
963bb08
fix(cache): sonarcloud
buschNT Feb 25, 2022
95caae6
fix: remove unused files
buschNT Feb 28, 2022
7bb279e
refactor: cluster
buschNT Mar 2, 2022
9b0905a
feat: bridge abstraction + more
buschNT Mar 4, 2022
c2f83c5
feat: add gefyra up + down
buschNT Mar 7, 2022
a0b0c28
feat(gefyra): integration
buschNT Mar 10, 2022
faae5ea
fix(tele): telepresence reintegration + fixes
buschNT Mar 11, 2022
f9aa0e5
feature(listprompt): add updateable list prompt
SteinRobert Mar 11, 2022
477e292
fix(listprompt): missing func call
SteinRobert Mar 11, 2022
a75bbf1
WIP: auto async update + spinner
SteinRobert Mar 16, 2022
45ba0e8
fix: async update for projects
SteinRobert Mar 17, 2022
13495c7
fix: async update for projects
SteinRobert Mar 17, 2022
daa9028
chore: remove comments
SteinRobert Mar 17, 2022
2da8bc9
refactor: remove unused imports
SteinRobert Mar 17, 2022
3ef6649
fix: reduce code smell
buschNT Mar 24, 2022
c697e02
fix: add cache README
buschNT Mar 24, 2022
31b5618
fix: UserID classmethod
buschNT Mar 28, 2022
b60a5c7
fix: login success message
buschNT Mar 28, 2022
2324a70
refactor: telepresence service_account_tokens
buschNT Mar 28, 2022
908ff2c
fix(KubeAPI): namespace arguments
buschNT Mar 28, 2022
178d8d7
fix: UpdatableFuzzyPrompt
buschNT Mar 28, 2022
553e938
fix: cluster create ingress port
buschNT Mar 29, 2022
33e5d79
fix(docu): adjust file paths
buschNT Apr 1, 2022
8513c03
fix: UUID types + switch wait for docker container
buschNT Apr 6, 2022
c0b7a0f
feat(gefyra): add kubeconfig_path
buschNT May 2, 2022
bb3a8a9
fix: add gefyra to dependencies
buschNT May 5, 2022
8ecdbf0
Merge branch 'main' into feature/gefyra-integration
buschNT May 17, 2022
cd0340a
fix: gefyra kubepath
buschNT May 17, 2022
c5a922a
chore: gefyra 0.8.0
buschNT Jun 3, 2022
d7c20c4
fix: graphql queries
buschNT Jun 3, 2022
c4592f7
chore: update gefyra
buschNT Jul 1, 2022
b1761c5
test: fix failing tests
buschNT Jul 1, 2022
d43e041
fix: deck list + project list error
buschNT Jul 1, 2022
4a065a6
fix: change default log level to INFO
buschNT Jul 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions tests/test_cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os
import tempfile
import unittest
from pathlib import Path
from uuid import UUID

from unikube.cache import Cache


class CacheTest(unittest.TestCase):
def setUp(self):
self.temporary_path_object = tempfile.TemporaryDirectory()
self.temporary_path = self.temporary_path_object.name

def tearDown(self):
self.temporary_path_object.cleanup()

def test_cache_empty(self):
cache = Cache(file_path=self.temporary_path)
self.assertEqual(UUID("00000000-0000-0000-0000-000000000000"), cache.userId)

def test_cache_save(self):
cache = Cache(file_path=self.temporary_path)
cache.file_path = self.temporary_path
cache.save()

file = Path(os.path.join(cache.file_path, cache.file_name))

self.assertTrue(file.exists())
self.assertEqual(UUID("00000000-0000-0000-0000-000000000000"), cache.userId)

def test_cache_load(self):
cache_01 = Cache(file_path=self.temporary_path)
cache_01.userId = UUID("00000000-0000-0000-0000-000000000001")
cache_01.save()

cache_02 = Cache(file_path=self.temporary_path)
self.assertEqual(UUID("00000000-0000-0000-0000-000000000001"), cache_02.userId)
18 changes: 8 additions & 10 deletions tests/test_cli_app.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
from unittest.mock import patch

from tests.login_testcase import LoginTestCase
from unikube.authentication.authentication import TokenAuthentication
from unikube.cli import app
from unikube.commands import ClickContext


def check():
"""Function used to mock check function"""
pass
from unikube.context import ClickContext


class AppTestCase(LoginTestCase):
def test_list(self):
@patch.object(TokenAuthentication, "check")
def test_list(self, *args, **kwargs):
obj = ClickContext()
obj.auth.check = check
result = self.runner.invoke(
app.list,
obj=obj,
)
assert result.exit_code == 1

def test_shell_invalid_arguments(self):
@patch.object(TokenAuthentication, "check")
def test_shell_invalid_arguments(self, *args, **kwargs):
obj = ClickContext()
obj.auth.check = check
result = self.runner.invoke(
app.shell,
[
Expand Down
171 changes: 83 additions & 88 deletions tests/test_cli_auth.py
Original file line number Diff line number Diff line change
@@ -1,94 +1,89 @@
import os
import unittest
from unittest.mock import patch

import pytest
from click.testing import CliRunner

from unikube.authentication.authentication import TokenAuthentication
from unikube.cli import auth
from unikube.commands import ClickContext


def test_login_failed():
runner = CliRunner()
result = runner.invoke(
auth.login,
["--email", "[email protected]", "--password", "unsecure"],
obj=ClickContext(),
)
assert "[ERROR] Login failed. Please check email and password.\n" in result.output
assert result.exit_code == 0


def test_login_wrong_token():
def login(email, password):
return {"success": True, "response": {"access_token": "WRONG_TOKEN"}}

runner = CliRunner()
obj = ClickContext()
obj.auth.login = login
result = runner.invoke(
auth.login,
["--email", "[email protected]", "--password", "secure"],
obj=obj,
)
assert "[ERROR] Login failed. Your token does not match." in result.output
assert result.exit_code == 0


def test_logout():
runner = CliRunner()
result = runner.invoke(
auth.logout,
obj=ClickContext(),
)
assert result.output == "[INFO] Logout completed.\n"
assert result.exit_code == 0


def test_status_not_logged():
runner = CliRunner()
result = runner.invoke(
auth.status,
obj=ClickContext(),
)
assert result.output == "[INFO] Authentication could not be verified.\n"
assert result.exit_code == 0


def test_status_success():
def verify():
return {"success": True}

runner = CliRunner()
obj = ClickContext()
obj.auth.verify = verify
result = runner.invoke(
auth.status,
obj=obj,
)
assert result.output == "[SUCCESS] Authentication verified.\n"
assert result.exit_code == 0


def test_login_logout_success():
runner = CliRunner()

email = os.getenv("TESTRUNNER_EMAIL")
secret = os.getenv("TESTRUNNER_SECRET")
assert email is not None
assert secret is not None

result = runner.invoke(
auth.login,
["--email", email, "--password", secret],
obj=ClickContext(),
)
assert "[SUCCESS] Login successful. Hello Testrunner!\n" in result.output
assert result.exit_code == 0

result = runner.invoke(
auth.logout,
obj=ClickContext(),
)
assert result.output == "[INFO] Logout completed.\n"
assert result.exit_code == 0
from unikube.context import ClickContext


class AuthTest(unittest.TestCase):
def test_login_failed(self):
runner = CliRunner()
result = runner.invoke(
auth.login,
["--email", "[email protected]", "--password", "unsecure"],
obj=ClickContext(),
)
assert "[ERROR] Login failed. Please check email and password.\n" in result.output
assert result.exit_code == 1

@patch.object(TokenAuthentication, "login")
def test_login_wrong_token(self, mock_login):
mock_login.return_value = {"success": True, "response": {"access_token": "WRONG_TOKEN"}}

runner = CliRunner()
obj = ClickContext()
result = runner.invoke(
auth.login,
["--email", "[email protected]", "--password", "secure"],
obj=obj,
)
assert "[ERROR] Login failed." in result.output
assert result.exit_code == 1

def test_logout(self):
runner = CliRunner()
result = runner.invoke(
auth.logout,
obj=ClickContext(),
)
assert result.output == "[INFO] Logout completed.\n"
assert result.exit_code == 0

def test_status_not_logged(self):
runner = CliRunner()
result = runner.invoke(
auth.status,
obj=ClickContext(),
)
assert result.output == "[INFO] Authentication could not be verified.\n"
assert result.exit_code == 0

@patch.object(TokenAuthentication, "verify")
def test_status_success(self, mock_verify):
mock_verify.return_value = {"success": True}

runner = CliRunner()
obj = ClickContext()
result = runner.invoke(
auth.status,
obj=obj,
)
assert result.output == "[SUCCESS] Authentication verified.\n"
assert result.exit_code == 0

def test_login_logout_success(self):
email = os.getenv("TESTRUNNER_EMAIL")
secret = os.getenv("TESTRUNNER_SECRET")

self.assertIsNotNone(email)
self.assertIsNotNone(secret)

runner = CliRunner()
result = runner.invoke(
auth.login,
["--email", email, "--password", secret],
obj=ClickContext(),
)
assert "[SUCCESS] Login successful.\n" in result.output
assert result.exit_code == 0

result = runner.invoke(
auth.logout,
obj=ClickContext(),
)
assert result.output == "[INFO] Logout completed.\n"
assert result.exit_code == 0
4 changes: 0 additions & 4 deletions tests/test_cli_deck.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,4 @@ def test_deck_ingress(self):
obj=ClickContext(),
)

self.assertIn(
"[ERROR] The project cluster does not exist. Please be sure to run 'unikube project up' first.\n",
result.output,
)
self.assertEqual(result.exit_code, 1)
11 changes: 3 additions & 8 deletions tests/test_cli_helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
from requests import HTTPError, Session

from unikube.cache import Cache
from unikube.helpers import (
check_environment_type_local_or_exit,
download_manifest,
Expand Down Expand Up @@ -40,15 +41,9 @@ def test_download_manifest():
},
}

class Authentication:
def refresh(self):
return {"success": True, "response": {"access_token": ""}}

access_token = ""
authentication = Authentication()

cache = Cache()
with pytest.raises(SystemExit) as pytest_wrapped_e:
_ = download_manifest(deck=deck, authentication=authentication, access_token=access_token)
_ = download_manifest(deck=deck, cache=cache)

assert pytest_wrapped_e.type == SystemExit
assert pytest_wrapped_e.value.code == 1
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli_orga.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ def test_orga_list(self):

self.assertIn("id", result.output)
self.assertIn("name", result.output)
self.assertIn("acme", result.output)
self.assertIn("ACME", result.output)
self.assertEqual(result.exit_code, 0)
2 changes: 1 addition & 1 deletion tests/test_cli_project.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from tests.login_testcase import LoginTestCase
from unikube.cli import orga, project
from unikube.cli import project
from unikube.commands import ClickContext


Expand Down
4 changes: 4 additions & 0 deletions unikube.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from unikube.commands import cli

if __name__ == "__main__":
cli()
33 changes: 0 additions & 33 deletions unikube/_backup/decorators.py

This file was deleted.

Loading