-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for ruby-gem registry purls
- Loading branch information
Showing
4 changed files
with
207 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
from setuptools import setup | ||
|
||
setup(name='pypurl', | ||
version='v0.5.0', | ||
version='v0.6.0', | ||
python_requires='>=3.6', | ||
description='Implementation of an easy way to build and handle Package URLs.', | ||
description='Implementation of an easy way to build and handle Package URLs', | ||
author='Victor Barbaros', | ||
url='https://github.com/vBarbaros/pypurl', | ||
) |
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,181 @@ | ||
import unittest | ||
from pypurl.purl import Purl | ||
|
||
|
||
class RubyGemPurlTestCase(unittest.TestCase): | ||
def setUp(self): | ||
self.purl_obj = Purl() | ||
print('Running ruby-gem-repository tests... OK') | ||
|
||
def test_ruby_gem_purl_to_dict_version_success(self): | ||
purl_with_version = 'pkg:gem/aws-partitions@1.463.0' | ||
actual = self.purl_obj.purl_to_dict(purl_with_version) | ||
self.assertEqual(actual['scheme'], 'pkg') | ||
self.assertEqual(actual['type'], 'gem') | ||
self.assertEqual(actual['namespace'], '') | ||
self.assertEqual(actual['name'], 'aws-partitions') | ||
self.assertEqual(actual['version'], '1.463.0') | ||
|
||
def test_ruby_gem_purl_to_dict_version_qualifier_success(self): | ||
purl_with_version_qualifiers = 'pkg:gem/aws-partitions@1.463.0?param1=one,param2=two' | ||
actual = self.purl_obj.purl_to_dict(purl_with_version_qualifiers) | ||
self.assertEqual(actual['scheme'], 'pkg') | ||
self.assertEqual(actual['type'], 'gem') | ||
self.assertEqual(actual['namespace'], '') | ||
self.assertEqual(actual['name'], 'aws-partitions') | ||
self.assertEqual(actual['version'], '1.463.0') | ||
self.assertEqual(actual['qualifiers'], 'param1=one,param2=two') | ||
|
||
def test_ruby_gem_purl_to_dict_version_qualifier_path_success(self): | ||
purl_with_version_qualifiers_subpath = 'pkg:gem/aws-partitions@1.463.0?param1=one,param2=two#/src/main/sub-path' | ||
actual = self.purl_obj.purl_to_dict(purl_with_version_qualifiers_subpath) | ||
self.assertEqual(actual['scheme'], 'pkg') | ||
self.assertEqual(actual['type'], 'gem') | ||
self.assertEqual(actual['namespace'], '') | ||
self.assertEqual(actual['name'], 'aws-partitions') | ||
self.assertEqual(actual['version'], '1.463.0') | ||
self.assertEqual(actual['qualifiers'], 'param1=one,param2=two') | ||
self.assertEqual(actual['subpath'], '/src/main/sub-path') | ||
|
||
def test_ruby_gem_purl_to_dict_no_pkg_fail(self): | ||
'pkg:gem/aws-partitions@1.463.0' | ||
purl_with_version_qualifiers_subpath = 'gem/aws-partitions@1.463.0?param1=one,param2=two#/src/main/sub-path' | ||
actual = self.purl_obj.purl_to_dict(purl_with_version_qualifiers_subpath) | ||
self.assertEqual(actual, {}) | ||
|
||
def test_ruby_gem_purl_to_dict_no_type_fail(self): | ||
purl_with_version_qualifiers_subpath = 'pkg:aws-partitions@1.463.0?param1=one,param2=two#/src/main/sub-path' | ||
actual = self.purl_obj.purl_to_dict(purl_with_version_qualifiers_subpath) | ||
self.assertEqual(actual, {}) | ||
|
||
def test_ruby_gem_purl_to_dict_no_namespace_success(self): | ||
purl_with_version_qualifiers_subpath = 'pkg:gem/aws-partitions@1.463.0?param1=one,param2=two#/src/main/sub-path' | ||
actual = self.purl_obj.purl_to_dict(purl_with_version_qualifiers_subpath) | ||
self.assertEqual(actual['scheme'], 'pkg') | ||
self.assertEqual(actual['type'], 'gem') | ||
self.assertEqual(actual['namespace'], '') | ||
self.assertEqual(actual['name'], 'aws-partitions') | ||
self.assertEqual(actual['version'], '1.463.0') | ||
self.assertEqual(actual['qualifiers'], 'param1=one,param2=two') | ||
self.assertEqual(actual['subpath'], '/src/main/sub-path') | ||
|
||
def test_ruby_gem_purl_to_dict_no_name_fail(self): | ||
purl_with_version_qualifiers_subpath = 'pkg:gem@1.463.0?param1=one,param2=two#/src/main/sub-path' | ||
actual = self.purl_obj.purl_to_dict(purl_with_version_qualifiers_subpath) | ||
self.assertEqual(actual, {}) | ||
|
||
def test_ruby_gem_purl_to_dict_no_type_wrong_url_fail(self): | ||
purl_with_version_qualifiers_subpath = 'pkg:/aws-partitions@1.463.0?param1=one,param2=two#/src/main/sub-path' | ||
actual = self.purl_obj.purl_to_dict(purl_with_version_qualifiers_subpath) | ||
self.assertEqual(actual, {}) | ||
|
||
def test_ruby_gem_purl_to_dict_no_name_wrong_url_fail(self): | ||
purl_with_version_qualifiers_subpath = 'pkg:gem/@1.463.0?param1=one,param2=two#/src/main/sub-path' | ||
actual = self.purl_obj.purl_to_dict(purl_with_version_qualifiers_subpath) | ||
self.assertEqual(actual, {}) | ||
|
||
def test_ruby_gem_durl_to_dict_all_success(self): | ||
durl = 'https://rubygems.org/downloads/aws-partitions-1.463.0.gem' | ||
actual = self.purl_obj.durl_to_dict(durl, '1.463.0', 'param1=one,param2=two', '/src/main/sub-path') | ||
self.assertEqual(actual['scheme'], 'pkg') | ||
self.assertEqual(actual['type'], 'gem') | ||
self.assertEqual(actual['namespace'], '') | ||
self.assertEqual(actual['name'], 'aws-partitions') | ||
self.assertEqual(actual['version'], '1.463.0') | ||
self.assertEqual(actual['qualifiers'], 'param1=one,param2=two') | ||
self.assertEqual(actual['subpath'], '/src/main/sub-path') | ||
|
||
def test_ruby_gem_durl_to_dict_version_qualifier_success(self): | ||
durl = 'https://rubygems.org/downloads/aws-partitions-1.463.0.gem' | ||
actual = self.purl_obj.durl_to_dict(durl, '1.463.0', 'param1=one,param2=two') | ||
self.assertEqual(actual['scheme'], 'pkg') | ||
self.assertEqual(actual['type'], 'gem') | ||
self.assertEqual(actual['namespace'], '') | ||
self.assertEqual(actual['name'], 'aws-partitions') | ||
self.assertEqual(actual['version'], '1.463.0') | ||
self.assertEqual(actual['qualifiers'], 'param1=one,param2=two') | ||
|
||
def test_ruby_gem_durl_to_dict_version_success(self): | ||
durl = 'https://rubygems.org/downloads/aws-partitions-1.463.0.gem' | ||
actual = self.purl_obj.durl_to_dict(durl, '1.463.0') | ||
self.assertEqual(actual['scheme'], 'pkg') | ||
self.assertEqual(actual['type'], 'gem') | ||
self.assertEqual(actual['namespace'], '') | ||
self.assertEqual(actual['name'], 'aws-partitions') | ||
self.assertEqual(actual['version'], '1.463.0') | ||
|
||
def test_ruby_gem_durl_to_dict_main_success(self): | ||
durl = 'https://rubygems.org/downloads/aws-partitions-1.463.0.gem' | ||
actual = self.purl_obj.durl_to_dict(durl) | ||
self.assertEqual(actual['scheme'], 'pkg') | ||
self.assertEqual(actual['type'], 'gem') | ||
self.assertEqual(actual['namespace'], '') | ||
self.assertEqual(actual['name'], 'aws-partitions') | ||
|
||
def test_ruby_gem_durl_to_dict_main_wrong_http_fail(self): | ||
durl = 'https:rubygems.org/downloads/aws-partitions-1.463.0.gem' | ||
actual = self.purl_obj.durl_to_dict(durl) | ||
self.assertEqual(actual, {}) | ||
|
||
def test_ruby_gem_durl_to_dict_main_wrong_type_fail(self): | ||
durl = 'https://rubygems/downloads/aws-partitions-1.463.0.gem' | ||
actual = self.purl_obj.durl_to_dict(durl) | ||
self.assertEqual(actual, {}) | ||
|
||
def test_ruby_gem_durl_to_dict_main_wrong_namespace_fail(self): | ||
durl = 'https://rubygems.org//aws-partitions-1.463.0.gem' | ||
actual = self.purl_obj.durl_to_dict(durl) | ||
self.assertEqual(actual, {}) | ||
|
||
def test_ruby_gem_durl_to_dict_main_wrong_name_fail(self): | ||
durl = 'https://rubygems.org/downloads/1.463.0.gem' | ||
actual = self.purl_obj.durl_to_dict(durl) | ||
self.assertEqual(actual, {}) | ||
|
||
def test_ruby_gem_durl_to_purl_all_success(self): | ||
durl = 'https://rubygems.org/downloads/aws-partitions-1.463.0.gem' | ||
actual = self.purl_obj.durl_to_purl(durl, '1.463.0', 'param1=one,param2=two', '/src/main/sub-path') | ||
expect = 'pkg:gem/aws-partitions@1.463.0?param1=one,param2=two#/src/main/sub-path' | ||
self.assertEqual(expect, actual) | ||
|
||
def test_ruby_gem_durl_to_purl_version_qualifier_success(self): | ||
durl = 'https://rubygems.org/downloads/aws-partitions-1.463.0.gem' | ||
actual = self.purl_obj.durl_to_purl(durl, '1.463.0', 'param1=one,param2=two') | ||
expect = 'pkg:gem/aws-partitions@1.463.0?param1=one,param2=two' | ||
self.assertEqual(expect, actual) | ||
|
||
def test_ruby_gem_durl_to_purl_version_success(self): | ||
durl = 'https://rubygems.org/downloads/aws-partitions-1.463.0.gem' | ||
actual = self.purl_obj.durl_to_purl(durl, '1.463.0') | ||
expect = 'pkg:gem/aws-partitions@1.463.0' | ||
self.assertEqual(expect, actual) | ||
|
||
def test_ruby_gem_durl_to_purl_main_success(self): | ||
durl = 'https://rubygems.org/downloads/aws-partitions-1.463.0.gem' | ||
actual = self.purl_obj.durl_to_purl(durl) | ||
expect = 'pkg:gem/aws-partitions' | ||
self.assertEqual(expect, actual) | ||
|
||
def test_ruby_gem_params_to_purl_all_success(self): | ||
actual = self.purl_obj.params_to_purl('gem', '', 'aws-partitions', '1.463.0', 'param1=one,param2=two','/src/main/sub-path') | ||
expect = 'pkg:gem/aws-partitions@1.463.0?param1=one,param2=two#/src/main/sub-path' | ||
self.assertEqual(expect, actual) | ||
|
||
def test_ruby_gem_params_to_purl_version_qualifier_success(self): | ||
actual = self.purl_obj.params_to_purl('gem', '', 'aws-partitions', '1.463.0', 'param1=one,param2=two') | ||
expect = 'pkg:gem/aws-partitions@1.463.0?param1=one,param2=two' | ||
self.assertEqual(expect, actual) | ||
|
||
def test_ruby_gem_params_to_purl_version_success(self): | ||
actual = self.purl_obj.params_to_purl('gem', '', 'aws-partitions', '1.463.0') | ||
expect = 'pkg:gem/aws-partitions@1.463.0' | ||
self.assertEqual(expect, actual) | ||
|
||
def test_ruby_gem_params_to_purl_main_success(self): | ||
actual = self.purl_obj.params_to_purl('gem', '', 'aws-partitions') | ||
expect = 'pkg:gem/aws-partitions' | ||
self.assertEqual(expect, actual) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |