1
1
import unittest
2
2
3
+ import requests_mock
4
+
3
5
from podman import PodmanClient , tests
4
6
from podman .domain .manifests import Manifest , ManifestsManager
5
7
8
+ FIRST_MANIFEST = {
9
+ "Id" : "326dd9d7add24646a389e8eaa82125294027db2332e49c5828d96312c5d773ab" ,
10
+ "names" : "quay.io/fedora:latest" ,
11
+ }
12
+
6
13
7
14
class ManifestTestCase (unittest .TestCase ):
8
15
def setUp (self ) -> None :
@@ -23,6 +30,34 @@ def test_name(self):
23
30
manifest = Manifest ()
24
31
self .assertIsNone (manifest .name )
25
32
33
+ @requests_mock .Mocker ()
34
+ def test_push (self , mock ):
35
+ adapter = mock .post (
36
+ tests .LIBPOD_URL + "/manifests/quay.io%2Ffedora%3Alatest/registry/quay.io%2Ffedora%3Av1"
37
+ )
38
+
39
+ manifest = Manifest (attrs = FIRST_MANIFEST , client = self .client .api )
40
+ manifest .push (destination = "quay.io/fedora:v1" )
41
+
42
+ self .assertTrue (adapter .called_once )
43
+
44
+ @requests_mock .Mocker ()
45
+ def test_push_with_auth (self , mock ):
46
+ adapter = mock .post (
47
+ tests .LIBPOD_URL
48
+ + "/manifests/quay.io%2Ffedora%3Alatest/registry/quay.io%2Ffedora%3Av1" ,
49
+ request_headers = {
50
+ "X-Registry-Auth" : b"eyJ1c2VybmFtZSI6ICJ1c2VyIiwgInBhc3N3b3JkIjogInBhc3MifQ=="
51
+ },
52
+ )
53
+
54
+ manifest = Manifest (attrs = FIRST_MANIFEST , client = self .client .api )
55
+ manifest .push (
56
+ destination = "quay.io/fedora:v1" , auth_config = {"username" : "user" , "password" : "pass" }
57
+ )
58
+
59
+ self .assertTrue (adapter .called_once )
60
+
26
61
27
62
if __name__ == '__main__' :
28
63
unittest .main ()
0 commit comments