-
Notifications
You must be signed in to change notification settings - Fork 10
/
local.go
62 lines (50 loc) · 1.86 KB
/
local.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// SPDX-License-Identifier: ice License 1.0
package main
import (
"flag"
"github.com/google/uuid"
"github.com/ice-blockchain/eskimo/users/fixture"
"github.com/ice-blockchain/eskimo/users/seeding"
authfixture "github.com/ice-blockchain/wintr/auth/fixture"
"github.com/ice-blockchain/wintr/log"
)
//nolint:gochecknoglobals // Because those are flags
var (
generateFirebaseAuth = flag.String("generateFirebaseAuth", "", "generate a new auth for a random user, with the specified role")
generateIceAuth = flag.String("generateIceAuth", "", "generate a new auth for a random user, with the specified role")
startSeeding = flag.Bool("startSeeding", false, "whether to start seeding a remote database or not")
)
func main() {
flag.Parse()
if generateFirebaseAuth != nil && *generateFirebaseAuth != "" {
userID, accessToken := testingAuthorization(*generateFirebaseAuth)
formatToken(userID, "", accessToken)
return
}
if generateIceAuth != nil && *generateIceAuth != "" {
userID := uuid.NewString()
refreshToken, accessToken, err := authfixture.GenerateIceTokens(userID, *generateIceAuth)
log.Panic(err) //nolint:revive // .
formatToken(userID, refreshToken, accessToken)
return
}
if *startSeeding {
seeding.StartSeeding()
return
}
fixture.StartLocalTestEnvironment()
}
func testingAuthorization(role string) (userID, token string) {
return authfixture.CreateUser(role)
}
func formatToken(userID, refresh, access string) {
log.Info("UserID")
log.Info("=================================================================================")
log.Info(userID)
log.Info("Refresh Token")
log.Info("=================================================================================")
log.Info(refresh)
log.Info("Authorization Bearer Token")
log.Info("=================================================================================")
log.Info(access)
}