-
Notifications
You must be signed in to change notification settings - Fork 61
/
main_test.go
61 lines (47 loc) · 1.19 KB
/
main_test.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
package main
import (
"crypto/ed25519"
"os"
"testing"
"github.com/spaceandtimelabs/SxT-Go-SDK/utils"
)
var userId, privKeyB64, pubKeyB64 string
var privKey ed25519.PrivateKey
var pubKey ed25519.PublicKey
// Test Authentication
func TestAuthentication(t *testing.T){
userId, ok := os.LookupEnv("TEST_TRIAL_USERID")
if !ok {
t.Error("TEST_TRIAL_USERID not set in env")
}
privKeyB64, ok = os.LookupEnv("TEST_TRIAL_PRIVKEY")
if !ok {
t.Error("TEST_TRIAL_PRIVKEY not set in env")
}
pubKeyB64, ok = os.LookupEnv("TEST_TRIAL_PUBKEY")
if !ok {
t.Error("TEST_TRIAL_PUBKEY not set in env")
}
_, _, privKeyBytes, pubKeyBytes, err := utils.Authenticate(userId, pubKeyB64, privKeyB64)
if err != nil {
t.Errorf("Autentication error %q", err)
}
pubKey = pubKeyBytes
privKey = privKeyBytes
}
// Test SQL APIs
func TestSQLAPIs(t *testing.T){
err := utils.SQLAPIs(privKey, pubKey)
// Intentionally skip errors as we dont want to modify any records
// This will always throw error
if err == nil {
t.Errorf("SQL API error %q", err)
}
}
// Test Discovery APIs
func TestDiscoveryAPIs(t *testing.T){
err := utils.DiscoveryAPIs()
if err != nil {
t.Errorf("Discovery APIs error %q", err)
}
}