Documentation ¶
Overview ¶
Package anvil runs functional tests for the Thing SDK
Index ¶
- Constants
- Variables
- func BaseURL() *url.URL
- func CertVerificationKey() (*jose.JSONWebKey, error)
- func ConfigureTestRealm(realm string, testDataDir string) (err error)
- func CreateCertVerificationMapping() error
- func CreateCertificate(caWebKey *jose.JSONWebKey, 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 DeleteRealms(ids []string) (err error)
- func GetIdentityAttributes(realm, name string, attributes interface{}) error
- func ModifyOAuth2Provider(realm string, clientBased bool, signingAlgorithm jose.SignatureAlgorithm) (original []byte, err error)
- func NewFileDebugger(directory, testName string) (*log.Logger, *os.File)
- func RandomName() string
- func RestoreOAuth2Service(realm string, config []byte) error
- func RestoreTestRealm(realm string, testDataDir string) (err error)
- func RunTest(state TestState, t SDKTest) (pass bool)
- func TestName(t SDKTest) string
- func TestThingGateway(u *url.URL, realm string, audience string, authTree string, dnsConfigured bool) (*gateway.ThingGateway, error)
- func TypeName(t interface{}) string
- func URL(subDomain string) *url.URL
- type AMTestState
- type NopSetupCleanup
- type SDKTest
- type SigningKey
- type TestState
- type ThingData
- type ThingGatewayTestState
- func (i *ThingGatewayTestState) Audience() string
- func (i *ThingGatewayTestState) ClientType() string
- func (i *ThingGatewayTestState) RealmForConfiguration() string
- func (i *ThingGatewayTestState) SetGatewayTree(tree string)
- func (i *ThingGatewayTestState) TestRealm() string
- func (i *ThingGatewayTestState) URL() *url.URL
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 DebugLogger = log.New(ioutil.Discard, "", 0)
var ProgressLogger = log.New(os.Stdout, "", 0)
Functions ¶
func CertVerificationKey ¶
func CertVerificationKey() (*jose.JSONWebKey, error)
CertVerificationKey returns the test JSON web key used by AM to verify certificates
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 ¶
func CreateCertificate(caWebKey *jose.JSONWebKey, thingID string, thingKey crypto.Signer) (*x509.Certificate, error)
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 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 GetIdentityAttributes ¶
GetIdentityAttributes gets the identity and unmarshals its attributes into the supplied struct
func ModifyOAuth2Provider ¶
func ModifyOAuth2Provider(realm string, clientBased bool, signingAlgorithm jose.SignatureAlgorithm) (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 NewFileDebugger ¶
NewFileDebugger creates a new Anvil logger that logs to file with the given test name
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 TestThingGateway ¶
func TestThingGateway(u *url.URL, realm string, audience string, authTree string, dnsConfigured bool) (*gateway.ThingGateway, error)
TestThingGateway creates a test Thing Gateway
Types ¶
type AMTestState ¶
AMTestState contains data and methods for testing the AM client
func (*AMTestState) Audience ¶
func (a *AMTestState) Audience() string
func (*AMTestState) ClientType ¶
func (a *AMTestState) ClientType() string
func (*AMTestState) RealmForConfiguration ¶
func (a *AMTestState) RealmForConfiguration() string
func (*AMTestState) SetGatewayTree ¶
func (a *AMTestState) SetGatewayTree(tree string)
func (*AMTestState) TestRealm ¶
func (a *AMTestState) TestRealm() string
func (*AMTestState) URL ¶
func (a *AMTestState) URL() *url.URL
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 interface { // RealmForConfiguration returns the realm that can be used for test setup, validation and clean up RealmForConfiguration() string // TestRealm returns the test realm that should be passed to the Thing SDK TestRealm() string // Audience returns the JWT audience for the current test realm Audience() string // ClientType returns 'am' or 'gateway' depending on the type of client ClientType() string // URL of the current test server (AM or Gateway) URL() *url.URL // SetGatewayTree sets the auth tree used by the test Thing Gateway SetGatewayTree(tree string) }
TestState contains client and realm data required to run a test
type ThingData ¶
type ThingData struct { Id am.IdAttributes Signer SigningKey Certificates []*x509.Certificate }
ThingData holds information about a Thing used in a test
type ThingGatewayTestState ¶
type ThingGatewayTestState struct { ThingGateway *gateway.ThingGateway Realm string TestAudience string }
ThingGatewayTestState contains data and methods for testing the Thing Gateway client
func (*ThingGatewayTestState) Audience ¶
func (i *ThingGatewayTestState) Audience() string
func (*ThingGatewayTestState) ClientType ¶
func (i *ThingGatewayTestState) ClientType() string
func (*ThingGatewayTestState) RealmForConfiguration ¶
func (i *ThingGatewayTestState) RealmForConfiguration() string
func (*ThingGatewayTestState) SetGatewayTree ¶
func (i *ThingGatewayTestState) SetGatewayTree(tree string)
func (*ThingGatewayTestState) TestRealm ¶
func (i *ThingGatewayTestState) TestRealm() string
func (*ThingGatewayTestState) URL ¶
func (i *ThingGatewayTestState) URL() *url.URL