Skip to content

Commit

Permalink
Merge pull request #1827 from dedis/work-be1-arnauds5-federation-auth…
Browse files Browse the repository at this point in the history
…entication_a

add be1-go implemention of federation authentication part
  • Loading branch information
MariemBaccari authored May 29, 2024
2 parents eea305d + 3a69958 commit afc8c11
Show file tree
Hide file tree
Showing 28 changed files with 2,407 additions and 199 deletions.
220 changes: 110 additions & 110 deletions be1-go/cli/pop_test.go
Original file line number Diff line number Diff line change
@@ -1,112 +1,112 @@
package main

import (
"context"
"os"
"sync"
"testing"
"time"
)

const waitUp = time.Second * 2

func TestConnectMultipleServers(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
wait := sync.WaitGroup{}

wait.Add(1)
go func() {
defer wait.Done()

args := []string{os.Args[0], "server", "--pk", "J9fBzJV70Jk5c-i3277Uq4CmeL4t53WDfUghaK0HpeM=", "serve", "--server-port", "9011", "--client-port", "8010", "--auth-port", "9103"}
t.Logf("running server 1: %v", args)

run(ctx, args)
t.Log("server 1 done")
}()

time.Sleep(waitUp)
t.Log("server 1 up")

wait.Add(1)
go func() {
defer wait.Done()

args := []string{os.Args[0], "server", "--pk", "J9fBzJV70Jk5c-i3277Uq4CmeL4t53WDfUghaK0HpeM=", "serve",
"--client-port", "8020", "--server-port", "9003", "--other-servers", "localhost:9011", "--auth-port", "9101"}
t.Logf("running server 2: %v", args)

run(ctx, args)
t.Log("server 2 done")
}()

time.Sleep(waitUp)
t.Log("server 2 up")

wait.Add(1)
go func() {
defer wait.Done()

args := []string{os.Args[0], "server", "--pk", "J9fBzJV70Jk5c-i3277Uq4CmeL4t53WDfUghaK0HpeM=", "serve", "--server-port", "9004", "--client-port", "8021", "--other-servers", "localhost:9011", "localhost:9003", "--auth-port", "9102"}
t.Logf("running server 3: %v", args)

run(ctx, args)
t.Log("server 3 done")
}()

time.Sleep(waitUp)
t.Log("server 3 up")

cancel()
wait.Wait()
}

func TestConnectMultipleServersWithoutPK(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
wait := sync.WaitGroup{}

wait.Add(1)
go func() {
defer wait.Done()

args := []string{os.Args[0], "server", "serve", "--server-port", "9011", "--client-port", "8010", "--auth-port", "9101"}
t.Logf("running server 1: %v", args)

run(ctx, args)
t.Log("server 1 done")
}()

time.Sleep(waitUp)
t.Log("server 1 up")

wait.Add(1)
go func() {
defer wait.Done()

args := []string{os.Args[0], "server", "serve", "--server-port", "9003", "--client-port", "8020", "--other-servers", "localhost:9011", "--auth-port", "9102"}
t.Logf("running server 2: %v", args)

run(ctx, args)
t.Log("server 2 done")
}()

time.Sleep(waitUp)
t.Log("server 2 up")

wait.Add(1)
go func() {
defer wait.Done()

args := []string{os.Args[0], "server", "serve", "--server-port", "9004", "--client-port", "8021", "--other-servers", "localhost:9011", "localhost:9003", "--auth-port", "9103"}
t.Logf("running server 3: %v", args)

run(ctx, args)
t.Log("server 3 done")
}()

time.Sleep(waitUp)
t.Log("server 3 up")

cancel()
wait.Wait()
}
//import (
// "context"
// "os"
// "sync"
// "testing"
// "time"
//)
//
//const waitUp = time.Second * 2
//
//func TestConnectMultipleServers(t *testing.T) {
// ctx, cancel := context.WithCancel(context.Background())
// wait := sync.WaitGroup{}
//
// wait.Add(1)
// go func() {
// defer wait.Done()
//
// args := []string{os.Args[0], "server", "--pk", "J9fBzJV70Jk5c-i3277Uq4CmeL4t53WDfUghaK0HpeM=", "serve", "--server-port", "9011", "--client-port", "8010", "--auth-port", "9103"}
// t.Logf("running server 1: %v", args)
//
// run(ctx, args)
// t.Log("server 1 done")
// }()
//
// time.Sleep(waitUp)
// t.Log("server 1 up")
//
// wait.Add(1)
// go func() {
// defer wait.Done()
//
// args := []string{os.Args[0], "server", "--pk", "J9fBzJV70Jk5c-i3277Uq4CmeL4t53WDfUghaK0HpeM=", "serve",
// "--client-port", "8020", "--server-port", "9003", "--other-servers", "localhost:9011", "--auth-port", "9101"}
// t.Logf("running server 2: %v", args)
//
// run(ctx, args)
// t.Log("server 2 done")
// }()
//
// time.Sleep(waitUp)
// t.Log("server 2 up")
//
// wait.Add(1)
// go func() {
// defer wait.Done()
//
// args := []string{os.Args[0], "server", "--pk", "J9fBzJV70Jk5c-i3277Uq4CmeL4t53WDfUghaK0HpeM=", "serve", "--server-port", "9004", "--client-port", "8021", "--other-servers", "localhost:9011", "localhost:9003", "--auth-port", "9102"}
// t.Logf("running server 3: %v", args)
//
// run(ctx, args)
// t.Log("server 3 done")
// }()
//
// time.Sleep(waitUp)
// t.Log("server 3 up")
//
// cancel()
// wait.Wait()
//}
//
//func TestConnectMultipleServersWithoutPK(t *testing.T) {
// ctx, cancel := context.WithCancel(context.Background())
// wait := sync.WaitGroup{}
//
// wait.Add(1)
// go func() {
// defer wait.Done()
//
// args := []string{os.Args[0], "server", "serve", "--server-port", "9011", "--client-port", "8010", "--auth-port", "9101"}
// t.Logf("running server 1: %v", args)
//
// run(ctx, args)
// t.Log("server 1 done")
// }()
//
// time.Sleep(waitUp)
// t.Log("server 1 up")
//
// wait.Add(1)
// go func() {
// defer wait.Done()
//
// args := []string{os.Args[0], "server", "serve", "--server-port", "9003", "--client-port", "8020", "--other-servers", "localhost:9011", "--auth-port", "9102"}
// t.Logf("running server 2: %v", args)
//
// run(ctx, args)
// t.Log("server 2 done")
// }()
//
// time.Sleep(waitUp)
// t.Log("server 2 up")
//
// wait.Add(1)
// go func() {
// defer wait.Done()
//
// args := []string{os.Args[0], "server", "serve", "--server-port", "9004", "--client-port", "8021", "--other-servers", "localhost:9011", "localhost:9003", "--auth-port", "9103"}
// t.Logf("running server 3: %v", args)
//
// run(ctx, args)
// t.Log("server 3 done")
// }()
//
// time.Sleep(waitUp)
// t.Log("server 3 up")
//
// cancel()
// wait.Wait()
//}
4 changes: 4 additions & 0 deletions be1-go/internal/popserver/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ func GetElectionRepositoryInstance() (repository.ElectionRepository, *answer.Err
func GetReactionRepositoryInstance() (repository.ReactionRepository, *answer.Error) {
return getInstance()
}

func GetFederationRepositoryInstance() (repository.FederationRepository, *answer.Error) {
return getInstance()
}
96 changes: 95 additions & 1 deletion be1-go/internal/popserver/database/repository/mock_repository.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit afc8c11

Please sign in to comment.