-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #184 from Mirantis/integration
add integration testing
- Loading branch information
Showing
12 changed files
with
207 additions
and
27 deletions.
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
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
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
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
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
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
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
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
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
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,15 @@ | ||
from kqueen.auth import authenticate | ||
|
||
|
||
def test_nonexisting_user(): | ||
""" | ||
Try authenticate with non-existing user | ||
It is expected to return None but not fail | ||
""" | ||
|
||
username = "non_existing_user" | ||
password = "password" | ||
|
||
result = authenticate(username, password) | ||
|
||
assert result is None |
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,80 @@ | ||
from flask import url_for | ||
from kqueen.conftest import auth_header | ||
from kqueen.models import User | ||
|
||
import json | ||
import pytest | ||
import yaml | ||
|
||
|
||
@pytest.mark.usefixtures('client_class') | ||
class TestInsertManualCluster: | ||
def setup(self): | ||
self.auth_header = auth_header(self.client) | ||
self.namespace = self.auth_header['X-Test-Namespace'] | ||
self.user = User.load(None, self.auth_header['X-User']) | ||
|
||
self.provisioner_id = None | ||
|
||
def test_run(self): | ||
self.create_provisioner() | ||
self.get_provisioners() | ||
self.create_cluster() | ||
self.get_cluster() | ||
|
||
def create_provisioner(self): | ||
data = { | ||
'name': 'Manual provisioner', | ||
'engine': 'kqueen.engines.ManualEngine', | ||
'owner': 'User:{}'.format(self.user.id), | ||
} | ||
|
||
response = self.client.post( | ||
url_for('api.provisioner_create'), | ||
data=json.dumps(data), | ||
headers=self.auth_header, | ||
content_type='application/json', | ||
) | ||
|
||
assert response.status_code == 200 | ||
|
||
self.provisioner_id = response.json['id'] | ||
|
||
def get_provisioners(self): | ||
response = self.client.get( | ||
url_for('api.provisioner_list'), | ||
headers=self.auth_header, | ||
content_type='application/json', | ||
) | ||
|
||
assert response.status_code == 200 | ||
|
||
content = response.data.decode(response.charset) | ||
assert self.provisioner_id in content | ||
|
||
def create_cluster(self): | ||
data = { | ||
'name': 'Manual cluster', | ||
'provisioner': 'Provisioner:{}'.format(self.provisioner_id), | ||
'kubeconfig': yaml.load(open('kubeconfig_localhost', 'r').read()), | ||
'owner': 'User:{}'.format(self.user.id), | ||
} | ||
|
||
response = self.client.post( | ||
url_for('api.cluster_create'), | ||
data=json.dumps(data), | ||
headers=self.auth_header, | ||
content_type='application/json', | ||
) | ||
|
||
assert response.status_code == 200 | ||
self.cluster_id = response.json['id'] | ||
|
||
def get_cluster(self): | ||
response = self.client.get( | ||
url_for('api.cluster_get', pk=self.cluster_id), | ||
headers=self.auth_header, | ||
content_type='application/json', | ||
) | ||
|
||
assert response.status_code == 200 |
Oops, something went wrong.