Validate origin URLs before sending to the scheduler

This commit is contained in:
Valentin Lorentz 2022-11-04 13:48:14 +01:00
parent 60707a45dd
commit 8ea4200909
8 changed files with 339 additions and 12 deletions

View file

@ -0,0 +1,151 @@
{
"packages": {
"payrix/payrix-php": {
"dev-master": {
"name": "payrix/payrix-php",
"description": "PayrixPHP PHP SDK package",
"keywords": [],
"homepage": "https://portal.payrix.com",
"version": "dev-master",
"version_normalized": "9999999-dev",
"license": [
"Apache-2.0"
],
"authors": [],
"source": {
"url": "git@gitlab.com:payrix/public/payrix-php.git",
"type": "git",
"reference": "cf02195d3c32424396932e087824bf581966e703"
},
"dist": {
"url": "https://gitlab.com/api/v4/projects/payrix%2Fpublic%2Fpayrix-php/repository/archive.zip?sha=cf02195d3c32424396932e087824bf581966e703",
"type": "zip",
"shasum": "",
"reference": "cf02195d3c32424396932e087824bf581966e703"
},
"type": "library",
"time": "2021-05-25T14:12:28+00:00",
"autoload": {
"psr-4": {
"PayrixPHP\\": "lib/"
}
},
"default-branch": true,
"require": {
"php": ">=5.4.0",
"ext-curl": "*",
"ext-openssl": "*"
},
"uid": 4416889
},
"v2.0.0": {
"name": "payrix/payrix-php",
"description": "PayrixPHP PHP SDK package",
"keywords": [],
"homepage": "https://portal.payrix.com",
"version": "v2.0.0",
"version_normalized": "2.0.0.0",
"license": [
"Apache-2.0"
],
"authors": [],
"source": {
"url": "https://gitlab.com/payrix/public/payrix-php.git",
"type": "git",
"reference": "4b40ad457a5cdbddb384b4d8f2c62d8d8c04ce68"
},
"dist": {
"url": "https://gitlab.com/api/v4/projects/payrix%2Fpublic%2Fpayrix-php/repository/archive.zip?sha=4b40ad457a5cdbddb384b4d8f2c62d8d8c04ce68",
"type": "zip",
"shasum": "",
"reference": "4b40ad457a5cdbddb384b4d8f2c62d8d8c04ce68"
},
"type": "library",
"time": "2020-09-03T11:26:52+00:00",
"autoload": {
"psr-4": {
"PayrixPHP\\": "lib/"
}
},
"require": {
"php": ">=5.4.0",
"ext-curl": "*",
"ext-openssl": "*"
},
"uid": 4416947
},
"v2.0.1": {
"name": "payrix/payrix-php",
"description": "PayrixPHP PHP SDK package",
"keywords": [],
"homepage": "https://portal.payrix.com",
"version": "v2.0.1",
"version_normalized": "2.0.1.0",
"license": [
"Apache-2.0"
],
"authors": [],
"source": {
"url": "https://gitlab.com/payrix/public/payrix-php.git",
"type": "git",
"reference": "9693f2dff0a589e16c88a9bf838069ab89166103"
},
"dist": {
"url": "https://gitlab.com/api/v4/projects/payrix%2Fpublic%2Fpayrix-php/repository/archive.zip?sha=9693f2dff0a589e16c88a9bf838069ab89166103",
"type": "zip",
"shasum": "",
"reference": "9693f2dff0a589e16c88a9bf838069ab89166103"
},
"type": "library",
"time": "2021-05-10T02:32:57+00:00",
"autoload": {
"psr-4": {
"PayrixPHP\\": "lib/"
}
},
"require": {
"php": ">=5.4.0",
"ext-curl": "*",
"ext-openssl": "*"
},
"uid": 5183918
},
"v2.0.2": {
"name": "payrix/payrix-php",
"description": "PayrixPHP PHP SDK package",
"keywords": [],
"homepage": "https://portal.payrix.com",
"version": "v2.0.2",
"version_normalized": "2.0.2.0",
"license": [
"Apache-2.0"
],
"authors": [],
"source": {
"url": "https://gitlab.com/payrix/public/payrix-php.git",
"type": "git",
"reference": "cf02195d3c32424396932e087824bf581966e703"
},
"dist": {
"url": "https://gitlab.com/api/v4/projects/payrix%2Fpublic%2Fpayrix-php/repository/archive.zip?sha=cf02195d3c32424396932e087824bf581966e703",
"type": "zip",
"shasum": "",
"reference": "cf02195d3c32424396932e087824bf581966e703"
},
"type": "library",
"time": "2021-05-25T10:12:28+00:00",
"autoload": {
"psr-4": {
"PayrixPHP\\": "lib/"
}
},
"require": {
"php": ">=5.4.0",
"ext-curl": "*",
"ext-openssl": "*"
},
"uid": 5232658
}
}
}
}

View file

@ -0,0 +1,24 @@
{
"packages": {
"ycms/module-main": {
"dev-master": {
"name": "with/invalid_url",
"description": "",
"keywords": [],
"homepage": "",
"version": "dev-master",
"version_normalized": "9999999-dev",
"license": [],
"authors": [],
"source": {
"type": "git",
"url": "git@example.org/invalid/url.git",
"reference": "0000000000000000000000000000000000000000"
},
"time": "2015-08-23T04:42:33+00:00",
"default-branch": true,
"uid": 4064797
}
}
}
}

View file

@ -14,7 +14,9 @@ _packages_list = {
"ljjackson/linnworks",
"lky/wx_article",
"spryker-eco/computop-api",
"idevlab/essential",
"idevlab/essential", # Git SSH URL
"payrix/payrix-php",
"with/invalid_url", # invalid URL
]
}
@ -49,7 +51,7 @@ def test_packagist_lister(swh_scheduler, requests_mock, datadir, requests_mock_d
stats = lister.run()
assert stats.pages == 1
assert stats.origins == len(_packages_list["packageNames"])
assert stats.origins == len(_packages_list["packageNames"]) - 2
assert lister.updated
expected_origins = {
@ -69,9 +71,9 @@ def test_packagist_lister(swh_scheduler, requests_mock, datadir, requests_mock_d
datetime.datetime.fromisoformat("2020-06-22T15:50:29+00:00"),
),
(
"git@gitlab.com:idevlab/Essential.git", # not GitHub
"https://gitlab.com/payrix/public/payrix-php.git", # not GitHub
"git",
datetime.datetime.fromisoformat("2022-10-12T10:34:29+00:00"),
datetime.datetime.fromisoformat("2021-05-25T14:12:28+00:00"),
),
}