Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor tests #28

Merged
merged 4 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*.pem
/*.pem
!ca.pem
uzi-did-x509-issuer
c.out
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.23.1
require (
github.com/alecthomas/kong v1.4.0
github.com/google/uuid v1.6.0
github.com/huandu/go-clone v1.7.2
github.com/lestrrat-go/jwx/v2 v2.1.2
github.com/nuts-foundation/go-did v0.15.0
github.com/stretchr/testify v1.9.0
Expand Down
6 changes: 0 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c=
github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U=
github.com/huandu/go-clone v1.7.2 h1:3+Aq0Ed8XK+zKkLjE2dfHg0XrpIfcohBE1K+c8Usxoo=
github.com/huandu/go-clone v1.7.2/go.mod h1:ReGivhG6op3GYr+UY3lS6mxjKp7MIGTknuU5TbTVaXE=
github.com/lestrrat-go/blackmagic v1.0.2 h1:Cg2gVSc9h7sz9NOByczrbUvLopQmXrfFx//N+AkAr5k=
github.com/lestrrat-go/blackmagic v1.0.2/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU=
github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE=
Expand Down Expand Up @@ -48,7 +44,6 @@ github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr
github.com/shengdoushi/base58 v1.0.0 h1:tGe4o6TmdXFJWoI31VoSWvuaKxf0Px3gqa3sUWhAxBs=
github.com/shengdoushi/base58 v1.0.0/go.mod h1:m5uIILfzcKMw6238iWAhP4l3s5+uXyF3+bJKUNhAL9I=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
Expand All @@ -59,7 +54,6 @@ golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
26 changes: 25 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func main() {
fmt.Println(err)
os.Exit(-1)
}
fmt.Println("VC result:")
err = printLineAndFlush(jwt)
if err != nil {
fmt.Println(err)
Expand Down Expand Up @@ -123,5 +124,28 @@ func printLineAndFlush(jwt string) error {
}

func issueVc(vc VC) (string, error) {
return uzi_vc_issuer.Issue(vc.CertificateFile, vc.SigningKey, vc.SubjectDID, vc.Test, vc.IncludePermanent, vc.SubjectAttributes)
chain, err := uzi_vc_issuer.NewValidCertificateChain(vc.CertificateFile)
if err != nil {
return "", err
}

key, err := uzi_vc_issuer.NewPrivateKey(vc.SigningKey)
if err != nil {
return "", err
}

subject, err := uzi_vc_issuer.NewSubjectDID(vc.SubjectDID)
if err != nil {
return "", err
}

credential, err := uzi_vc_issuer.Issue(chain, key, subject,
uzi_vc_issuer.SubjectAttributes(vc.SubjectAttributes...),
uzi_vc_issuer.AllowTestUraCa(vc.Test))

if err != nil {
return "", err
}

return credential.Raw(), nil
}
27 changes: 27 additions & 0 deletions uzi_vc_issuer/testdata/signing_key.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN PRIVATE KEY-----
MIIEpAIBAAKCAQEA0+LyiNeyaWUCHyzRDKG6+a+btQXCiuKX7cRzLWRp3Dc0v4Bv
8GCgNNSHRwHz+KbadpGuBebvD6f4GvwDA9PjdJ3xjjRi0aF1hYmzPmnrsYxDtuZV
A1IU0BTBbfQcQ9yXpUEtPZwDvf3/J9OlckNrEVOKZzG7Bw/0rk4OGt4D4lOkmhlg
yvWHou59J9/ARrRaRl1b5bcjzrUnEbD6B8w3G6xino57/M2cvExFu3dChV6eABDD
hwE+WsSK2CaijXMiCD25xg80nq9gzTIJEVlSEYilf4DthdyaRae4WV74/x5H3EZI
wRHr+8A2rZmNXivpUuDXAtTH5BsJibujfeYfJQIDAQABAoIBAQCouZC+bVyR1rBA
2PRC5cq5JyCLnuGSrOukl4nL/Kjbhk6HrCP3O0p3p0Ftxt1bBKr0Pf9gjcuSIQRN
oJ5Z/vGiHF+NCKQkIDkwND26lqfrwzDsxS+vLD6Mj+qTvw5+73sGSgdXhxPnyAnV
0hBuE8d/jZGpqQ0wi4EhB+DtfhuDrfp4ZdQXFynsTi/MuttOmiu4r/aVqYS4uhjh
NO4EvnfDpyUVxpdy78t8H16+ghyAI5fnELqxq7Gk1EIrFYtUfnEfJKyB33ZLZrkL
imIVc5Qt90zObFFljDrM26cr7OnKopApO98dREi13aLio2QeKX3OkUOIlcGgwAN0
Fhpvv7jBAoGBAOodh925HBKiIJlE3C5oYwnalVLnr7fVffACuCyxE2oxPv7jl1qP
XnJ1i5DIgwyqUBzLbgo6Jf9fVTK/0lzx0rMIDBTiMJE+YE7UZ1/BFsdql0AnkHP9
S21E3vdVPl1vcQMbc9fokkGYayMDkLeToLKVIv/76IZkQ1iS6vpWwQqVAoGBAOex
eNmXms9FSx2aw3IdAHnS11u+cvn60hYmvVod10kFzhO2l17WBtlWSzysWchEWzX3
u0bW95LIuRerlj463jqw89ecEadmOsn382Icpsf2ZhtswyeAIa7u0/y965xX6j0+
dbx1GQ8Ftdt9nozb/o41sF5/DjrYWmQFmOrvfy5RAoGAY0/9p7/zua/O9lWwtXsQ
sEhqWc3wy6IkF2F/8W14l+6mE4hGV2NEJHfaqaN1fDTvYRem6W27WrZ9NNcMjOME
h2/deCpvgd2dCzOtWoBVgmikGtHtxFZp3cN+dhtSJl606SWHIcsF6A+ZOzQy+r0E
SV1ciIy7Ge+EZhmE1odgwnUCgYBatXa06c/oOh7Qdljygjw/dbZu6r8k83fwyDX1
5Bz3L9igiyn0LSL9T/WgyXFVIL39AQJHF75Rr1gX1ku6DV4X6FNvJGEdAr8dd3/H
96OsQeFz9z7oZhfJ3yMLnmdyDFFerOd3YvjukrPCPQon57Ffh9GHDYNKso2g/zgB
Msa+IQKBgQDEpBtnP0+oJCAlUb3bOqJY7+5B4GsBCbNgV2rpa362Iyx5OPKLdGgV
U/G3jdZeqrzLJsFPfU41jOFiL76pDsH0rCUK1fQJkAhrux/k/5rYWhgfziZYwiNT
RccjKo7mMgg/vPjbw/wtLhvLTstfMQl5OLJ0f/vROR24ThAdNiFGWw==
-----END PRIVATE KEY-----
80 changes: 80 additions & 0 deletions uzi_vc_issuer/testdata/valid_chain.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
-----BEGIN CERTIFICATE-----
MIIDjTCCAnWgAwIBAgICAMQwDQYJKoZIhvcNAQELBQAwIjEgMB4GA1UEChMXSW50
ZXJtZWRpYXRlIENBIExldmVsIDIwHhcNMjQxMjAzMTQ1NTIyWhcNMjUwMTAyMTQ1
NTIyWjAlMREwDwYDVQQKEwhGYXV4Q2FyZTEQMA4GA1UEBRMHMTExMTExMTCCASIw
DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANPi8ojXsmllAh8s0Qyhuvmvm7UF
woril+3Ecy1kadw3NL+Ab/BgoDTUh0cB8/im2naRrgXm7w+n+Br8AwPT43Sd8Y40
YtGhdYWJsz5p67GMQ7bmVQNSFN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