Browse Source

test/gitolite (#3)

test: Gitolite dockerization

test: Gitolite docherization 37

test: Gitolite docherization 36

test: Gitolite docherization 35

test: Gitolite docherization 34

test: Gitolite docherization 33

test: Gitolite docherization 32

test: Gitolite docherization 31

test: Gitolite docherization 30

test: Gitolite docherization 29

test: Gitolite docherization 28

test: Gitolite docherization 27

test: Gitolite docherization 26

test: Gitolite docherization 25

test: Gitolite docherization 24

test: Gitolite docherization 23

test: Gitolite docherization 22

test: Gitolite docherization 21

test: Gitolite docherization 20

test: Gitolite docherization 19

test: Gitolite docherization 18

test: Gitolite docherization 17

test: Gitolite docherization 16

test: Gitolite docherization 15

test: Gitolite docherization 14

test: Gitolite docherization 13

test: Gitolite docherization 12

test: Gitolite docherization 11

test: Gitolite docherization 10

test: Gitolite docherization 9

test: Gitolite docherization 8

test: Gitolite docherization 7

test: Gitolite docherization 6

test: Gitolite docherization

test: Gitolite docherization

test: Gitolite docherization 3

test: Gitolite docherization 2

test: Gitolite docherization 1

Co-authored-by: mco-system <michael.costa@mcos.nc>
Reviewed-on: https://git.mcos.nc/scrippy/scrippy-git/pulls/3
Co-Authored-By: Michaël Costa <michael.costa@mcos.nc>
Co-Committed-By: Michaël Costa <michael.costa@mcos.nc>
pull/4/head
Michaël Costa 5 months ago
parent
commit
a810b53860
10 changed files with 121 additions and 18 deletions
  1. +11
    -1
      .drone.yml
  2. +2
    -2
      scrippy_git/git/__init__.py
  3. +19
    -0
      tests/docker/Makefile
  4. +6
    -0
      tests/docker/docker-compose.yml
  5. +1
    -0
      tests/docker/git/scrippy.pub
  6. +13
    -0
      tests/docker/gitolite.dockerfile
  7. +1
    -0
      tests/docker/ssh/scrippy.pub
  8. +14
    -0
      tests/docker/start.sh
  9. +38
    -0
      tests/ssh/scrippy.rsa
  10. +16
    -15
      tests/test_git.py

+ 11
- 1
.drone.yml View File

@ -8,6 +8,8 @@ steps:
- name: Test
image: python
commands:
- chmod 700 ./tests/ssh
- chmod 600 ./tests/ssh/scrippy.rsa
- python -m pip install pip --upgrade
- python -m pip install .[dev]
- python3 -m pytest --cov=scrippy_git --junitxml=./junit_report.xml
@ -63,8 +65,16 @@ steps:
exclude:
- tag
- pull_request
services:
- name: gitolite
pull: never
image: gitolite:latest
ports:
- 2200
---
kind: signature
hmac: e3ab2a931a1fde2f7fc57693c79ebbc858a1accb7de26c165f6c3f0cfe8fecce
hmac: de0a23194495e115559933c368b0eb11b0ddfc7805ef01094c29eb135022d992
...

+ 2
- 2
scrippy_git/git/__init__.py View File

@ -27,13 +27,13 @@ class Repo():
self.origin = None
self.branch = None
def clone(self, branch, path, origin="origin", options=[]):
def clone(self, branch, path, origin="origin", options=[], env={}):
logging.info("[+] Clonage du depot: {}".format(self.url))
logging.info(" '-> {}".format(path))
self.path = path
self.branch = branch
try:
self.cloned = git.Repo.clone_from(self.url, path, branch=branch, multi_options=options)
self.cloned = git.Repo.clone_from(self.url, path, branch=branch, multi_options=options, env=env)
self.origin = self.cloned.remote(name=origin)
except Exception as e:
err_msg = "Erreur lors du clonage du depot: [{}]: {}".format(e.__class__.__name__, e)


+ 19
- 0
tests/docker/Makefile View File

@ -0,0 +1,19 @@
.RECIPEPREFIX +=
.PHONY: run kill build delete prune stop rebuild
stop:
cd ./docker; docker-compose down --rmi local --remove-orphans
prune:
docker container prune -f
delete:
docker rmi gitolite
build:
cd ./docker; docker build -t gitolite -f gitolite.dockerfile .
run:
cd ./docker; docker-compose up -d
rebuild: | stop delete build run

+ 6
- 0
tests/docker/docker-compose.yml View File

@ -0,0 +1,6 @@
services:
gitolite:
image: gitolite:latest
container_name: gitolite
ports:
- "2200:2200"

+ 1
- 0
tests/docker/git/scrippy.pub View File

@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC7GVr51EBjIleMgEGam33YU0A9YmspkcqJpLogy0V4/uoqMkZnuMlRih1PU2z6NMGS/JZnZNC8iyEnAIieZV+39C5W6N6viGHxXs36Y2eJEIf/wDLLHYpeuDrG4w7iShJg+A2VK46M0fAzEBzCXJp6cYypSMib/avKYKO5sJ6O3yhUVYktg6/G0fHk9vccC0/okbvyRkC7QBiM9N1YjbTI4d6zOoZWdDBtWfSrVoxfv+waP7mDl0EeITgwDVTUokbyjn4uEI/CAfntT0xFujfzsCPIT2JFAB+xbYRugwaBtKQs+VTYb1ukDrBAe8uugnhHfegHq2NdHGgR5NUtRuXzxPtyEIn/3dCrbZIhzvrrdLPyCQ2YAaWH3d6JnaDRPZUH3IMRd6Gf6Ruuk2S+nm8XKPLuoVDhkhBHvRzAQ8qQ5dRc/AMShJUVYPP/K/Azcy5a2Q0DrW8vwk9d83lvpmAZVPrDbRU81SWDurk/sJi2AvdKOBmkNSiswQ9y8Cfz560= doug@cyberlab.redatomik.org

+ 13
- 0
tests/docker/gitolite.dockerfile View File

@ -0,0 +1,13 @@
FROM alpine:latest
RUN apk add gitolite git openssh openssl shadow bash
COPY ./git /var/lib/git
RUN chown -R git: /var/lib/git
COPY start.sh .
RUN chmod +x ./start.sh
RUN ./start.sh init
RUN usermod --password $(echo 0123456789 | openssl passwd -1 -stdin) git
USER git
RUN /usr/bin/gitolite setup -pk /var/lib/git/scrippy.pub
USER root
ENTRYPOINT ["./start.sh"]
EXPOSE 2200

+ 1
- 0
tests/docker/ssh/scrippy.pub View File

@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC7GVr51EBjIleMgEGam33YU0A9YmspkcqJpLogy0V4/uoqMkZnuMlRih1PU2z6NMGS/JZnZNC8iyEnAIieZV+39C5W6N6viGHxXs36Y2eJEIf/wDLLHYpeuDrG4w7iShJg+A2VK46M0fAzEBzCXJp6cYypSMib/avKYKO5sJ6O3yhUVYktg6/G0fHk9vccC0/okbvyRkC7QBiM9N1YjbTI4d6zOoZWdDBtWfSrVoxfv+waP7mDl0EeITgwDVTUokbyjn4uEI/CAfntT0xFujfzsCPIT2JFAB+xbYRugwaBtKQs+VTYb1ukDrBAe8uugnhHfegHq2NdHGgR5NUtRuXzxPtyEIn/3dCrbZIhzvrrdLPyCQ2YAaWH3d6JnaDRPZUH3IMRd6Gf6Ruuk2S+nm8XKPLuoVDhkhBHvRzAQ8qQ5dRc/AMShJUVYPP/K/Azcy5a2Q0DrW8vwk9d83lvpmAZVPrDbRU81SWDurk/sJi2AvdKOBmkNSiswQ9y8Cfz560= doug@cyberlab.redatomik.org

+ 14
- 0
tests/docker/start.sh View File

@ -0,0 +1,14 @@
#!/bn/#!/usr/bin/env bash
case $1 in
init)
/usr/bin/ssh-keygen -v -t dsa -f /etc/ssh/ssh_host_dsa_key -N ''
/usr/bin/ssh-keygen -v -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
/usr/bin/ssh-keygen -v -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''
/usr/bin/ssh-keygen -v -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ''
/usr/bin/ssh-keygen -v -A
;;
start)
echo "Starting ssh daemon..."
/usr/sbin/sshd -D -p 2200
;;
esac

