Skip to content

Commit

Permalink
fix registration test
Browse files Browse the repository at this point in the history
  • Loading branch information
jbsv committed Mar 11, 2024
1 parent 417bbd5 commit 1bca58c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 0 additions & 2 deletions server/registration/registry/crud/crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ func CreateDocument(w http.ResponseWriter, r *http.Request, db database.Database
return
}

log.Println(fileHeader)

picData := make([]byte, fileHeader.Size)
_, err = picture.Read(picData)
if err != nil {
Expand Down
Binary file added server/test/passport.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 8 additions & 5 deletions server/test/user/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ func RegistrationAdd(data registry.RegistrationData, symKey []byte) (
registry.RegistrationID,
error,
) {
var b bytes.Buffer
w := multipart.NewWriter(&b)
var body bytes.Buffer
w := multipart.NewWriter(&body)

fw, err := w.CreateFormField("pubkey")
if err != nil {
Expand Down Expand Up @@ -67,21 +67,24 @@ func RegistrationAdd(data registry.RegistrationData, symKey []byte) (
return registry.RegistrationID{}, err
}

fw, err = w.CreateFormField("picture")
fw, err = w.CreateFormFile("portrait", "portrait.jpg")
if err != nil {
return registry.RegistrationID{}, err
}
if _, err = io.Copy(fw, bytes.NewReader(data.Picture)); err != nil {
return registry.RegistrationID{}, err
}

defer w.Close()
w.Close()

req, err := http.NewRequest(http.MethodPost, registrationServer+"/document", &b)
req, err := http.NewRequest(http.MethodPost, registrationServer+"/document", &body)
if err != nil {
return registry.RegistrationID{}, err
}

// Don't forget to set the content type, this will contain the boundary.
req.Header.Set("Content-Type", w.FormDataContentType())

resp, err := http.DefaultClient.Do(req)
if err != nil {
return registry.RegistrationID{}, err
Expand Down
4 changes: 2 additions & 2 deletions server/test/user/smc.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"go.dedis.ch/kyber/v3"
)

const smcServer = "localhost:3002"
const smcServer = "http://localhost:40001"

func SmcGetKey() kyber.Point {
resp, err := http.Get(smcServer + "/key")
resp, err := http.Get(smcServer + "/smc/pubkey")
if err != nil {
log.Fatal().Msgf("error: %v", err)
}
Expand Down

0 comments on commit 1bca58c

Please sign in to comment.