Commit 67bd60ea by Łukasz Nowak

app: Fix bug with wrong PRIMARY KEY

Having PRIMARY KEY on certificate.id is to strict -- as real uniques is
required on id + reference in certificate table.
parent 85640261
......@@ -80,12 +80,13 @@ class SQLite3Storage(local):
active INTEGER
);
CREATE TABLE IF NOT EXISTS certificate (
id INTEGER PRIMARY KEY,
id INTEGER,
reference VARCHAR(255),
submission_date INTEGER,
not_valid_before_date INTEGER,
not_valid_after_date INTEGER,
pem TEXT
pem TEXT,
PRIMARY KEY (id, reference)
);
CREATE TABLE IF NOT EXISTS counter (
name TEXT PRIMARY KEY,
......
......@@ -714,9 +714,11 @@ class KedifaIntegrationTest(unittest.TestCase):
result.text
)
def generateauth(self):
def generateauth(self, reference=None):
if reference is None:
reference = self.reference
result = self.requests_get(
self.kedifa_url + self.reference + '/generateauth')
self.kedifa_url + reference + '/generateauth')
self.assertEqual(
httplib.CREATED,
result.status_code
......@@ -779,6 +781,28 @@ class KedifaIntegrationTest(unittest.TestCase):
def test_PUT(self):
self.put()
def test_PUT_multiple_same_reference(self):
auth = self.generateauth()
self.put(auth=auth)
_, key_pem, _, certificate_pem = self.generateKeyCertificateData(
not_valid_before=datetime.datetime.utcnow() - datetime.timedelta(days=4),
not_valid_after=datetime.datetime.utcnow() + datetime.timedelta(days=2)
)
self.put(data=key_pem + certificate_pem, auth=auth)
def test_PUT_multiple_different_reference(self):
# put first certificate
self.put()
# put another certificate on another reference
reference = self.reserveReference()
auth = self.generateauth(reference)
_, key_pem, _, certificate_pem = self.generateKeyCertificateData(
not_valid_before=datetime.datetime.utcnow() - datetime.timedelta(days=4),
not_valid_after=datetime.datetime.utcnow() + datetime.timedelta(days=2)
)
self.put(key=reference, data=key_pem + certificate_pem, auth=auth)
def test_PUT_certificate_expired(self):
_, key_pem, _, certificate_pem = self.generateKeyCertificateData(
not_valid_before=datetime.datetime.utcnow() - datetime.timedelta(days=4),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment