From b8e0cd56ef5e852e2b5722d6c45fc8c86dfc6d8a Mon Sep 17 00:00:00 2001
From: Stefan Nica <snica@suse.com>
Date: Wed, 9 Sep 2020 14:06:48 +0200
Subject: [PATCH] Enable tests to run on a SUSE container

Those changes are required to be able to run the harbor tests on a
container running SLES or openSUSE 15.
---
 tests/apitests/python/library/cnab.py       | 2 +-
 tests/apitests/python/library/containerd.py | 4 ++--
 tests/apitests/python/library/docker_api.py | 6 +++---
 tests/apitests/python/update_docker_cfg.sh  | 6 +++---
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/tests/apitests/python/library/cnab.py b/tests/apitests/python/library/cnab.py
index f0b7231dc..0aa1795fe 100644
--- a/tests/apitests/python/library/cnab.py
+++ b/tests/apitests/python/library/cnab.py
@@ -19,7 +19,7 @@ def load_bundle(service_image, invocation_image):
 
 def cnab_fixup_bundle(bundle_file, target, auto_update_bundle = True):
     fixed_bundle_file = "./tests/apitests/python/bundle_data/fixed-bundle.json"
-    command = ["sudo", "cnab-to-oci", "--log-level", "debug", "fixup", bundle_file, "--target", target, "--bundle", fixed_bundle_file]
+    command = ["cnab-to-oci", "--log-level", "debug", "fixup", bundle_file, "--target", target, "--bundle", fixed_bundle_file]
     if auto_update_bundle == True:
          command.append("--auto-update-bundle")
          #fixed_bundle_file = bundle_file
diff --git a/tests/apitests/python/library/containerd.py b/tests/apitests/python/library/containerd.py
index 01ecc3cf7..5ea2aa1c3 100644
--- a/tests/apitests/python/library/containerd.py
+++ b/tests/apitests/python/library/containerd.py
@@ -5,13 +5,13 @@ import json
 import docker_api
 
 def ctr_images_pull(username, password, oci):
-    command = ["sudo", "ctr", "images", "pull", "-u", username+":"+password, oci]
+    command = ["containerd-ctr", "images", "pull", "-u", username+":"+password, oci]
     print("Command: ", command)
     ret = base.run_command(command)
     print("Command return: ", ret)
 
 def ctr_images_list(oci_ref = None):
-    command = ["sudo", "ctr", "images", "list", "--q"]
+    command = ["containerd-ctr", "images", "list", "--q"]
     print("Command: ", command)
     ret = base.run_command(command)
     print("Command return: ", ret)
diff --git a/tests/apitests/python/library/docker_api.py b/tests/apitests/python/library/docker_api.py
index b745b8ef9..7fce643c6 100644
--- a/tests/apitests/python/library/docker_api.py
+++ b/tests/apitests/python/library/docker_api.py
@@ -18,7 +18,7 @@ def docker_info_display():
     print("Command return: ", ret)
 
 def docker_login_cmd(harbor_host, user, password, enable_manifest = True):
-    command = ["sudo", "docker", "login", harbor_host, "-u", user, "-p", password]
+    command = ["docker", "login", harbor_host, "-u", user, "-p", password]
     print( "Docker Login Command: ", command)
     base.run_command(command)
     if enable_manifest == True:
@@ -28,13 +28,13 @@ def docker_login_cmd(harbor_host, user, password, enable_manifest = True):
             raise Exception("Failed to update docker config, error is {} {}.".format(exc.returncode, exc.output))
 
 def docker_manifest_create(index, manifests):
-    command = ["sudo", "docker","manifest","create",index]
+    command = ["docker","manifest","create",index]
     command.extend(manifests)
     print( "Docker Manifest Command: ", command)
     base.run_command(command)
 
 def docker_manifest_push(index):
-    command = ["sudo", "docker","manifest","push",index]
+    command = ["docker","manifest","push",index]
     print( "Docker Manifest Command: ", command)
     ret = base.run_command(command)
     index_sha256=""
diff --git a/tests/apitests/python/update_docker_cfg.sh b/tests/apitests/python/update_docker_cfg.sh
index 0ab4968ed..efd138bcf 100755
--- a/tests/apitests/python/update_docker_cfg.sh
+++ b/tests/apitests/python/update_docker_cfg.sh
@@ -1,5 +1,5 @@
 #!/bin/sh
 
-sudo sed -i '$d' /$HOME/.docker/config.json
-sudo sed -i '$d' /$HOME/.docker/config.json
-sudo echo -e "\n        },\n        \"experimental\": \"enabled\"\n}" >> /$HOME/.docker/config.json
+sed -i '$d' /$HOME/.docker/config.json
+sed -i '$d' /$HOME/.docker/config.json
+echo -e "\n        },\n        \"experimental\": \"enabled\"\n}" >> /$HOME/.docker/config.json
-- 
2.16.4