+ 38
- 0
tests/ssh/scrippy.rsa View File

@ -0,0 +1,38 @@
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
NhAAAAAwEAAQAAAYEAuxla+dRAYyJXjIBBmpt92FNAPWJrKZHKiaS6IMtFeP7qKjJGZ7jJ
UYodT1Ns+jTBkvyWZ2TQvIshJwCInmVft/QuVujer4hh8V7N+mNniRCH/8Ayyx2KXrg6xu
MO4koSYPgNlSuOjNHwMxAcwlyaenGMqUjIm/2rymCjubCejt8oVFWJLYOvxtHx5Pb3HAtP
6JG78kZAu0AYjPTdWI20yOHeszqGVnQwbVn0q1aMX7/sGj+5g5dBHiE4MA1U1KJG8o5+Lh
CPwgH57U9MRbo387AjyE9iRQAfsW2EboMGgbSkLPlU2G9bpA6wQHvLroJ4R33oB6tjXRxo
EeTVLUbl88T7chCJ/93Qq22SIc7663Sz8gkNmAG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_git."""
import os
import shutil
from scrippy_git import git
USERNAME = "git"
HOST = "git.mcos.nc"
PORT = 2205
REPONAME = "scrippy/scrippy-git.git"
HOST = "gitolite"
PORT = 2200
REPONAME = "gitolite-admin"
BRANCH = "master"
ENV = {"GIT_SSH_COMMAND": "ssh -i {}/ssh/scrippy.rsa -o StrictHostKeyChecking=no".format(os.path.dirname(os.path.realpath(__file__)))}
def test_git_pull():
"""Test pull and commit."""
assert True
# repo = git.Repo(USERNAME, HOST, PORT, REPONAME)
# local_path = os.path.join("./", REPONAME)
# repo.clone(branch=BRANCH, path=local_path)
# test_fname = os.path.join(local_path, "dead_parrot.txt")
# with open(test_fname, mode="w") as test_file:
# test_file.write("Nobody expects the Spanish inquisition !")
# commit_message = "Inquisition shall not be expected"
# repo.commit(commit_message)
# shutil.rmtree(os.path.dirname(local_path))
"""Test Git pull."""
repo = git.Repo(USERNAME, HOST, PORT, REPONAME)
local_path = os.path.join("./", REPONAME)
repo.clone(branch=BRANCH, path=local_path, env=ENV)
gitolite_config_filename = os.path.join(local_path, "conf", "gitolite.conf")
with open(gitolite_config_filename, mode="r") as gitolite_config_file:
gitolite_conf = gitolite_config_file.readlines()
assert gitolite_conf[0].strip() == "repo gitolite-admin"
with open(gitolite_config_filename, mode="w") as gitolite_config_file:
gitolite_config_file.write("Nobody expects the Spanish inquisition !")
commit_message = "Inquisition shall not be expected"
repo.commit(commit_message)

Loading…
Cancel
Save