Commit 4fac4ae0 authored by Loïck Bonniot's avatar Loïck Bonniot

[tests] Use testify instead of bmizerany

parent 1b2f1b5d
Pipeline #687 passed with stage
...@@ -5,5 +5,6 @@ go get -u github.com/golang/protobuf/proto ...@@ -5,5 +5,6 @@ go get -u github.com/golang/protobuf/proto
go get -u github.com/golang/protobuf/protoc-gen-go go get -u github.com/golang/protobuf/protoc-gen-go
go get -u google.golang.org/grpc go get -u google.golang.org/grpc
go get -u github.com/pborman/uuid go get -u github.com/pborman/uuid
go get -u github.com/bmizerany/assert go get -u github.com/stretchr/testify/assert
go get -u golang.org/x/crypto/ssh/terminal go get -u golang.org/x/crypto/ssh/terminal
...@@ -6,7 +6,7 @@ import ( ...@@ -6,7 +6,7 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
"github.com/bmizerany/assert" "github.com/stretchr/testify/assert"
) )
var path = os.TempDir() var path = os.TempDir()
...@@ -38,27 +38,27 @@ func TestSaveToDisk(t *testing.T) { ...@@ -38,27 +38,27 @@ func TestSaveToDisk(t *testing.T) {
data[1] = 'o' data[1] = 'o'
data[2] = 'o' data[2] = 'o'
err := SaveToDisk(data, ffoo) err := SaveToDisk(data, ffoo)
assert.T(t, err == nil, "An error has been raised") assert.True(t, err == nil, "An error has been raised")
assert.T(t, FileExists(ffoo), "foo.txt should be present") assert.True(t, FileExists(ffoo), "foo.txt should be present")
} }
// Save a string on the disk // Save a string on the disk
func TestSaveStringToDisk(t *testing.T) { func TestSaveStringToDisk(t *testing.T) {
s := "bar" s := "bar"
err := SaveStringToDisk(s, fbar) err := SaveStringToDisk(s, fbar)
assert.T(t, err == nil, "An error has been raised") assert.True(t, err == nil, "An error has been raised")
assert.T(t, FileExists(fbar), "bar.txt should be present") assert.True(t, FileExists(fbar), "bar.txt should be present")
} }
// DeleteQuietly should never raise an error, even with non-existant file // DeleteQuietly should never raise an error, even with non-existant file
func TestDeleteQuietly(t *testing.T) { func TestDeleteQuietly(t *testing.T) {
s := "baz" s := "baz"
_ = SaveStringToDisk(s, fbaz) _ = SaveStringToDisk(s, fbaz)
assert.T(t, FileExists(fbaz), "baz.txt should be present") assert.True(t, FileExists(fbaz), "baz.txt should be present")
DeleteQuietly(fbaz) DeleteQuietly(fbaz)
assert.T(t, !FileExists(fbaz), "baz.txt should not be present") assert.True(t, !FileExists(fbaz), "baz.txt should not be present")
// Assert it does not panic when deleting an inexistant file // Assert it does not panic when deleting an inexistant file
DeleteQuietly("dummy") DeleteQuietly("dummy")
...@@ -68,12 +68,12 @@ func TestDeleteQuietly(t *testing.T) { ...@@ -68,12 +68,12 @@ func TestDeleteQuietly(t *testing.T) {
func TestReadFile(t *testing.T) { func TestReadFile(t *testing.T) {
s := "qux" s := "qux"
_ = SaveStringToDisk(s, fqux) _ = SaveStringToDisk(s, fqux)
assert.T(t, FileExists(fqux), "qux.txt should be present") assert.True(t, FileExists(fqux), "qux.txt should be present")
data, err := ReadFile(fqux) data, err := ReadFile(fqux)
if err != nil { if err != nil {
fmt.Println(err.Error()) fmt.Println(err.Error())
assert.T(t, err == nil, "An error has been raised while reading the file") assert.True(t, err == nil, "An error has been raised while reading the file")
} }
assert.Equal(t, s, fmt.Sprintf("%s", data), "Expected qux, received ", fmt.Sprintf("%s", data)) assert.Equal(t, s, fmt.Sprintf("%s", data), "Expected qux, received ", fmt.Sprintf("%s", data))
......
...@@ -4,7 +4,7 @@ import ( ...@@ -4,7 +4,7 @@ import (
"testing" "testing"
"dfss/dfssp/api" "dfss/dfssp/api"
"github.com/bmizerany/assert" "github.com/stretchr/testify/assert"
) )
func TestEvaluateErrorCodeResponse(t *testing.T) { func TestEvaluateErrorCodeResponse(t *testing.T) {
......
...@@ -4,7 +4,7 @@ import ( ...@@ -4,7 +4,7 @@ import (
"io/ioutil" "io/ioutil"
"testing" "testing"
"github.com/bmizerany/assert" "github.com/stretchr/testify/assert"
) )
func TestUnmarshalDFSSFile(t *testing.T) { func TestUnmarshalDFSSFile(t *testing.T) {
......
...@@ -4,7 +4,7 @@ import ( ...@@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/bmizerany/assert" "github.com/stretchr/testify/assert"
) )
func TestFindNextIndex(t *testing.T) { func TestFindNextIndex(t *testing.T) {
......
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
"github.com/bmizerany/assert" "github.com/stretchr/testify/assert"
) )
var crtFixture = `-----BEGIN CERTIFICATE----- var crtFixture = `-----BEGIN CERTIFICATE-----
...@@ -34,9 +34,9 @@ func TestGenerateKeys(t *testing.T) { ...@@ -34,9 +34,9 @@ func TestGenerateKeys(t *testing.T) {
fkey := filepath.Join(path, "genKey.pem") fkey := filepath.Join(path, "genKey.pem")
rsa, err := GenerateKeys(512, "pwd", fkey) rsa, err := GenerateKeys(512, "pwd", fkey)
assert.T(t, err == nil, "An error has been raised during generation") assert.True(t, err == nil, "An error has been raised during generation")
assert.T(t, rsa != nil, "RSA key should not be nil") assert.True(t, rsa != nil, "RSA key should not be nil")
assert.T(t, common.FileExists(fkey), "File is missing") assert.True(t, common.FileExists(fkey), "File is missing")
common.DeleteQuietly(fkey) common.DeleteQuietly(fkey)
} }
...@@ -46,13 +46,13 @@ func TestCertificateRequest(t *testing.T) { ...@@ -46,13 +46,13 @@ func TestCertificateRequest(t *testing.T) {
rsa, err := GenerateKeys(512, "pwd", fkey) rsa, err := GenerateKeys(512, "pwd", fkey)
defer common.DeleteQuietly(fkey) defer common.DeleteQuietly(fkey)
assert.T(t, err == nil, "An error has been raised during generation") assert.True(t, err == nil, "An error has been raised during generation")
assert.T(t, rsa != nil, "RSA key should not be nil") assert.True(t, rsa != nil, "RSA key should not be nil")
assert.T(t, common.FileExists(fkey), "File is missing") assert.True(t, common.FileExists(fkey), "File is missing")
csr, err := GenerateCertificateRequest("France", "DFSS", "DFSS_C", "dfssc@dfss.org", rsa) csr, err := GenerateCertificateRequest("France", "DFSS", "DFSS_C", "dfssc@dfss.org", rsa)
assert.T(t, err == nil, "An error has been raised during generation of certificate request") assert.True(t, err == nil, "An error has been raised during generation of certificate request")
assert.T(t, csr != "", "Certificate request should not be nil") assert.True(t, csr != "", "Certificate request should not be nil")
} }
// Test saving rsa key on the disk // Test saving rsa key on the disk
...@@ -62,18 +62,18 @@ func TestDumpingKey(t *testing.T) { ...@@ -62,18 +62,18 @@ func TestDumpingKey(t *testing.T) {
rsa, err := GenerateKeys(512, "pwd", fkey) rsa, err := GenerateKeys(512, "pwd", fkey)
defer common.DeleteQuietly(fkey) defer common.DeleteQuietly(fkey)
assert.T(t, err == nil, "An error has been raised during generation") assert.True(t, err == nil, "An error has been raised during generation")
assert.T(t, rsa != nil, "RSA key should not be nil") assert.True(t, rsa != nil, "RSA key should not be nil")
assert.T(t, common.FileExists(fkey), "File is missing") assert.True(t, common.FileExists(fkey), "File is missing")
k, err := GetPrivateKey(fkey, "") k, err := GetPrivateKey(fkey, "")
assert.T(t, err != nil, "An error should have been raised") assert.True(t, err != nil, "An error should have been raised")
k, err = GetPrivateKey(fkey, "dummypwd") k, err = GetPrivateKey(fkey, "dummypwd")
assert.T(t, err != nil, "An error should have been raised") assert.True(t, err != nil, "An error should have been raised")
k, err = GetPrivateKey(fkey, "pwd") k, err = GetPrivateKey(fkey, "pwd")
assert.T(t, err == nil, "No error should have been raised") assert.True(t, err == nil, "No error should have been raised")
assert.Equal(t, *rsa, *k, "Keys should be equal") assert.Equal(t, *rsa, *k, "Keys should be equal")
} }
...@@ -85,14 +85,14 @@ func TestDumpCrt(t *testing.T) { ...@@ -85,14 +85,14 @@ func TestDumpCrt(t *testing.T) {
err := SaveCertificate(crtFixture, fcert) err := SaveCertificate(crtFixture, fcert)
defer common.DeleteQuietly(fcert) defer common.DeleteQuietly(fcert)
assert.T(t, err == nil, "An error has been raised during saving") assert.True(t, err == nil, "An error has been raised during saving")
assert.T(t, common.FileExists(fcert), "File is missing") assert.True(t, common.FileExists(fcert), "File is missing")
data, err := common.ReadFile(fcert) data, err := common.ReadFile(fcert)
assert.T(t, err == nil, "An error has been raised while reading file") assert.True(t, err == nil, "An error has been raised while reading file")
assert.Equal(t, crtFixture, fmt.Sprintf("%s", data), "Certificates are not equal") assert.Equal(t, crtFixture, fmt.Sprintf("%s", data), "Certificates are not equal")
crt, err := GetCertificate(fcert) crt, err := GetCertificate(fcert)
assert.T(t, err == nil, "An error has been raised while parsing certificate") assert.True(t, err == nil, "An error has been raised while parsing certificate")
assert.T(t, crt != nil, "Certificate is nil") assert.True(t, crt != nil, "Certificate is nil")
} }
...@@ -10,7 +10,7 @@ import ( ...@@ -10,7 +10,7 @@ import (
"dfss/auth" "dfss/auth"
"dfss/mockp/server" "dfss/mockp/server"
"github.com/bmizerany/assert" "github.com/stretchr/testify/assert"
) )
var path = filepath.Join("..", "testdata") var path = filepath.Join("..", "testdata")
......
...@@ -6,7 +6,7 @@ import ( ...@@ -6,7 +6,7 @@ import (
"os" "os"
"testing" "testing"
"github.com/bmizerany/assert" "github.com/stretchr/testify/assert"
) )
func TestFetchContract(t *testing.T) { func TestFetchContract(t *testing.T) {
......
...@@ -5,7 +5,7 @@ import ( ...@@ -5,7 +5,7 @@ import (
"dfss/dfssp/contract" "dfss/dfssp/contract"
"github.com/bmizerany/assert" "github.com/stretchr/testify/assert"
) )
func TestFindId(t *testing.T) { func TestFindId(t *testing.T) {
......
...@@ -3,23 +3,23 @@ package user ...@@ -3,23 +3,23 @@ package user
import ( import (
"dfss/dfssc/common" "dfss/dfssc/common"
"fmt" "fmt"
"github.com/bmizerany/assert" "github.com/stretchr/testify/assert"
"os" "os"
"testing" "testing"
) )
func TestAuthenticationValidation(t *testing.T) { func TestAuthenticationValidation(t *testing.T) {
_, err := NewAuthManager("fca", fcert, addrPort, "dummy", "token") _, err := NewAuthManager("fca", fcert, addrPort, "dummy", "token")
assert.T(t, err != nil, "Email is invalid") assert.True(t, err != nil, "Email is invalid")
f, _ := os.Create(fcert) f, _ := os.Create(fcert)
_ = f.Close() _ = f.Close()
_, err = NewAuthManager("fca", fcert, addrPort, "mail@mail.mail", "token") _, err = NewAuthManager("fca", fcert, addrPort, "mail@mail.mail", "token")
assert.T(t, err != nil, "Cert file already there") assert.True(t, err != nil, "Cert file already there")
_ = os.Remove(fcert) _ = os.Remove(fcert)
_, err = NewAuthManager("fca", fcert, addrPort, "mail@mail.mail", "token") _, err = NewAuthManager("fca", fcert, addrPort, "mail@mail.mail", "token")
assert.T(t, err != nil, "CA file not there") assert.True(t, err != nil, "CA file not there")
_, err = NewAuthManager(fca, fcert, addrPort, "mail@mail.mail", "token") _, err = NewAuthManager(fca, fcert, addrPort, "mail@mail.mail", "token")
assert.Equal(t, err, nil) assert.Equal(t, err, nil)
......
...@@ -8,7 +8,7 @@ import ( ...@@ -8,7 +8,7 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
"github.com/bmizerany/assert" "github.com/stretchr/testify/assert"
) )
const certFixture = `-----BEGIN CERTIFICATE----- const certFixture = `-----BEGIN CERTIFICATE-----
...@@ -46,15 +46,15 @@ func TestInvalidFiles(t *testing.T) { ...@@ -46,15 +46,15 @@ func TestInvalidFiles(t *testing.T) {
defer deleteFiles(keyFile, certFile, "invalidConf.pem") defer deleteFiles(keyFile, certFile, "invalidConf.pem")
_, err := NewConfig("inexistantKey", "inexistantCert") _, err := NewConfig("inexistantKey", "inexistantCert")
assert.Tf(t, err != nil, "No key file nor cert file, expected error") assert.True(t, err != nil, "No key file nor cert file, expected error")
_ = common.SaveStringToDisk(fmt.Sprintf("%s", []byte(keyFixture)), keyFile) _ = common.SaveStringToDisk(fmt.Sprintf("%s", []byte(keyFixture)), keyFile)
_, err = NewConfig(keyFile, "inexistantCert") _, err = NewConfig(keyFile, "inexistantCert")
assert.Tf(t, err != nil, "No cert file, expected error") assert.True(t, err != nil, "No cert file, expected error")
_ = security.SaveCertificate(fmt.Sprintf("%s", []byte(certFixture)), certFile) _ = security.SaveCertificate(fmt.Sprintf("%s", []byte(certFixture)), certFile)
_, err = NewConfig(keyFile, certFile) _, err = NewConfig(keyFile, certFile)
assert.Tf(t, err == nil, "Expected no error, files are present and valid") assert.True(t, err == nil, "Expected no error, files are present and valid")
} }
// TestErrorDumpingConfig checks the error that may be raised while dumping the configuration to the disk // TestErrorDumpingConfig checks the error that may be raised while dumping the configuration to the disk
...@@ -64,25 +64,25 @@ func TestErrorDumpingConfig(t *testing.T) { ...@@ -64,25 +64,25 @@ func TestErrorDumpingConfig(t *testing.T) {
defer deleteFiles(keyFile, certFile, "invalidConf.pem") defer deleteFiles(keyFile, certFile, "invalidConf.pem")
err := common.SaveStringToDisk(fmt.Sprintf("%s", []byte(keyFixture)), keyFile) err := common.SaveStringToDisk(fmt.Sprintf("%s", []byte(keyFixture)), keyFile)
assert.Tf(t, err == nil, "Expected no error, file is present") assert.True(t, err == nil, "Expected no error, file is present")
err = security.SaveCertificate(fmt.Sprintf("%s", []byte(certFixture)), certFile) err = security.SaveCertificate(fmt.Sprintf("%s", []byte(certFixture)), certFile)
assert.Tf(t, err == nil, "Expected no error, cert is valid") assert.True(t, err == nil, "Expected no error, cert is valid")
config, err := NewConfig(keyFile, certFile) config, err := NewConfig(keyFile, certFile)
assert.Tf(t, err == nil, "Expected no error, files are present and valid") assert.True(t, err == nil, "Expected no error, files are present and valid")
err = config.SaveConfigToFile("file", "abc", "") err = config.SaveConfigToFile("file", "abc", "")
assert.Tf(t, err != nil, "Expected an error, passphrase is too short (< 4 char)") assert.True(t, err != nil, "Expected an error, passphrase is too short (< 4 char)")
err = config.SaveConfigToFile(keyFile, "passphrase", "") err = config.SaveConfigToFile(keyFile, "passphrase", "")
assert.Tf(t, err != nil, "Expected an error, file is already there") assert.True(t, err != nil, "Expected an error, file is already there")
common.DeleteQuietly(keyFile) common.DeleteQuietly(keyFile)
_ = common.SaveStringToDisk("Invalid key", keyFile) _ = common.SaveStringToDisk("Invalid key", keyFile)
config, _ = NewConfig(keyFile, certFile) config, _ = NewConfig(keyFile, certFile)
err = config.SaveConfigToFile("file", "passphrase", "passphrase") err = config.SaveConfigToFile("file", "passphrase", "passphrase")
assert.Tf(t, err != nil, "Expected an error, private key is invalid") assert.True(t, err != nil, "Expected an error, private key is invalid")
common.DeleteQuietly(certFile) common.DeleteQuietly(certFile)
common.DeleteQuietly(keyFile) common.DeleteQuietly(keyFile)
...@@ -90,7 +90,7 @@ func TestErrorDumpingConfig(t *testing.T) { ...@@ -90,7 +90,7 @@ func TestErrorDumpingConfig(t *testing.T) {
_ = common.SaveStringToDisk("Invalid certificate", certFile) _ = common.SaveStringToDisk("Invalid certificate", certFile)
config, _ = NewConfig(keyFile, certFile) config, _ = NewConfig(keyFile, certFile)
err = config.SaveConfigToFile("file", "passphrase", "passphrase") err = config.SaveConfigToFile("file", "passphrase", "passphrase")
assert.Tf(t, err != nil, "Expected an error, certificate is invalid") assert.True(t, err != nil, "Expected an error, certificate is invalid")
} }
...@@ -103,21 +103,21 @@ func TestDumpingFile(t *testing.T) { ...@@ -103,21 +103,21 @@ func TestDumpingFile(t *testing.T) {
defer deleteFiles(keyFile, certFile, configPath) defer deleteFiles(keyFile, certFile, configPath)
err := common.SaveStringToDisk(fmt.Sprintf("%s", []byte(keyFixture)), keyFile) err := common.SaveStringToDisk(fmt.Sprintf("%s", []byte(keyFixture)), keyFile)
assert.Tf(t, err == nil, "Expected no error, file is present") assert.True(t, err == nil, "Expected no error, file is present")
err = security.SaveCertificate(fmt.Sprintf("%s", []byte(certFixture)), certFile) err = security.SaveCertificate(fmt.Sprintf("%s", []byte(certFixture)), certFile)
assert.Tf(t, err == nil, "Expected no error, cert is valid") assert.True(t, err == nil, "Expected no error, cert is valid")
config, err := NewConfig(keyFile, certFile) config, err := NewConfig(keyFile, certFile)
assert.Tf(t, err == nil, "Expected no error, files are present and valid") assert.True(t, err == nil, "Expected no error, files are present and valid")
err = config.SaveConfigToFile(configPath, "passphrase", "") err = config.SaveConfigToFile(configPath, "passphrase", "")
assert.Tf(t, err == nil, "Expected no error, config is valid") assert.True(t, err == nil, "Expected no error, config is valid")
assert.Tf(t, common.FileExists(configPath), "Expected a config file present") assert.True(t, common.FileExists(configPath), "Expected a config file present")
_, err = common.ReadFile(configPath) _, err = common.ReadFile(configPath)
assert.Tf(t, err == nil, "Expected no error, config is present") assert.True(t, err == nil, "Expected no error, config is present")
} }
// TestErrorDecodeFile tries to decode a configuration file and checks the errors raised // TestErrorDecodeFile tries to decode a configuration file and checks the errors raised
...@@ -132,19 +132,19 @@ func TestErrorDecodeFile(t *testing.T) { ...@@ -132,19 +132,19 @@ func TestErrorDecodeFile(t *testing.T) {
_ = security.SaveCertificate(fmt.Sprintf("%s", []byte(certFixture)), certFile) _ = security.SaveCertificate(fmt.Sprintf("%s", []byte(certFixture)), certFile)
_, err := DecodeConfiguration("inexistantFile", "passphrase", "") _, err := DecodeConfiguration("inexistantFile", "passphrase", "")
assert.Tf(t, err != nil, "File is invalid, impossible to decode configuration") assert.True(t, err != nil, "File is invalid, impossible to decode configuration")
_, err = DecodeConfiguration(keyFile, "pas", "") _, err = DecodeConfiguration(keyFile, "pas", "")
assert.Tf(t, err != nil, "Passphrase is invalid, should be at least 4 char long") assert.True(t, err != nil, "Passphrase is invalid, should be at least 4 char long")
config, err := NewConfig(keyFile, certFile) config, err := NewConfig(keyFile, certFile)
assert.Tf(t, err == nil, "Expected no error, files are present and valid") assert.True(t, err == nil, "Expected no error, files are present and valid")
err = config.SaveConfigToFile(configPath, "passphrase", "") err = config.SaveConfigToFile(configPath, "passphrase", "")
assert.Tf(t, err == nil, "Expected no error, config is valid") assert.True(t, err == nil, "Expected no error, config is valid")
config, err = DecodeConfiguration(configPath, "pass", "") config, err = DecodeConfiguration(configPath, "pass", "")
assert.Tf(t, err != nil, "Expected error, wrong passphrase") assert.True(t, err != nil, "Expected error, wrong passphrase")
} }
...@@ -160,18 +160,18 @@ func TestDecodeConfig(t *testing.T) { ...@@ -160,18 +160,18 @@ func TestDecodeConfig(t *testing.T) {
_ = security.SaveCertificate(fmt.Sprintf("%s", []byte(certFixture)), certFile) _ = security.SaveCertificate(fmt.Sprintf("%s", []byte(certFixture)), certFile)
config, err := NewConfig(keyFile, certFile) config, err := NewConfig(keyFile, certFile)
assert.Tf(t, err == nil, "Expected no error, files are present and valid") assert.True(t, err == nil, "Expected no error, files are present and valid")
err = config.SaveConfigToFile(configPath, "passphrase", "") err = config.SaveConfigToFile(configPath, "passphrase", "")
assert.Tf(t, err == nil, "Expected no error, config is valid") assert.True(t, err == nil, "Expected no error, config is valid")
decoded, err := DecodeConfiguration(configPath, "", "passphrase") decoded, err := DecodeConfiguration(configPath, "", "passphrase")
assert.Tf(t, err == nil, "Expected no error, config should have been decodedi") assert.True(t, err == nil, "Expected no error, config should have been decodedi")
assert.Equalf(t, config.KeyFile, decoded.KeyFile, "Wrong keyFile parameter") assert.Equal(t, config.KeyFile, decoded.KeyFile, "Wrong keyFile parameter")
assert.Equalf(t, config.KeyData, decoded.KeyData, "Wrong keyData parameter") assert.Equal(t, config.KeyData, decoded.KeyData, "Wrong keyData parameter")
assert.Equalf(t, config.CertFile, decoded.CertFile, "Wrong certFile parameter") assert.Equal(t, config.CertFile, decoded.CertFile, "Wrong certFile parameter")
assert.Equalf(t, config.CertData, decoded.CertData, "Wrong certData parameter") assert.Equal(t, config.CertData, decoded.CertData, "Wrong certData parameter")
} }
// TestSaveFilesToDisk tries to create the certificate and private key on the disk from // TestSaveFilesToDisk tries to create the certificate and private key on the disk from
...@@ -187,22 +187,22 @@ func TestSaveFilesToDisk(t *testing.T) { ...@@ -187,22 +187,22 @@ func TestSaveFilesToDisk(t *testing.T) {
_ = security.SaveCertificate(fmt.Sprintf("%s", []byte(certFixture)), certFile) _ = security.SaveCertificate(fmt.Sprintf("%s", []byte(certFixture)), certFile)
config, err := NewConfig(keyFile, certFile) config, err := NewConfig(keyFile, certFile)
assert.Tf(t, err == nil, "Expected no error, files are present and valid") assert.True(t, err == nil, "Expected no error, files are present and valid")
err = config.SaveUserInformations() err = config.SaveUserInformations()
assert.Tf(t, err != nil, "Expected an error, files are already present") assert.True(t, err != nil, "Expected an error, files are already present")
common.DeleteQuietly(keyFile) common.DeleteQuietly(keyFile)
err = config.SaveUserInformations() err = config.SaveUserInformations()
assert.Tf(t, err != nil, "Expected an error, certificate file is already present") assert.True(t, err != nil, "Expected an error, certificate file is already present")
common.DeleteQuietly(certFile) common.DeleteQuietly(certFile)
err = config.SaveUserInformations() err = config.SaveUserInformations()
assert.Tf(t, err == nil, "No error expected, files are not here") assert.True(t, err == nil, "No error expected, files are not here")
assert.Tf(t, common.FileExists(keyFile), "Expected private key file") assert.True(t, common.FileExists(keyFile), "Expected private key file")
assert.Tf(t, common.FileExists(certFile), "Expected certificate file") assert.True(t, common.FileExists(certFile), "Expected certificate file")
} }