Commit d26dd7a1 authored by Sietse Ringers's avatar Sietse Ringers

refactor: rename testdata contents

parent 53a421fd
*.test
.idea/
testdata/storage/*
!testdata/storage/cardemu.xml
testdata/tmp/*
!testdata/tmp/cardemu.xml
errors_*.go
vendor/
\ No newline at end of file
......@@ -44,7 +44,7 @@ func parseExistingStorage(t *testing.T) (*irmaclient.Client, *TestClientHandler)
handler := &TestClientHandler{t: t, c: make(chan error)}
path := test.FindTestdataFolder(t)
client, err := irmaclient.New(
filepath.Join(path, "storage", "test"),
filepath.Join(path, "tmp", "client"),
filepath.Join(path, "irma_configuration"),
handler,
)
......
......@@ -364,7 +364,7 @@ func TestRevocation(t *testing.T) {
client, _ := parseStorage(t)
iss := irma.NewIssuerIdentifier("irma-demo.MijnOverheid")
cred := irma.NewCredentialTypeIdentifier("irma-demo.MijnOverheid.root")
dbPath := filepath.Join(testdata, "storage", "revocation", cred.String())
dbPath := filepath.Join(testdata, "tmp", "revocation", cred.String())
keystore := client.Configuration.RevocationKeystore(iss)
sk, err := client.Configuration.PrivateKey(iss)
require.NoError(t, err)
......
......@@ -59,7 +59,7 @@ func StartIrmaServer(t *testing.T, updatedIrmaConf bool) {
URL: "http://localhost:48680",
Logger: logger,
SchemesPath: filepath.Join(testdata, irmaconf),
RevocationPath: filepath.Join(testdata, "storage", "revocation"),
RevocationPath: filepath.Join(testdata, "tmp", "revocation"),
})
require.NoError(t, err)
......@@ -83,7 +83,7 @@ var IrmaServerConfiguration = &requestorserver.Configuration{
Logger: logger,
SchemesPath: filepath.Join(testdata, "irma_configuration"),
IssuerPrivateKeysPath: filepath.Join(testdata, "privatekeys"),
RevocationPath: filepath.Join(testdata, "storage", "revocation"),
RevocationPath: filepath.Join(testdata, "tmp", "revocation"),
},
DisableRequestorAuthentication: true,
Port: 48682,
......@@ -95,7 +95,7 @@ var JwtServerConfiguration = &requestorserver.Configuration{
Logger: logger,
SchemesPath: filepath.Join(testdata, "irma_configuration"),
IssuerPrivateKeysPath: filepath.Join(testdata, "privatekeys"),
RevocationPath: filepath.Join(testdata, "storage", "revocation"),
RevocationPath: filepath.Join(testdata, "tmp", "revocation"),
},
Port: 48682,
DisableRequestorAuthentication: false,
......
......@@ -437,7 +437,7 @@ func TestDownloadSchemeManager(t *testing.T) {
require.Contains(t, client.Configuration.Issuers, irma.NewIssuerIdentifier("irma-demo.RU"))
require.Contains(t, client.Configuration.CredentialTypes, irma.NewCredentialTypeIdentifier("irma-demo.RU.studentCard"))
basepath := filepath.Join(test.FindTestdataFolder(t), "storage", "test", "irma_configuration", "irma-demo")
basepath := filepath.Join(test.FindTestdataFolder(t), "tmp", "client", "irma_configuration", "irma-demo")
exists, err := fs.PathExists(filepath.Join(basepath, "description.xml"))
require.NoError(t, err)
require.True(t, exists)
......
......@@ -30,7 +30,7 @@ func checkError(t *testing.T, err error) {
var schemeServer *http.Server
var badServer *http.Server
var badServerCount int
var testStorageDir = "teststorage"
var testStorageDir = "client"
func StartSchemeManagerHttpServer() {
path := FindTestdataFolder(nil)
......@@ -88,32 +88,22 @@ func FindTestdataFolder(t *testing.T) string {
// ClearTestStorage removes any output from previously run tests to ensure a clean state;
// some of the tests don't like it when there is existing state in storage.
func ClearTestStorage(t *testing.T) {
path := filepath.Join(FindTestdataFolder(t), "storage")
err := os.RemoveAll(filepath.Join(path, "test"))
checkError(t, err)
err = os.RemoveAll(filepath.Join(path, "revocation"))
checkError(t, err)
tmp := filepath.Join(FindTestdataFolder(t), "tmp")
checkError(t, os.RemoveAll(tmp))
checkError(t, fs.EnsureDirectoryExists(tmp))
}
func CreateTestStorage(t *testing.T) {
ClearTestStorage(t)
path := filepath.Join(FindTestdataFolder(t), "storage")
// EnsureDirectoryExists eventually uses mkdir from the OS which is not recursive
// so we have to create the temporary test storage by multiple function calls.
// We ignore any error possibly returned by creating the first one, because if it errors,
// then the second one certainly will as well.
_ = fs.EnsureDirectoryExists(path)
err := fs.EnsureDirectoryExists(filepath.Join(path, "test"))
checkError(t, err)
err = fs.EnsureDirectoryExists(filepath.Join(path, "revocation"))
checkError(t, err)
tmp := filepath.Join(FindTestdataFolder(t), "tmp")
checkError(t, fs.EnsureDirectoryExists(filepath.Join(tmp, "client")))
checkError(t, fs.EnsureDirectoryExists(filepath.Join(tmp, "revocation")))
}
func SetupTestStorage(t *testing.T) {
CreateTestStorage(t)
path := FindTestdataFolder(t)
err := fs.CopyDirectory(filepath.Join(path, testStorageDir), filepath.Join(path, "storage", "test"))
err := fs.CopyDirectory(filepath.Join(path, testStorageDir), filepath.Join(path, "tmp", "client"))
checkError(t, err)
}
......
package irmaclient
import (
"github.com/privacybydesign/irmago/internal/test"
"testing"
"github.com/privacybydesign/irmago/internal/test"
)
func TestConvertingLegacyStorage(t *testing.T) {
test.SetTestStorageDir("legacy_teststorage")
defer test.SetTestStorageDir("teststorage")
test.SetTestStorageDir("client_legacy")
defer test.SetTestStorageDir("client")
// Test all tests in this file with legacy storage too
t.Run("TestVerify", TestVerify)
......
......@@ -36,7 +36,7 @@ func parseStorage(t *testing.T) *Client {
func parseExistingStorage(t *testing.T) *Client {
client, err := New(
filepath.Join("..", "testdata", "storage", "test"),
filepath.Join("..", "testdata", "tmp", "client"),
filepath.Join("..", "testdata", "irma_configuration"),
&TestClientHandler{t: t},
)
......@@ -273,7 +273,7 @@ func TestWrongSchemeManager(t *testing.T) {
irmademo := irma.NewSchemeManagerIdentifier("irma-demo")
require.Contains(t, client.Configuration.SchemeManagers, irmademo)
require.NoError(t, os.Remove(filepath.Join("..", "testdata", "storage", "test", "irma_configuration", "irma-demo", "index")))
require.NoError(t, os.Remove(filepath.Join("..", "testdata", "tmp", "client", "irma_configuration", "irma-demo", "index")))
err := client.Configuration.ParseFolder()
_, ok := err.(*irma.SchemeManagerError)
......@@ -299,7 +299,7 @@ func TestCredentialInfoListNewAttribute(t *testing.T) {
require.NoError(t, client.Configuration.ParseFolder())
require.NotNil(t, client.Configuration.CredentialTypes[credid].AttributeType(attrid))
// irma-demo.RU.studentCard.newAttribute now exists in the scheme but not in the instance in the teststorage
// irma-demo.RU.studentCard.newAttribute now exists in the scheme but not in the instance in the testdata folder
for _, credinfo := range client.CredentialInfoList() {
if credinfo.ID == "studentCard" {
require.Nil(t, credinfo.Attributes[attrid])
......
......@@ -31,7 +31,7 @@ func TestConfigurationAutocopy(t *testing.T) {
test.CreateTestStorage(t)
defer test.ClearTestStorage(t)
path := filepath.Join("testdata", "storage", "test", "irma_configuration")
path := filepath.Join("testdata", "tmp", "client", "irma_configuration")
require.NoError(t, fs.CopyDirectory(filepath.Join("testdata", "irma_configuration"), path))
conf, err := NewConfigurationFromAssets(path, filepath.Join("testdata", "irma_configuration_updated"))
require.NoError(t, err)
......@@ -80,7 +80,7 @@ func TestInvalidIrmaConfigurationRestoreFromRemote(t *testing.T) {
test.CreateTestStorage(t)
defer test.ClearTestStorage(t)
conf, err := NewConfigurationFromAssets(filepath.Join("testdata", "storage", "test", "irma_configuration"),
conf, err := NewConfigurationFromAssets(filepath.Join("testdata", "tmp", "client", "irma_configuration"),
filepath.Join("testdata", "irma_configuration_invalid"))
require.NoError(t, err)
......@@ -95,7 +95,7 @@ func TestInvalidIrmaConfigurationRestoreFromAssets(t *testing.T) {
test.CreateTestStorage(t)
defer test.ClearTestStorage(t)
conf, err := NewConfigurationFromAssets(filepath.Join("testdata", "storage", "test", "irma_configuration"),
conf, err := NewConfigurationFromAssets(filepath.Join("testdata", "tmp", "client", "irma_configuration"),
filepath.Join("testdata", "irma_configuration_invalid"))
require.NoError(t, err)
......
Markdown is supported
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