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
go get -u github.com/golang/protobuf/protoc-gen-go
go get -u google.golang.org/grpc
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
......@@ -6,7 +6,7 @@ import (
"path/filepath"
"testing"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
)
var path = os.TempDir()
......@@ -38,27 +38,27 @@ func TestSaveToDisk(t *testing.T) {
data[1] = 'o'
data[2] = 'o'
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
func TestSaveStringToDisk(t *testing.T) {
s := "bar"
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
func TestDeleteQuietly(t *testing.T) {
s := "baz"
_ = 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)
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
DeleteQuietly("dummy")
......@@ -68,12 +68,12 @@ func TestDeleteQuietly(t *testing.T) {
func TestReadFile(t *testing.T) {
s := "qux"
_ = 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)
if err != nil {
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))
......
......@@ -4,7 +4,7 @@ import (
"testing"
"dfss/dfssp/api"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
)
func TestEvaluateErrorCodeResponse(t *testing.T) {
......
......@@ -4,7 +4,7 @@ import (
"io/ioutil"
"testing"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
)
func TestUnmarshalDFSSFile(t *testing.T) {
......
......@@ -4,7 +4,7 @@ import (
"fmt"
"testing"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
)
func TestFindNextIndex(t *testing.T) {
......
......@@ -7,7 +7,7 @@ import (
"path/filepath"
"testing"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
)
var crtFixture = `-----BEGIN CERTIFICATE-----
......@@ -34,9 +34,9 @@ func TestGenerateKeys(t *testing.T) {
fkey := filepath.Join(path, "genKey.pem")
rsa, err := GenerateKeys(512, "pwd", fkey)
assert.T(t, err == nil, "An error has been raised during generation")
assert.T(t, rsa != nil, "RSA key should not be nil")
assert.T(t, common.FileExists(fkey), "File is missing")
assert.True(t, err == nil, "An error has been raised during generation")
assert.True(t, rsa != nil, "RSA key should not be nil")
assert.True(t, common.FileExists(fkey), "File is missing")
common.DeleteQuietly(fkey)
}
......@@ -46,13 +46,13 @@ func TestCertificateRequest(t *testing.T) {
rsa, err := GenerateKeys(512, "pwd", fkey)
defer common.DeleteQuietly(fkey)
assert.T(t, err == nil, "An error has been raised during generation")
assert.T(t, rsa != nil, "RSA key should not be nil")
assert.T(t, common.FileExists(fkey), "File is missing")
assert.True(t, err == nil, "An error has been raised during generation")
assert.True(t, rsa != nil, "RSA key should not be nil")
assert.True(t, common.FileExists(fkey), "File is missing")
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.T(t, csr != "", "Certificate request should not be nil")
assert.True(t, err == nil, "An error has been raised during generation of certificate request")
assert.True(t, csr != "", "Certificate request should not be nil")
}
// Test saving rsa key on the disk
......@@ -62,18 +62,18 @@ func TestDumpingKey(t *testing.T) {
rsa, err := GenerateKeys(512, "pwd", fkey)
defer common.DeleteQuietly(fkey)
assert.T(t, err == nil, "An error has been raised during generation")
assert.T(t, rsa != nil, "RSA key should not be nil")
assert.T(t, common.FileExists(fkey), "File is missing")
assert.True(t, err == nil, "An error has been raised during generation")
assert.True(t, rsa != nil, "RSA key should not be nil")
assert.True(t, common.FileExists(fkey), "File is missing")
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")
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")
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")
}
......@@ -85,14 +85,14 @@ func TestDumpCrt(t *testing.T) {
err := SaveCertificate(crtFixture, fcert)
defer common.DeleteQuietly(fcert)
assert.T(t, err == nil, "An error has been raised during saving")
assert.T(t, common.FileExists(fcert), "File is missing")
assert.True(t, err == nil, "An error has been raised during saving")
assert.True(t, common.FileExists(fcert), "File is missing")
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")
crt, err := GetCertificate(fcert)
assert.T(t, err == nil, "An error has been raised while parsing certificate")
assert.T(t, crt != nil, "Certificate is nil")
assert.True(t, err == nil, "An error has been raised while parsing certificate")
assert.True(t, crt != nil, "Certificate is nil")
}
......@@ -10,7 +10,7 @@ import (
"dfss/auth"
"dfss/mockp/server"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
)
var path = filepath.Join("..", "testdata")
......
......@@ -6,7 +6,7 @@ import (
"os"
"testing"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
)
func TestFetchContract(t *testing.T) {
......
......@@ -5,7 +5,7 @@ import (
"dfss/dfssp/contract"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
)
func TestFindId(t *testing.T) {
......
......@@ -3,23 +3,23 @@ package user
import (
"dfss/dfssc/common"
"fmt"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
"os"
"testing"
)
func TestAuthenticationValidation(t *testing.T) {
_, 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.Close()
_, 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)
_, 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")
assert.Equal(t, err, nil)
......
......@@ -8,7 +8,7 @@ import (
"path/filepath"
"testing"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
)
const certFixture = `-----BEGIN CERTIFICATE-----
......@@ -46,15 +46,15 @@ func TestInvalidFiles(t *testing.T) {
defer deleteFiles(keyFile, certFile, "invalidConf.pem")
_, 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)
_, 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)
_, 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
......@@ -64,25 +64,25 @@ func TestErrorDumpingConfig(t *testing.T) {
defer deleteFiles(keyFile, certFile, "invalidConf.pem")
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)
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)
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", "")
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", "")
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.SaveStringToDisk("Invalid key", keyFile)
config, _ = NewConfig(keyFile, certFile)
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(keyFile)
......@@ -90,7 +90,7 @@ func TestErrorDumpingConfig(t *testing.T) {
_ = common.SaveStringToDisk("Invalid certificate", certFile)
config, _ = NewConfig(keyFile, certFile)
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) {
defer deleteFiles(keyFile, certFile, configPath)
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)
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)
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", "")
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)
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
......@@ -132,19 +132,19 @@ func TestErrorDecodeFile(t *testing.T) {
_ = security.SaveCertificate(fmt.Sprintf("%s", []byte(certFixture)), certFile)
_, 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", "")
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)
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", "")
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", "")
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) {
_ = security.SaveCertificate(fmt.Sprintf("%s", []byte(certFixture)), 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", "")
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")
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.Equalf(t, config.KeyData, decoded.KeyData, "Wrong keyData parameter")
assert.Equalf(t, config.CertFile, decoded.CertFile, "Wrong certFile parameter")
assert.Equalf(t, config.CertData, decoded.CertData, "Wrong certData parameter")
assert.Equal(t, config.KeyFile, decoded.KeyFile, "Wrong keyFile parameter")
assert.Equal(t, config.KeyData, decoded.KeyData, "Wrong keyData parameter")
assert.Equal(t, config.CertFile, decoded.CertFile, "Wrong certFile parameter")
assert.Equal(t, config.CertData, decoded.CertData, "Wrong certData parameter")
}
// TestSaveFilesToDisk tries to create the certificate and private key on the disk from
......@@ -187,22 +187,22 @@ func TestSaveFilesToDisk(t *testing.T) {
_ = security.SaveCertificate(fmt.Sprintf("%s", []byte(certFixture)), 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()
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)
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)
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.Tf(t, common.FileExists(certFile), "Expected certificate file")
assert.True(t, common.FileExists(keyFile), "Expected private key file")
assert.True(t, common.FileExists(certFile), "Expected certificate file")
}
// Helper function to delete all the files
......
......@@ -10,7 +10,7 @@ import (
"testing"
"time"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
)
const caFixture = `-----BEGIN CERTIFICATE-----
......@@ -67,23 +67,23 @@ func TestMain(m *testing.M) {
// Test the validation of the fields
func TestRegisterValidation(t *testing.T) {
_, err := NewRegisterManager(fca, fcert, fkey, addrPort, "password", "FR", "organization", "unit", "dummy", 2048)
assert.T(t, err != nil, "Email is invalid")
assert.True(t, err != nil, "Email is invalid")
_, err = NewRegisterManager(fca, fkey, fkey, addrPort, "password", "FR", "organization", "unit", "mpcs@dfss.io", 2048)
assert.T(t, err != nil, "Cert file is the same as key file")
assert.True(t, err != nil, "Cert file is the same as key file")
_, err = NewRegisterManager("inexistant.pem", fcert, fkey, addrPort, "password", "FR", "organization", "unit", "mpcs@dfss.io", 2048)
assert.T(t, err != nil, "CA file is invalid")
assert.True(t, err != nil, "CA file is invalid")
f, _ := os.Create(fcert)
_ = f.Close()
_, err = NewRegisterManager(fca, fcert, fkey, addrPort, "password", "FR", "organization", "unit", "mpcs@dfss.io", 2048)
assert.T(t, err != nil, "Cert file already exist")
assert.True(t, err != nil, "Cert file already exist")
k, _ := os.Create(fkey)
_ = k.Close()
_, err = NewRegisterManager(fca, fcert, fkey, addrPort, "password", "FR", "organization", "unit", "mpcs@dfss.io", 2048)
assert.T(t, err != nil, "Key file already exist")
assert.True(t, err != nil, "Key file already exist")
_ = os.Remove(fcert)
_ = os.Remove(fkey)
......@@ -93,9 +93,9 @@ func TestRegisterValidation(t *testing.T) {
// Only the SUCCESS code should not raise an error
func TestGetCertificate(t *testing.T) {
manager, err := NewRegisterManager(fca, fcert, fkey, addrPort, "password", "FR", "organization", "unit", "dfss@success.io", 2048)
assert.T(t, err == nil, "An error occurred while processing")
assert.True(t, err == nil, "An error occurred while processing")
err = manager.GetCertificate()
assert.T(t, err == nil, "An error occurred while getting the certificate")
assert.True(t, err == nil, "An error occurred while getting the certificate")
go testRegisterInvalidResponse(t, "dfss@invarg.io")
go testRegisterInvalidResponse(t, "dfss@badauth.io")
......@@ -108,9 +108,9 @@ func TestGetCertificate(t *testing.T) {
func testRegisterInvalidResponse(t *testing.T, mail string) {
manager, err := NewRegisterManager(fca, fcert+mail, fkey+mail, addrPort, "password", "FR", "organization", "unit", mail, 2048)
assert.T(t, err == nil, "An error occurred while processing")
assert.True(t, err == nil, "An error occurred while processing")
err = manager.GetCertificate()
assert.T(t, err != nil, "An error should have occurred while getting the certificate")
assert.True(t, err != nil, "An error should have occurred while getting the certificate")
_ = os.Remove(fcert + mail)
_ = os.Remove(fkey + mail)
......
......@@ -10,7 +10,7 @@ import (
"dfss/dfssp/server"
"dfss/mgdb"
"dfss/net"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
"gopkg.in/mgo.v2/bson"
)
......@@ -159,16 +159,16 @@ func TestCheckAuthorization(t *testing.T) {
res, err := repository.GetWithSigner(user1.CertHash, id)
assert.Equal(t, nil, err)
assert.T(t, res != nil)
assert.True(t, res != nil)
res, err = repository.GetWithSigner(user1.CertHash, bson.NewObjectId())
assert.Equal(t, nil, err)
assert.T(t, res == nil)
assert.True(t, res == nil)
res, err = repository.GetWithSigner(user2.CertHash, id)
assert.Equal(t, nil, err)
assert.T(t, res == nil)
assert.True(t, res == nil)
res, err = repository.GetWithSigner(user2.CertHash, bson.NewObjectId())
assert.Equal(t, nil, err)
assert.T(t, res == nil)
assert.True(t, res == nil)
contract := entities.Contract{}
_ = repository.Collection.FindByID(entities.Contract{ID: id}, &contract)
......@@ -177,6 +177,6 @@ func TestCheckAuthorization(t *testing.T) {
// Still valid if contract is not ready
res, _ = repository.GetWithSigner(user1.CertHash, id)
assert.T(t, res != nil)
assert.T(t, !res.Ready)
assert.True(t, res != nil)
assert.True(t, !res.Ready)
}
......@@ -12,7 +12,7 @@ import (
"dfss/dfssp/api"
"dfss/dfssp/entities"
"dfss/net"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
)
......@@ -105,7 +105,7 @@ func TestAddContract(t *testing.T) {
assert.Equal(t, defaultHash[:], contracts[0].File.Hash)
assert.Equal(t, "ContractFilename", contracts[0].File.Name)
assert.Equal(t, "ContractComment", contracts[0].Comment)
assert.T(t, contracts[0].Ready)
assert.True(t, contracts[0].Ready)
assert.Equal(t, 2, len(contracts[0].Signers))
assert.Equal(t, user1.ID, contracts[0].Signers[0].UserID)
......@@ -140,7 +140,7 @@ func TestAddContractMissingUser(t *testing.T) {
assert.Equal(t, defaultHash[:], contracts[0].File.Hash)
assert.Equal(t, "ContractFilename", contracts[0].File.Name)
assert.Equal(t, "", contracts[0].Comment)
assert.T(t, !contracts[0].Ready)
assert.True(t, !contracts[0].Ready)
assert.Equal(t, 2, len(contracts[0].Signers))
assert.Equal(t, user1.ID, contracts[0].Signers[0].UserID)
......
......@@ -7,7 +7,7 @@ import (
"dfss/dfssp/api"
"dfss/dfssp/contract"
"dfss/dfssp/entities"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
"gopkg.in/mgo.v2/bson"
)
......@@ -34,7 +34,7 @@ func TestGetContract(t *testing.T) {
})
assert.Equal(t, nil, err)
assert.Equal(t, api.ErrorCode_SUCCESS, c.ErrorCode.Code)
assert.T(t, len(c.Json) > 0)
assert.True(t, len(c.Json) > 0)
// Trying to unmarshal contract
var entity contract.JSON
......
......@@ -5,7 +5,7 @@ import (
"time"
"dfss/dfssp/entities"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
"gopkg.in/mgo.v2/bson"
)
......
......@@ -5,7 +5,7 @@ import (
"dfss/dfssp/api"
"dfss/dfssp/entities"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
"gopkg.in/mgo.v2/bson"
)
......
......@@ -6,7 +6,7 @@ import (
"dfss/dfssp/api"
"dfss/dfssp/contract"
"dfss/dfssp/entities"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
"gopkg.in/mgo.v2/bson"
)
......
......@@ -2,7 +2,7 @@ package contract_test
import (
"dfss/dfssp/contract"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
"testing"
)
......
......@@ -4,7 +4,7 @@ import (
"testing"
"dfss/dfssp/entities"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
)
func TestInit(t *testing.T) {
......
......@@ -3,7 +3,7 @@ package user_test
import (
"dfss/dfssp/api"
"dfss/net"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
"testing"
)
......
......@@ -15,7 +15,7 @@ import (
"dfss/dfssp/server"
"dfss/mgdb"
"dfss/net"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
"gopkg.in/mgo.v2/bson"
"time"
......
......@@ -8,7 +8,7 @@ import (
"crypto/sha512"
cAPI "dfss/dfssc/api"
"dfss/mgdb"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
"gopkg.in/mgo.v2/bson"
)
......
......@@ -4,7 +4,7 @@ import (
"testing"
cAPI "dfss/dfssc/api"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
)
func TestArePromisesValid(t *testing.T) {
......
......@@ -5,7 +5,7 @@ import (
"testing"
cAPI "dfss/dfssc/api"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
)
func TestIsRequestValid(t *testing.T) {
......
......@@ -3,7 +3,7 @@ package entities
import (
"testing"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
)
func TestArePromisesEqual(t *testing.T) {
......
......@@ -8,7 +8,7 @@ import (
"crypto/sha512"
"dfss/dfsst/entities"
"dfss/mgdb"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
"gopkg.in/mgo.v2/bson"
)
......
......@@ -9,7 +9,7 @@ import (
"strings"
"testing"
"github.com/bmizerany/assert"
"github.com/stretchr/testify/assert"
)
// TestExport tries to export the certificate and pricate key of the client
......@@ -49,7 +49,7 @@ func TestExport(t *testing.T) {
)
err = cmd.Run()
assert.Equal(t, nil, err)
assert.T(t, common.FileExists(confPath))
assert.True(t, common.FileExists(confPath))
// Bad case 1 : Wrong passphrase for private key
badCmd1 := exec.Command(path, "-cert", certPath, "-key", keyPath, "export", confPath)
......@@ -59,8 +59,8 @@ func TestExport(t *testing.T) {
"wrong passphrase\n",
)
_ = badCmd1.Run()
// assert.Equalf(t, nil, err, "%x", err)
assert.T(t, !common.FileExists(confPath))
// assert.Equal(t, nil, err, "%x", err)
assert.True(t, !common.FileExists(confPath))
// Bad case 2 : Missing certificate
badCmd2 := exec.Command(path, "-cert", certPath, "-key", keyPath, "export", confPath)
......@@ -71,7 +71,7 @@ func TestExport(t *testing.T) {
)
_ = badCmd2.Run()
// assert.Equal(t, nil, err)
assert.T(t, !common.FileExists(confPath))
assert.True(t, !common.FileExists(confPath))
}