Repository: aquasecurity/starboard
Pull request #379 (2021-02-10 15:23:37)

fix: Get registry server from Docker auth key
Signed-off-by: Daniel Pacak <pacak.daniel@gmail.com>

codecov[bot]: # [Codecov](https://codecov.io/gh/aquasecurity/starboard/pull/379?src=pr&el=h1) Report
> Merging [#379](https://codecov.io/gh/aquasecurity/starboard/pull/379?src=pr&el=desc) (f21f04b) into [main](https://codecov.io/gh/aquasecurity/starboard/commit/b73ef2a6938198586a22315c37d69e41daae88aa?el=desc) (b73ef2a) will **decrease** coverage by `37.80%`.
> The diff coverage is `76.92%`.

[![Impacted file tree graph](https://codecov.io/gh/aquasecurity/starboard/pull/379/graphs/tree.svg?width=650&height=150&src=pr&token=qqTGKAJ0Wb)](https://codecov.io/gh/aquasecurity/starboard/pull/379?src=pr&el=tree)

```diff
@@             Coverage Diff             @@
##             main     #379       +/-   ##
===========================================
- Coverage   68.32%   30.51%   -37.81%     
===========================================
  Files          58       57        -1     
  Lines        3062     2972       -90     
===========================================
- Hits         2092      907     -1185     
- Misses        714     2002     +1288     
+ Partials      256       63      -193     
```


| [Impacted Files](https://codecov.io/gh/aquasecurity/starboard/pull/379?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pkg/docker/config.go](https://codecov.io/gh/aquasecurity/starboard/pull/379/diff?src=pr&el=tree#diff-cGtnL2RvY2tlci9jb25maWcuZ28=) | `55.81% <72.72%> (-1.01%)` | :arrow_down: |
| [pkg/kube/secrets.go](https://codecov.io/gh/aquasecurity/starboard/pull/379/diff?src=pr&el=tree#diff-cGtnL2t1YmUvc2VjcmV0cy5nbw==) | `31.11% <100.00%> (-14.45%)` | :arrow_down: |
| [pkg/cmd/get.go](https://codecov.io/gh/aquasecurity/starboard/pull/379/diff?src=pr&el=tree#diff-cGtnL2NtZC9nZXQuZ28=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [pkg/cmd/find.go](https://codecov.io/gh/aquasecurity/starboard/pull/379/diff?src=pr&el=tree#diff-cGtnL2NtZC9maW5kLmdv) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [pkg/cmd/root.go](https://codecov.io/gh/aquasecurity/starboard/pull/379/diff?src=pr&el=tree#diff-cGtnL2NtZC9yb290Lmdv) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [pkg/cmd/scan.go](https://codecov.io/gh/aquasecurity/starboard/pull/379/diff?src=pr&el=tree#diff-cGtnL2NtZC9zY2FuLmdv) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [pkg/cmd/polaris.go](https://codecov.io/gh/aquasecurity/starboard/pull/379/diff?src=pr&el=tree#diff-cGtnL2NtZC9wb2xhcmlzLmdv) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [pkg/cmd/version.go](https://codecov.io/gh/aquasecurity/starboard/pull/379/diff?src=pr&el=tree#diff-cGtnL2NtZC92ZXJzaW9uLmdv) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [pkg/cmd/kube\_bench.go](https://codecov.io/gh/aquasecurity/starboard/pull/379/diff?src=pr&el=tree#diff-cGtnL2NtZC9rdWJlX2JlbmNoLmdv) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [pkg/cmd/kube\_hunter.go](https://codecov.io/gh/aquasecurity/starboard/pull/379/diff?src=pr&el=tree#diff-cGtnL2NtZC9rdWJlX2h1bnRlci5nbw==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| ... and [33 more](https://codecov.io/gh/aquasecurity/starboard/pull/379/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/aquasecurity/starboard/pull/379?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/aquasecurity/starboard/pull/379?src=pr&el=footer). Last update [b73ef2a...4f62430](https://codecov.io/gh/aquasecurity/starboard/pull/379?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/go.mod b/go.mod
index 8078280..f2e4789 100644
--- a/go.mod
+++ b/go.mod
@@ -8,8 +8,8 @@ require (
 	github.com/go-logr/logr v0.3.0
 	github.com/google/go-containerregistry v0.1.1
 	github.com/google/uuid v1.1.1
-	github.com/onsi/ginkgo v1.14.1
-	github.com/onsi/gomega v1.10.2
+	github.com/onsi/ginkgo v1.15.0
+	github.com/onsi/gomega v1.10.5
 	github.com/spf13/cobra v1.1.1
 	github.com/spf13/pflag v1.0.5
 	github.com/stretchr/testify v1.7.0
diff --git a/go.sum b/go.sum
index 26953e5..7563fd4 100644
--- a/go.sum
+++ b/go.sum
@@ -588,8 +588,9 @@ github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+
 github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
 github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg=
 github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
-github.com/onsi/ginkgo v1.14.1 h1:jMU0WaQrP0a/YAEq8eJmJKjBoMs+pClEr1vDMlM/Do4=
 github.com/onsi/ginkgo v1.14.1/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
+github.com/onsi/ginkgo v1.15.0 h1:1V1NfVQR87RtWAgp1lv9JZJ5Jap+XFGKPi00andXGi4=
+github.com/onsi/ginkgo v1.15.0/go.mod h1:hF8qUzuuC8DJGygJH3726JnCZX4MYbRB8yFfISqnKUg=
 github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
 github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
 github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
@@ -597,8 +598,9 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J
 github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
 github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
 github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
-github.com/onsi/gomega v1.10.2 h1:aY/nuoWlKJud2J6U0E3NWsjlg+0GtwXxgEqthRdzlcs=
 github.com/onsi/gomega v1.10.2/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
+github.com/onsi/gomega v1.10.5 h1:7n6FEkpFmfCoo2t+YYqXH0evK+a9ICQz0xcAy9dYcaQ=
+github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48=
 github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
 github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
 github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
@@ -752,6 +754,7 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q
 github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
 github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
 go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
 go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
@@ -875,8 +878,10 @@ golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/
 golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
 golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
 golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
-golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU=
 golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
+golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
+golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb h1:eBmm0M9fYhWpKZLjQUUKka/LtIxf46G4fxeEz5KJr9U=
+golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
 golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
 golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
 golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -892,6 +897,7 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJ
 golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -942,8 +948,10 @@ golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7w
 golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4 h1:5/PjkGUjvEU5Gl6BxmvKRPpqo2uNMv4rcHBMwzk/st8=
 golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210112080510-489259a85091 h1:DMyOG0U+gKfu8JZzg2UQe9MeaC1X+xQWlAKcRnjxjCw=
+golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -1028,12 +1036,14 @@ golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roY
 golang.org/x/tools v0.0.0-20200502202811-ed308ab3e770/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
 golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
 golang.org/x/tools v0.0.0-20200527183253-8e7acdbce89d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
-golang.org/x/tools v0.0.0-20200616133436-c1934b75d054 h1:HHeAlu5H9b71C+Fx0K+1dGgVFN1DM1/wz4aoGOA5qS8=
 golang.org/x/tools v0.0.0-20200616133436-c1934b75d054/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
+golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e h1:4nW4NLDYnU28ojHaHO8OVxFHk/aQ33U01a9cjED+pzE=
+golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 gomodules.xyz/jsonpatch/v2 v2.1.0 h1:Phva6wqu+xR//Njw6iorylFFgn/z547tw5Ne3HZPQ+k=
 gomodules.xyz/jsonpatch/v2 v2.1.0/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU=
 gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485/go.mod h1:2ltnJ7xHfj0zHS40VVPYEAAMTa3ZGguvHGBSJeRWqE0=
diff --git a/pkg/docker/config.go b/pkg/docker/config.go
index 3386603..8a00e4c 100644
--- a/pkg/docker/config.go
+++ b/pkg/docker/config.go
@@ -23,16 +23,13 @@ func (v *BasicAuth) Encode(username, password string) {
 		[]byte(fmt.Sprintf("%s:%s", username, password))))
 }
 
-func (v *BasicAuth) Decode() (username, password string, err error) {
+func (v *BasicAuth) Decode() (string, string, error) {
 	bytes, err := base64.StdEncoding.DecodeString(string(*v))
 	if err != nil {
-		return
+		return "", "", err
 	}
 	split := strings.Split(string(bytes), ":")
-
-	username = split[0]
-	password = split[1]
-	return
+	return split[0], split[1], nil
 }
 
 func (v BasicAuth) String() string {
@@ -55,12 +52,13 @@ type Config struct {
 	Auths map[string]Auth `json:"auths"`
 }
 
-func (c *Config) Read(contents []byte) (err error) {
+func (c *Config) Read(contents []byte) error {
 	if err := json.Unmarshal(contents, c); err != nil {
 		return err
 	}
+	var err error
 	c.Auths, err = decodeAuths(c.Auths)
-	return
+	return err
 }
 
 func decodeAuths(auths map[string]Auth) (map[string]Auth, error) {
@@ -102,20 +100,21 @@ func GetServerFromImageRef(imageRef string) (string, error) {
 	return ref.Context().RegistryStr(), nil
 }
 
-// GetHostFromServer returns the host for the specified registry server.
+// GetServerFromDockerAuthKey returns the registry server for the specified Docker auth key.
 //
 // In ~/.docker/config.json auth keys can be specified as URLs or host names.
 // For the sake of comparison we need to normalize the registry identifier.
-func GetHostFromServer(server string) (string, error) {
-	if strings.HasPrefix(server, "http://") ||
-		strings.HasPrefix(server, "https://") {
+func GetServerFromDockerAuthKey(key string) (string, error) {
+	absoluteURL := key
 
-		parsed, err := url.Parse(server)
-		if err != nil {
-			return "", err
-		}
+	if !(strings.HasPrefix(key, "http://") || strings.HasPrefix(key, "https://")) {
+		absoluteURL = "https://" + absoluteURL
+	}
 
-		return parsed.Host, nil
+	parsed, err := url.Parse(absoluteURL)
+	if err != nil {
+		return "", err
 	}
-	return server, nil
+
+	return parsed.Host, nil
 }
diff --git a/pkg/docker/doc.go b/pkg/docker/doc.go
new file mode 100644
index 0000000..b9613ff
--- /dev/null
+++ b/pkg/docker/doc.go
@@ -0,0 +1,2 @@
+// This package provides primitives for working with Docker.
+package docker
diff --git a/pkg/kube/secrets.go b/pkg/kube/secrets.go
index 7dea304..cff4dcf 100644
--- a/pkg/kube/secrets.go
+++ b/pkg/kube/secrets.go
@@ -68,12 +68,12 @@ func MapDockerRegistryServersToAuths(imagePullSecrets []corev1.Secret) (map[stri
 		if err != nil {
 			return nil, err
 		}
-		for server, auth := range dockerConfig.Auths {
-			host, err := docker.GetHostFromServer(server)
+		for authKey, auth := range dockerConfig.Auths {
+			server, err := docker.GetServerFromDockerAuthKey(authKey)
 			if err != nil {
 				return nil, err
 			}
-			auths[host] = auth
+			auths[server] = auth
 		}
 	}
 	return auths, nil


Test patch:
diff --git a/pkg/docker/config_test.go b/pkg/docker/config_test.go
index 92d7568..28b75e7 100644
--- a/pkg/docker/config_test.go
+++ b/pkg/docker/config_test.go
@@ -4,15 +4,15 @@ import (
 	"errors"
 	"testing"
 
-	. "github.com/onsi/ginkgo"
-	. "github.com/onsi/gomega"
-
 	"github.com/aquasecurity/starboard/pkg/docker"
-	. "github.com/onsi/ginkgo/extensions/table"
 	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/require"
 )
 
-// TODO Refactor to Ginkgo+Gomega
+func TestNewBasicAuth(t *testing.T) {
+	assert.Equal(t, docker.BasicAuth("Zm9vOmJhcg=="), docker.NewBasicAuth("foo", "bar"))
+}
+
 func TestConfig_Read(t *testing.T) {
 	testCases := []struct {
 		name string
@@ -100,43 +100,81 @@ func TestConfig_Read(t *testing.T) {
 	}
 }
 
-func TestDocker(t *testing.T) {
-	RegisterFailHandler(Fail)
-	RunSpecs(t, "Docker")
-}
-
-var _ = Describe("Docker", func() {
-
-	DescribeTable("GetHostFromServer", func(server, expectedHost string) {
-		host, err := docker.GetHostFromServer(server)
-		Expect(err).ToNot(HaveOccurred())
-		Expect(host).To(Equal(expectedHost))
-	},
-		Entry("34.86.43.130.80",
-			"34.86.43.130.80", "34.86.43.130.80"),
-		Entry("core.harbor.domain:8080",
-			"core.harbor.domain:8080", "core.harbor.domain:8080"),
-		Entry("registry.aquasec.com",
-			"registry.aquasec.com", "registry.aquasec.com"),
-		Entry("https://index.docker.io/v1/",
-			"https://index.docker.io/v1/", "index.docker.io"),
-		Entry("https://registry:3780/",
-			"https://registry:3780/", "registry:3780"),
-	)
+func TestGetServerFromDockerAuthKey(t *testing.T) {
+	testCases := []struct {
+		authKey        string
+		expectedServer string
+	}{
+		{
+			authKey:        "34.86.43.13:80",
+			expectedServer: "34.86.43.13:80",
+		},
+		{
+			authKey:        "core.harbor.domain:8080",
+			expectedServer: "core.harbor.domain:8080",
+		},
+		{
+			authKey:        "rg.pl-waw.scw.cloud/starboard",
+			expectedServer: "rg.pl-waw.scw.cloud",
+		},
+		{
+			authKey:        "rg.pl-waw.scw.cloud:7777/private",
+			expectedServer: "rg.pl-waw.scw.cloud:7777",
+		},
+		{
+			authKey:        "registry.aquasec.com",
+			expectedServer: "registry.aquasec.com",
+		},
+		{
+			authKey:        "https://index.docker.io/v1/",
+			expectedServer: "index.docker.io",
+		},
+		{
+			authKey:        "https://registry:3780/",
+			expectedServer: "registry:3780",
+		},
+	}
 
-	DescribeTable("GetServerFromImageRef", func(imageRef, expectedServer string) {
-		server, err := docker.GetServerFromImageRef(imageRef)
-		Expect(err).ToNot(HaveOccurred())
-		Expect(server).To(Equal(expectedServer))
-	},
-		Entry("aquasec/trivy:0.10.0",
-			"aquasec/trivy:0.10.0", "index.docker.io"),
-		Entry("docker.io/aquasec/harbor-scanner-trivy:0.10.0",
-			"docker.io/aquasec/harbor-scanner-trivy:0.10.0", "index.docker.io"),
-		Entry("index.docker.io/aquasec/harbor-scanner-trivy:0.10.0",
-			"index.docker.io/aquasec/harbor-scanner-trivy:0.10.0", "index.docker.io"),
-		Entry("gcr.io/google-samples/hello-app:1.0",
-			"gcr.io/google-samples/hello-app:1.0", "gcr.io"),
-	)
+	for _, tc := range testCases {
+		t.Run(tc.authKey, func(t *testing.T) {
+			server, err := docker.GetServerFromDockerAuthKey(tc.authKey)
+			require.NoError(t, err)
+			assert.Equal(t, tc.expectedServer, server)
+		})
+	}
+}
 
-})
+func TestGetServerFromImageRef(t *testing.T) {
+	testCases := []struct {
+		imageRef       string
+		expectedServer string
+	}{
+		{
+			imageRef:       "nginx:1.16",
+			expectedServer: "index.docker.io",
+		},
+		{
+			imageRef:       "aquasec/trivy:0.10.0",
+			expectedServer: "index.docker.io",
+		},
+		{
+			imageRef:       "docker.io/aquasec/harbor-scanner-trivy:0.10.0",
+			expectedServer: "index.docker.io",
+		},
+		{
+			imageRef:       "index.docker.io/aquasec/harbor-scanner-trivy:0.10.0",
+			expectedServer: "index.docker.io",
+		},
+		{
+			imageRef:       "gcr.io/google-samples/hello-app:1.0",
+			expectedServer: "gcr.io",
+		},
+	}
+	for _, tc := range testCases {
+		t.Run(tc.imageRef, func(t *testing.T) {
+			server, err := docker.GetServerFromImageRef(tc.imageRef)
+			require.NoError(t, err)
+			assert.Equal(t, tc.expectedServer, server)
+		})
+	}
+}