-
Notifications
You must be signed in to change notification settings - Fork 3
/
main_ctx_test.go
60 lines (54 loc) · 1.39 KB
/
main_ctx_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
// Copyright (c) IOTIC LABS LIMITED. All rights reserved. Licensed under the Apache License, Version 2.0.
package main_test
import (
"github.com/Iotic-Labs/iotics-identity-go/v3/pkg/register"
"github.com/go-bdd/gobdd"
"gotest.tools/assert"
)
type ctxKey int
const (
ctxUserSeed ctxKey = iota
ctxAgentSeed
ctxTwinSeed
ctxUserKeyName
ctxAgentKeyName
ctxTwinKeyName
ctxUserIssuerName
ctxAgentIssuerName
ctxTwinIssuerName
ctxRegisteredUser
ctxRegisteredAgent
ctxRegisteredTwin
ctxDelegationName
ctxUseLegacySeedMethod
ctxRetrievedDoc
ctxAllOwnersPubKeys
ctxOtherRegisteredTwin
ctxOtherTwinIdentityExtraOwnerKeyPair
ctxOtherTwinIdentityExtraOwnerName
ctxOtherTwinIdentityIssuer
ctxOtherTwinIdentityName
ctxOtherTwinIdentityPubKey
ctxDelegationProof
ctxAuthTokenDuration
ctxTargetAudience
ctxAuthToken
ctxAllowedForAuth
ctxAllowedForControl
ctxNewOwnerKeyName
ctxRegisteredUserDocument
ctxRegisteredAgentDocument
ctxRegisteredTwinDocument
)
func (c ctxKey) GetRegisteredIdentity(t gobdd.StepTest, ctx gobdd.Context) register.RegisteredIdentity {
value, _ := ctx.Get(c)
identity := value.(register.RegisteredIdentity)
assert.Assert(t, identity != nil)
return identity
}
func (c ctxKey) GetRegisteredDocument(t gobdd.StepTest, ctx gobdd.Context) *register.RegisterDocument {
value, _ := ctx.Get(c)
doc := value.(*register.RegisterDocument)
assert.Assert(t, doc != nil)
return doc
}