aboutsummaryrefslogtreecommitdiff
path: root/rscalib
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-05-04 10:59:43 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-05-04 10:59:43 +0200
commit60b5b46801044010c4a820a038cb44b2fdec6435 (patch)
treefa4aa60c041115364899ae99feaac2be2ec64ad2 /rscalib
parent2946fc39e168a169c5d36c5b915b7d7be47a12aa (diff)
downloadremote-logon-config-agent-60b5b46801044010c4a820a038cb44b2fdec6435.tar.gz
remote-logon-config-agent-60b5b46801044010c4a820a038cb44b2fdec6435.tar.bz2
remote-logon-config-agent-60b5b46801044010c4a820a038cb44b2fdec6435.zip
API v5: Start work on API v5.
Diffstat (limited to 'rscalib')
-rw-r--r--rscalib/__init__.py12
-rw-r--r--rscalib/tests/__init__.py15
2 files changed, 24 insertions, 3 deletions
diff --git a/rscalib/__init__.py b/rscalib/__init__.py
index 92ac16c..7077f96 100644
--- a/rscalib/__init__.py
+++ b/rscalib/__init__.py
@@ -187,6 +187,13 @@ class GetMazaDataAPI1(GetMazaData):
return urllib.request.Request(self.get_api_url() + path)
+class GetMazaDataAPI5(GetMazaDataAPI4):
+ """Get the maza data for a given username/email and password via API v5."""
+
+ # identical for now with API v4 regarding the URL request part.
+ api_version = 5
+
+
class GetMazaDataAPI4(GetMazaData):
"""Get the maza data for a given email and password via API v4."""
api_version = 4
@@ -205,7 +212,6 @@ class GetMazaDataAPI4(GetMazaData):
class GetMazaDataAPI3(GetMazaDataAPI4):
"""Get the maza data for a given email and password via API v3."""
-
api_version = 3
def get_url(self):
@@ -214,7 +220,6 @@ class GetMazaDataAPI3(GetMazaDataAPI4):
class GetMazaDataAPI2(GetMazaDataAPI3):
"""Get the maza data for a given email and password via API v2."""
-
api_version = 2
@@ -223,5 +228,6 @@ api_versions = {
'2': GetMazaDataAPI2,
'3': GetMazaDataAPI3,
'4': GetMazaDataAPI4,
- 'default': GetMazaDataAPI4,
+ '5': GetMazaDataAPI5,
+ 'default': GetMazaDataAPI5,
}
diff --git a/rscalib/tests/__init__.py b/rscalib/tests/__init__.py
index c3a8afa..6558d0a 100644
--- a/rscalib/tests/__init__.py
+++ b/rscalib/tests/__init__.py
@@ -20,6 +20,7 @@ from rscalib import (
GetMazaDataAPI2,
GetMazaDataAPI3,
GetMazaDataAPI4,
+ GetMazaDataAPI5,
PycURLGetter,
Unauthorized,
)
@@ -118,6 +119,20 @@ class TestGetMazaDataAPI4(TestCase):
self.assertEqual(expected, request.headers['Authorization'])
+class TestGetMazaDataAPI5(TestCase):
+
+ def test_make_request(self):
+ """v5 requests have correct URL and Auth header."""
+ getter = GetMazaDataAPI5('foo', 'bar')
+ request = getter.make_request()
+ credentials = base64.encodebytes(b'foo:bar').decode('ascii')
+ expected = 'Basic %s' % credentials
+ self.assertEqual('GET', request.get_method())
+ self.assertEqual('https://uccs.landscape.canonical.com/api/4/',
+ request.get_full_url())
+ self.assertEqual(expected, request.headers['Authorization'])
+
+
class FakeCurl:
"""Fake pycurl.Curl for testing PycURLGetter."""