Commit f5a5f874 authored by Richer Maximilien's avatar Richer Maximilien

[p] User unregister test

parent 17e397b4
Pipeline #2191 passed with stage
...@@ -14,6 +14,7 @@ import ( ...@@ -14,6 +14,7 @@ import (
"dfss/dfssp/api" "dfss/dfssp/api"
"dfss/dfssp/entities" "dfss/dfssp/entities"
"dfss/dfssp/server" "dfss/dfssp/server"
u "dfss/dfssp/user"
"dfss/mgdb" "dfss/mgdb"
"dfss/net" "dfss/net"
"github.com/spf13/viper" "github.com/spf13/viper"
...@@ -110,6 +111,25 @@ func TestMongoInsertUser(t *testing.T) { ...@@ -110,6 +111,25 @@ func TestMongoInsertUser(t *testing.T) {
} }
} }
func TestUnregisterUser(t *testing.T) {
var hash = []byte{0xde, 0xad, 0xbe, 0xef}
user := entities.NewUser()
user.Email = "dfss2@mpcs.tk"
user.CertHash = hash
user.Csr = "csr2"
user.RegToken = "regToken 2"
_, err = repository.Collection.Insert(user)
if err != nil {
t.Fatal("An error occurred while inserting the user")
}
response := u.Unregister(manager, hash)
if response.Code != api.ErrorCode_SUCCESS {
t.Fatal("An error occured while deleting the user:" + response.Message)
}
}
func equalUsers(t *testing.T, user1, user2 *entities.User) { func equalUsers(t *testing.T, user1, user2 *entities.User) {
if user1.ID != user2.ID { if user1.ID != user2.ID {
t.Fatal("ID doesn't match : received ", user1.ID, " and ", user2.ID) t.Fatal("ID doesn't match : received ", user1.ID, " and ", user2.ID)
......
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