Commit 9fff5e2b authored by David Venhoek's avatar David Venhoek Committed by Sietse Ringers
Browse files

Refactored keyshareserver/server.go to relieve issue with excessively long functions.

parent 4c7a66f2
......@@ -5,6 +5,7 @@ import (
"path/filepath"
"testing"
irma "github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/test"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
......@@ -25,6 +26,19 @@ func TestConfInvalidAESKey(t *testing.T) {
})
assert.NoError(t, err)
_, err = New(&Configuration{
SchemesPath: filepath.Join(testdataPath, "irma_configuration"),
URL: "http://localhost:8080/irma_keyshare_server/",
DBType: DatabaseTypeMemory,
JwtKeyID: 0,
JwtPrivateKeyFile: filepath.Join(testdataPath, "jwtkeys", "kss-sk.pem"),
StoragePrimaryKeyFile: filepath.Join(testdataPath, "keyshareStorageTestkey"),
KeyshareCredential: "test.test.mijnirma",
KeyshareAttribute: "email",
Logger: irma.Logger,
})
assert.NoError(t, err)
_, err = New(&Configuration{
SchemesPath: filepath.Join(testdataPath, "irma_configuration"),
URL: "http://localhost:8080/irma_keyshare_server/",
......
This diff is collapsed.
......@@ -11,12 +11,18 @@ import (
"testing"
"github.com/go-chi/chi"
irma "github.com/privacybydesign/irmago"
"github.com/privacybydesign/irmago/internal/keysharecore"
"github.com/privacybydesign/irmago/internal/test"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func init() {
irma.Logger.SetLevel(logrus.FatalLevel)
}
func TestServerInvalidMessage(t *testing.T) {
StartKeyshareServer(t, NewMemoryDatabase(), "")
defer StopKeyshareServer(t)
......@@ -42,19 +48,19 @@ func TestServerInvalidMessage(t *testing.T) {
reqData = bytes.NewBufferString("asdlkzdsf;lskajl;kasdjfvl;jzxclvyewr")
res, err = http.Post("http://localhost:8080/irma_keyshare_server/api/v1/prove/getCommitments", "application/json", reqData)
assert.NoError(t, err)
assert.Equal(t, 400, res.StatusCode)
assert.Equal(t, 403, res.StatusCode)
_ = res.Body.Close()
reqData = bytes.NewBufferString("[]")
res, err = http.Post("http://localhost:8080/irma_keyshare_server/api/v1/prove/getCommitments", "application/json", reqData)
assert.NoError(t, err)
assert.Equal(t, 400, res.StatusCode)
assert.Equal(t, 403, res.StatusCode)
_ = res.Body.Close()
reqData = bytes.NewBufferString("asdlkzdsf;lskajl;kasdjfvl;jzxclvyewr")
res, err = http.Post("http://localhost:8080/irma_keyshare_server/api/v1/prove/getResponse", "application/json", reqData)
assert.NoError(t, err)
assert.Equal(t, 400, res.StatusCode)
assert.Equal(t, 403, res.StatusCode)
_ = res.Body.Close()
}
......@@ -465,6 +471,7 @@ func StartKeyshareServer(t *testing.T, db KeyshareDB, emailserver string) {
VerificationURL: map[string]string{
"en": "http://example.com/verify/",
},
Logger: irma.Logger,
})
require.NoError(t, err)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment