Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ semantic-version~=2.9.0
kubernetes>=11.0.0,<22.0.0
retrying~=1.3.3
oic==1.3.0
gefyra~=0.8.1
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"python-slugify>=5.0.2,<6.2.0",
"click-didyoumean~=0.3.0",
"requests-toolbelt~=0.9.1",
"gefyra~=0.8.1",
],
python_requires="~=3.7",
packages=find_packages(),
Expand Down
41 changes: 41 additions & 0 deletions tests/cluster/storage/test_cluster_storage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import os
import tempfile
import unittest
from pathlib import Path
from uuid import UUID

from unikube.cluster.storage.cluster_storage import ClusterStorage


class ClusterStorageTest(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_missing_id(self):
with self.assertRaises(Exception):
_ = ClusterStorage(file_path=self.temporary_path)

def test_save(self):
cluster_storage = ClusterStorage(file_path=self.temporary_path, id=UUID("00000000-0000-0000-0000-000000000000"))
cluster_storage.save()

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

self.assertTrue(file.exists())
self.assertEqual(UUID("00000000-0000-0000-0000-000000000000"), cluster_storage.id)

def test_load(self):
cluster_storage_01 = ClusterStorage(
file_path=self.temporary_path, id=UUID("00000000-0000-0000-0000-000000000000")
)
cluster_storage_01.name = "test"
cluster_storage_01.save()

cluster_storage_02 = ClusterStorage(
file_path=self.temporary_path, id=UUID("00000000-0000-0000-0000-000000000000")
)
self.assertEqual("test", cluster_storage_02.name)
10 changes: 5 additions & 5 deletions tests/console/test_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_filter_none(self):
filter_ = None

choices_resolved = resolve_duplicates(choices=choices, identifiers=identifiers)
choices_filtered = filter_by_identifiers(choices=choices_resolved, identifiers=identifiers, filter=filter_)
choices_filtered = filter_by_identifiers(choices=choices_resolved, identifiers=identifiers, _filter=filter_)
assert choices_filtered == [CHOICE_01, CHOICE_02]

def test_filter_empty_list(self):
Expand All @@ -79,7 +79,7 @@ def test_filter_empty_list(self):
filter_ = []

choices_resolved = resolve_duplicates(choices=choices, identifiers=identifiers)
choices_filtered = filter_by_identifiers(choices=choices_resolved, identifiers=identifiers, filter=filter_)
choices_filtered = filter_by_identifiers(choices=choices_resolved, identifiers=identifiers, _filter=filter_)
assert choices_filtered == []

def test_filter_existing_01(self):
Expand All @@ -88,7 +88,7 @@ def test_filter_existing_01(self):
filter_ = ["1"]

choices_resolved = resolve_duplicates(choices=choices, identifiers=identifiers)
choices_filtered = filter_by_identifiers(choices=choices_resolved, identifiers=identifiers, filter=filter_)
choices_filtered = filter_by_identifiers(choices=choices_resolved, identifiers=identifiers, _filter=filter_)
assert choices_filtered == [CHOICE_01]

def test_filter_existing_02(self):
Expand All @@ -97,7 +97,7 @@ def test_filter_existing_02(self):
filter_ = ["2"]

choices_resolved = resolve_duplicates(choices=choices, identifiers=identifiers)
choices_filtered = filter_by_identifiers(choices=choices_resolved, identifiers=identifiers, filter=filter_)
choices_filtered = filter_by_identifiers(choices=choices_resolved, identifiers=identifiers, _filter=filter_)
assert choices_filtered == ["choice"]

def test_filter_non_existing(self):
Expand All @@ -106,7 +106,7 @@ def test_filter_non_existing(self):
filter_ = ["3"]

choices_resolved = resolve_duplicates(choices=choices, identifiers=identifiers)
choices_filtered = filter_by_identifiers(choices=choices_resolved, identifiers=identifiers, filter=filter_)
choices_filtered = filter_by_identifiers(choices=choices_resolved, identifiers=identifiers, _filter=filter_)
assert choices_filtered == []


Expand Down
5 changes: 5 additions & 0 deletions tests/gefyra/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ubuntu
# run a server on port 8000
RUN apt update && apt install -y iproute2 iputils-ping python3 traceroute wget curl
COPY local.py local.py
CMD python3 local.py
48 changes: 48 additions & 0 deletions tests/gefyra/local.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/env python

import http.server
import signal
import socket
import socketserver
import sys
from datetime import datetime

if sys.argv[1:]:
port = int(sys.argv[1])
else:
port = 8000


class MyHttpRequestHandler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
hostname = socket.gethostname()
now = datetime.utcnow()
self.wfile.write(
bytes(f"<html><body><h1>Hello from Gefyra. It is {now} on {hostname}.</h1></body></html>".encode("utf-8"))
)


my_handler = MyHttpRequestHandler
server = socketserver.ThreadingTCPServer(("", port), my_handler)


def signal_handler(signal, frame):
try:
if server:
server.server_close()
finally:
sys.exit(0)


signal.signal(signal.SIGINT, signal_handler)
try:
while True:
sys.stdout.flush()
server.serve_forever()
except KeyboardInterrupt:
pass

server.server_close()
15 changes: 15 additions & 0 deletions tests/gefyra/unikube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# unikube switch configuration file
apps:
local:
build:
context: .
dockerfile: Dockerfile
deployment: buzzword-counter-web
container: buzzword-counter
command: python3 local.py
ports:
- 9000:8000
volumes:
- ./src:/app
env:
- DJANGO_DEBUG: "True"
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
Loading