aboutsummaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorNiall Sheridan <nsheridan@gmail.com>2017-01-05 23:28:26 +0000
committerNiall Sheridan <nsheridan@gmail.com>2017-01-05 23:28:26 +0000
commit9e9a7d50970f1424245d88169de82988fd57e112 (patch)
tree25aca2f5e18fe3ff454af34d5d75f8c5204d81fb /server
parent8066efd45861e7c024fc1daabc6d002266a527e7 (diff)
Move GetPublicKey to the shared `lib` package
Diffstat (limited to 'server')
-rw-r--r--server/store/store.go4
-rw-r--r--server/util/util.go10
-rw-r--r--server/util/util_test.go16
3 files changed, 2 insertions, 28 deletions
diff --git a/server/store/store.go b/server/store/store.go
index a447e72..8af77e3 100644
--- a/server/store/store.go
+++ b/server/store/store.go
@@ -5,8 +5,8 @@ import (
"golang.org/x/crypto/ssh"
+ "github.com/nsheridan/cashier/lib"
"github.com/nsheridan/cashier/server/config"
- "github.com/nsheridan/cashier/server/util"
)
// New returns a new configured database.
@@ -54,6 +54,6 @@ func parseCertificate(cert *ssh.Certificate) *CertRecord {
Principals: cert.ValidPrincipals,
CreatedAt: parseTime(cert.ValidAfter),
Expires: parseTime(cert.ValidBefore),
- Raw: util.GetPublicKey(cert),
+ Raw: lib.GetPublicKey(cert),
}
}
diff --git a/server/util/util.go b/server/util/util.go
deleted file mode 100644
index 10f5eca..0000000
--- a/server/util/util.go
+++ /dev/null
@@ -1,10 +0,0 @@
-package util
-
-import "golang.org/x/crypto/ssh"
-
-// GetPublicKey marshals a ssh certificate to a string.
-func GetPublicKey(cert *ssh.Certificate) string {
- marshaled := ssh.MarshalAuthorizedKey(cert)
- // Strip trailing newline
- return string(marshaled[:len(marshaled)-1])
-}
diff --git a/server/util/util_test.go b/server/util/util_test.go
deleted file mode 100644
index d294d86..0000000
--- a/server/util/util_test.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package util
-
-import (
- "testing"
-
- "github.com/nsheridan/cashier/testdata"
- "golang.org/x/crypto/ssh"
-)
-
-func TestGetPublicKey(t *testing.T) {
- t.Parallel()
- c, _, _, _, _ := ssh.ParseAuthorizedKey(testdata.Cert)
- if GetPublicKey(c.(*ssh.Certificate)) != string(testdata.Cert) {
- t.Fail()
- }
-}