Skip to content

Commit

Permalink
Software identifiers now use double underscores
Browse files Browse the repository at this point in the history
  • Loading branch information
strongX509 committed Jun 22, 2017
1 parent 754af03 commit 95ebee0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions apps/swid/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class Tag(models.Model):
files = models.ManyToManyField('filesystem.File', blank=True, verbose_name='list of files')
sessions = models.ManyToManyField('core.Session', verbose_name='list of sessions')
software_id = models.CharField(max_length=767, db_index=True,
help_text='The Software ID, format: {regid}_{tagId} '
'e.g strongswan.org_fedora_19-x86_64-strongswan-5.1.2-4.fc19')
help_text='The Software ID, format: {regid}__{tagId} '
'e.g strongswan.org__fedora_19-x86_64-strongswan-5.1.2-4.fc19')

class Meta(object):
db_table = TABLE_PREFIX + 'tags'
Expand Down
2 changes: 1 addition & 1 deletion apps/swid/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def start(self, tag, attrib):

# Use regid of last entity with tagCreator role to construct software-id
if role_id == EntityRole.TAG_CREATOR:
self.tag.software_id = '%s_%s' % (regid, self.tag.unique_id)
self.tag.software_id = '%s__%s' % (regid, self.tag.unique_id)

def end(self, tag):
clean_tag = tag.split('}')[-1] # Strip XSD part from tag name
Expand Down
10 changes: 5 additions & 5 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def form_request(data, encode=True):
])
def test_swid_measurement_diff(api_client, session, swidtag, filename):
software_ids = [
'strongswan.org_debian_7.4-x86_64-cowsay-3.03+dfsg1-4',
'strongswan.org_debian_7.4-x86_64-strongswan-4.5.2-1.5+deb7u3'
'strongswan.org__debian_7.4-x86_64-cowsay-3.03+dfsg1-4',
'strongswan.org__debian_7.4-x86_64-strongswan-4.5.2-1.5+deb7u3'
]
data = {'data': software_ids}

Expand Down Expand Up @@ -173,7 +173,7 @@ def test_swid_measurement_diff(api_client, session, swidtag, filename):
'strongswan.short.swidtag',
])
def test_diff_on_invalid_session(api_client, swidtag, filename):
software_ids = ['strongswan.org_debian_7.4-x86_64-strongswan-4.5.2-1.5+deb7u3']
software_ids = ['strongswan.org__debian_7.4-x86_64-strongswan-4.5.2-1.5+deb7u3']
data = {'data': software_ids}

assert Session.objects.filter(pk=1).count() == 0
Expand All @@ -191,7 +191,7 @@ def test_add_single_tag(api_client):
response = api_client.post(reverse('swid-add-tags'), data, format='json')
assert response.status_code == status.HTTP_200_OK

sw_id = "strongswan.org_debian_7.4-x86_64-strongswan-4.5.2-1.5+deb7u3"
sw_id = "strongswan.org__debian_7.4-x86_64-strongswan-4.5.2-1.5+deb7u3"
assert Tag.objects.filter(software_id=sw_id).exists()


Expand All @@ -208,7 +208,7 @@ def test_add_existing_tag(api_client, swidtag, filename):
response = api_client.post(reverse('swid-add-tags'), data, format='json')
assert response.status_code == status.HTTP_200_OK
tag = Tag.objects.get(
software_id="strongswan.org_debian_7.4-x86_64-strongswan-4.5.2-1.5+deb7u3")
software_id="strongswan.org__debian_7.4-x86_64-strongswan-4.5.2-1.5+deb7u3")

assert tag.files.count() == 7
assert tag.entityrole_set.count() == 2
Expand Down

0 comments on commit 95ebee0

Please sign in to comment.