Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.package
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush Tiwari
slapos.package
Commits
40ecbc37
Commit
40ecbc37
authored
Jul 15, 2014
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos.package: Implement key handling.
parent
3b15fd91
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
10 deletions
+30
-10
slapos/package/distribution.py
slapos/package/distribution.py
+6
-2
slapos/package/test/test_distribution.py
slapos/package/test/test_distribution.py
+24
-8
No files found.
slapos/package/distribution.py
View file @
40ecbc37
...
...
@@ -29,6 +29,7 @@
##############################################################################
import
platform
import
urllib
import
glob
import
re
import
os
...
...
@@ -165,11 +166,14 @@ class AptGet:
def
addKey
(
self
,
caller
,
url
,
alias
):
""" Download and add a gpg key """
gpg_path
=
open
(
"%s/%s.gpg"
%
(
self
.
trusted_gpg_d_path
,
alias
))
if
not
os
.
path
.
exists
(
self
.
trusted_gpg_d_path
):
os
.
mkdir
(
self
.
trusted_gpg_d_path
)
gpg_path
=
"%s/%s.gpg"
%
(
self
.
trusted_gpg_d_path
,
alias
)
urllib
.
urlretrieve
(
url
,
gpg_path
)
if
os
.
path
.
exists
(
gpg_path
):
# File already exists, skip
return
raise
NotImplementedError
(
"Download part is missing"
)
def
updateRepository
(
self
,
caller
):
""" Add a repository """
...
...
slapos/package/test/test_distribution.py
View file @
40ecbc37
...
...
@@ -29,6 +29,8 @@
from
slapos.package.distribution
import
PackageManager
,
AptGet
,
Zypper
,
\
UnsupportedOSException
import
tempfile
import
shutil
import
os
import
glob
import
unittest
...
...
@@ -202,20 +204,34 @@ class testPackageManager(unittest.TestCase):
source_list_d
=
"/tmp/test_distribution_sources.list.d"
if
os
.
path
.
exists
(
source_list_d
):
os
.
rmdir
(
source_list_d
)
shutil
.
rmtree
(
source_list_d
)
handler
.
addRepository
(
dummy_caller
,
"http://test main"
,
"slapos"
)
self
.
assertTrue
(
os
.
path
.
exists
(
source_list_d
))
self
.
assertEquals
(
open
(
"%s/slapos.list"
%
source_list_d
,
"r"
).
read
(),
"deb http://test main"
)
# def addKey(self, caller, url, alias):
# """ Download and add a gpg key """
# gpg_path = open("%s/%s.gpg" % self.trusted_gpg_d_path, alias)
# if os.path.exists(gpg_path):
# # File already exists, skip
# return
# raise NotImplementedError("Download part is missing")
def
testAptGetAddKey
(
self
):
handler
=
AptGet
()
called
=
[]
def
dummy_caller
(
*
args
,
**
kwargs
):
called
.
append
(
"called"
)
info
,
fake_gpg_path
=
tempfile
.
mkstemp
()
with
open
(
fake_gpg_path
,
"w"
)
as
f
:
f
.
write
(
"KEY"
)
trusted_list_d
=
"/tmp/test_distribution_trusted.gpg.d"
if
os
.
path
.
exists
(
trusted_list_d
):
shutil
.
rmtree
(
trusted_list_d
)
handler
.
addKey
(
dummy_caller
,
"file://%s"
%
fake_gpg_path
,
"slapos"
)
self
.
assertTrue
(
os
.
path
.
exists
(
trusted_list_d
))
self
.
assertEquals
(
open
(
"%s/slapos.gpg"
%
trusted_list_d
,
"r"
).
read
(),
"KEY"
)
def
testAptGetUpdateRepository
(
self
):
handler
=
AptGet
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment