Documentation ¶
Overview ¶
Package anvil runs functional tests for the IoT SDK
Index ¶
- Constants
- Variables
- func BaseURL() *url.URL
- func ConfigureTestRealm(realm string, testDataDir string) (err error)
- func CreateCertVerificationMapping() error
- func CreateCertificate(thingID string, thingKey crypto.Signer) (*x509.Certificate, error)
- func CreateRealmHierarchy(names ...string) (fullName string, ids []string, err error)
- func CreateRealmWithAlias(name string, alias string) (id string, err error)
- func CreateRealmWithDNSAlias(name string, alias string) (id string, err error)
- func CreateSoftwareStatement(clientJWK jose.JSONWebKey) (string, error)
- func CreateUser(realm string) (am.IdAttributes, error)
- func DeleteRealms(ids []string) (err error)
- func ModifyOAuth2Provider(realm string, tokenType AccessTokenType) (original []byte, err error)
- func RandomName() string
- func RestoreOAuth2Service(realm string, config []byte) error
- func RestoreTestRealm(realm string, testDataDir string) (err error)
- func RevokeAccessToken(realm string, token string) error
- func RunTest(state TestState, t SDKTest) (pass bool)
- func TestGateway(u *url.URL, realm string, audience string, authTree string, dnsConfigured bool) (*gateway.Gateway, error)
- func TestName(t SDKTest) string
- func TypeName(t interface{}) string
- func URL(subDomain string) *url.URL
- type AccessTokenType
- type NopSetupCleanup
- type SDKTest
- type SigningKey
- type TestState
- func (t *TestState) AMURL() string
- func (t *TestState) ClientType() string
- func (t *TestState) ConnectionURL() *url.URL
- func (t *TestState) DNSConfigured() bool
- func (t *TestState) Realm() string
- func (t *TestState) RealmForConfiguration() string
- func (t *TestState) RealmPath() string
- func (t *TestState) SetGatewayTree(tree string)
- func (t *TestState) String() string
- type ThingData
Constants ¶
const ( PassString = "\033[1;32mPASS\033[0m" FailString = "\033[1;31mFAIL\033[0m" // Standard timeout used in SDK calls in tests StdTimeOut = 10 * time.Second RootRealm = "/" GatewayClientType = "gateway" AMClientType = "am" )
Variables ¶
var ( // CTS based (stateful) access token type CTS = AccessTokenType{/* contains filtered or unexported fields */} // Client based (stateless) encrypted access token type ClientEncrypted = AccessTokenType{/* contains filtered or unexported fields */} )
var DebugLogger = log.New(io.Discard, "", 0)
var ProgressLogger = log.New(os.Stdout, "", 0)
Functions ¶
func ConfigureTestRealm ¶
ConfigureTestRealm configures the realm by loading all the data in the testDataDir
func CreateCertVerificationMapping ¶
func CreateCertVerificationMapping() error
CreateCertVerificationMapping maps the IoT certification verification secret to the test key
func CreateCertificate ¶
CreateCertificate creates a certificate for a Thing signed by the given CA JSON web key
func CreateRealmHierarchy ¶
CreateRealmHierarchy creates the supplied realms in a linear hierarchy The first realm is a child of root, otherwise a realm is a child of the previously created realm Returns the fully-qualified name of the leaf realm and a list of ids of all the created realms
func CreateRealmWithAlias ¶
CreateRealmWithAlias creates a test realm with an alias
func CreateRealmWithDNSAlias ¶
CreateRealmWithDNSAlias creates a test realm with a DNS alias
func CreateSoftwareStatement ¶ added in v7.2.0
CreateSoftwareStatement creates a software statement for a Thing signed with the configured Software Publisher key
func CreateUser ¶ added in v7.1.0
func CreateUser(realm string) (am.IdAttributes, error)
CreateUser creates a human identity in AM with a unique name.
func DeleteRealms ¶
DeleteRealms deletes all the realms in the id slice from the AM instance Assumes that the ids are in an order that can be safely deleted e.g. children before parents
func ModifyOAuth2Provider ¶
func ModifyOAuth2Provider(realm string, tokenType AccessTokenType) (original []byte, err error)
ModifyOAuth2Provider changes the OAuth 2.0 access tokens issued by AM Returns the original configuration so that the provider can be restored
func RestoreOAuth2Service ¶
RestoreOAuth2Service restores the OAut 2.0 service using the supplied config
func RestoreTestRealm ¶
RestoreTestRealm restores the configuration of the realm to a pre-test state
func RevokeAccessToken ¶ added in v7.1.0
RevokeAccessToken uses the custom OAuth 2.0 client to revoke the access token
func TestGateway ¶ added in v7.1.0
func TestGateway(u *url.URL, realm string, audience string, authTree string, dnsConfigured bool) (*gateway.Gateway, error)
TestGateway creates a test IoT Gateway
Types ¶
type AccessTokenType ¶ added in v7.1.0
type AccessTokenType struct {
// contains filtered or unexported fields
}
AccessTokenType is used to configure the type of OAuth2 access token issues by AM
func ClientSignedTokenType ¶ added in v7.1.0
func ClientSignedTokenType(alg jose.SignatureAlgorithm) AccessTokenType
ClientSignedTokenType returns a client based (stateless) signed token type
func (AccessTokenType) Name ¶ added in v7.1.0
func (a AccessTokenType) Name() string
type NopSetupCleanup ¶
type NopSetupCleanup struct { }
NopSetupCleanup defines a struct with no-op Setup and Cleanup methods
func (NopSetupCleanup) Cleanup ¶
func (t NopSetupCleanup) Cleanup(TestState, ThingData) error
Cleanup is a no op function
func (NopSetupCleanup) NameSuffix ¶
func (t NopSetupCleanup) NameSuffix() string
NameSuffix returns the empty string
type SDKTest ¶
type SDKTest interface { Setup(state TestState) (data ThingData, ok bool) // setup actions before the test starts Run(state TestState, data ThingData) bool // function that runs and validates the test Cleanup(state TestState, data ThingData) (err error) // cleanup actions after the test has finished NameSuffix() string // optional suffix to add to struct name to create the test name }
SDKTest defines the interface required by a SDK API test
type SigningKey ¶
SigningKey describes a key used for signing messages sent to AM
func ConfirmationKey ¶
func ConfirmationKey(algorithm jose.SignatureAlgorithm) (public jose.JSONWebKeySet, private SigningKey, err error)
ConfirmationKey returns a key for signing requests to AM that is accompanied by a restricted PoP SSO token.
type TestState ¶
type TestState struct {
// contains filtered or unexported fields
}
TestState contains client and realm data required to run a test
func NewTestState ¶ added in v7.2.0
func NewTestState(gateway *gateway.Gateway, amURL *url.URL, realm, realmPath string, dns bool) TestState
NewTestState will create a new TestState instance with the given properties
func (*TestState) ClientType ¶
ClientType returns 'am' or 'gateway' depending on the type of client
func (*TestState) ConnectionURL ¶ added in v7.2.0
ConnectionURL of the current test server (AM or Gateway)
func (*TestState) DNSConfigured ¶ added in v7.2.0
DNSConfigured will be true if DNS configuration is used instead of a realm path
func (*TestState) Realm ¶ added in v7.2.0
Realm returns the test realm that should be passed to the IoT SDK
func (*TestState) RealmForConfiguration ¶
RealmForConfiguration returns the realm that can be used for test setup, validation and clean up
func (*TestState) SetGatewayTree ¶
SetGatewayTree sets the auth tree used by the test IoT Gateway
type ThingData ¶
type ThingData struct { Id am.IdAttributes Signer SigningKey Certificates []*x509.Certificate SoftwareStatement string }
ThingData holds information about a Thing used in a test