Documentation ¶
Index ¶
- Variables
- func SupportedTokenAcquisitions() []string
- func SupportedVersions() map[string]bool
- func Version() string
- type CustomTest
- type Model
- type ModelAPISpecification
- type ModelConditionalProperties
- type ModelDiscovery
- type ModelDiscoveryItem
- type ModelEndpoint
- type ResourceIds
- type SpecificationTestCases
- type ValidationFailure
- func HasMandatoryEndpoints(checker model.ConditionalityChecker, discoveryConfig *Model) (bool, []ValidationFailure)
- func HasValidEndpoints(checker model.ConditionalityChecker, discoveryConfig *Model) (bool, []ValidationFailure)
- func Validate(checker model.ConditionalityChecker, discovery *Model) (bool, []ValidationFailure, error)
- type ValidationFailures
- type Validator
Constants ¶
This section is empty.
Variables ¶
var NoValidationFailures = ValidationFailures{}
NoValidationFailures represents a return of no validation errors found
Functions ¶
func SupportedTokenAcquisitions ¶
func SupportedTokenAcquisitions() []string
SupportedTokenAcquisitions returns a collection of supported token acquisition methods
func SupportedVersions ¶
SupportedVersions - returns map of supported versions
Types ¶
type CustomTest ¶
type CustomTest struct { ID string `json:"@id,omitempty"` // JSONLD ID Reference Name string `json:"name,omitempty"` // Name Description string `json:"description,omitempty"` // Purpose of the testcase in simple words Replacements map[string]string `json:"replacementParameters,omitempty"` // replacement parameters Sequence []model.TestCase `json:"testSequence,omitempty"` // TestCase to be run as part of this custom test }
CustomTest used to read and make sense of the custom test json
type Model ¶
type Model struct {
DiscoveryModel ModelDiscovery `json:"discoveryModel" validate:"required,dive"`
}
Model - Top level struct holding discovery model.
func UnmarshalDiscoveryJSON ¶
UnmarshalDiscoveryJSON - Used for testing in multiple packages to get discovery model from JSON. We tried moving this function to a _test file, but we get `go vet` error as it is used from multiple packages. In production, we use echo.Context Bind to load configuration from JSON in HTTP POST.
type ModelAPISpecification ¶
type ModelAPISpecification struct { Name string `json:"name" validate:"required"` URL string `json:"url" validate:"required,url"` Version string `json:"version" validate:"required"` SchemaVersion string `json:"schemaVersion" validate:"required,url"` }
ModelAPISpecification ... TODO: Document.
type ModelConditionalProperties ¶
type ModelConditionalProperties struct { Schema string `json:"schema" validate:"required"` Property string `json:"property" validate:"required"` Path string `json:"path" validate:"required"` }
ModelConditionalProperties - Conditional schema properties implemented by implementer.
type ModelDiscovery ¶
type ModelDiscovery struct { Name string `json:"name" validate:"required"` Description string `json:"description" validate:"required"` DiscoveryVersion string `json:"discoveryVersion" validate:"required"` TokenAcquisition string `json:"tokenAcquisition" validate:"required"` DiscoveryItems []ModelDiscoveryItem `json:"discoveryItems" validate:"required,dive"` CustomTests []CustomTest `json:"customTests" validate:"-"` }
ModelDiscovery - Holds fields describing model, and array of discovery items. For detailed documentation see ./doc/permissions.md file.
type ModelDiscoveryItem ¶
type ModelDiscoveryItem struct { APISpecification ModelAPISpecification `json:"apiSpecification,omitempty" validate:"required"` OpenidConfigurationURI string `json:"openidConfigurationUri,omitempty" validate:"required,url"` ResourceBaseURI string `json:"resourceBaseUri,omitempty" validate:"required,url"` ResourceIds ResourceIds `json:"resourceIds,omitempty" validate:"-"` Endpoints []ModelEndpoint `json:"endpoints,omitempty" validate:"required,gt=0,dive"` }
ModelDiscoveryItem - Each discovery item contains information related to a particular specification version.
type ModelEndpoint ¶
type ModelEndpoint struct { Method string `json:"method" validate:"required"` Path string `json:"path" validate:"required,uri"` ConditionalProperties []ModelConditionalProperties `json:"conditionalProperties,omitempty" validate:"dive"` }
ModelEndpoint - Endpoint and methods that have been implemented by implementer.
type ResourceIds ¶
ResourceIds section allows the replacement of endpoint resourceid values with real data parameters like accountid
type SpecificationTestCases ¶
type SpecificationTestCases struct { Specification ModelAPISpecification `json:"apiSpecification"` TestCases []model.TestCase `json:"testCases"` }
SpecificationTestCases - test cases generated for a specification
type ValidationFailure ¶
ValidationFailure - Records validation failure key and error.
e.g. ValidationFailure{ Key: "DiscoveryModel.Name", Error: "Field 'Name' is required", }
func HasMandatoryEndpoints ¶
func HasMandatoryEndpoints(checker model.ConditionalityChecker, discoveryConfig *Model) (bool, []ValidationFailure)
HasMandatoryEndpoints - checks that all the mandatory endpoints have been defined in each discovery model, otherwise it returns ValidationFailure structs for each missing mandatory endpoint.
func HasValidEndpoints ¶
func HasValidEndpoints(checker model.ConditionalityChecker, discoveryConfig *Model) (bool, []ValidationFailure)
HasValidEndpoints - checks that all the endpoints defined in the discovery model are either mandatory, conditional or optional. Return false and ValidationFailure structs indicating which endpoints are not valid.
func Validate ¶
func Validate(checker model.ConditionalityChecker, discovery *Model) (bool, []ValidationFailure, error)
Validate - validates a discovery model, returns true when valid, returns false and array of ValidationFailure structs when not valid.
type ValidationFailures ¶
type ValidationFailures []ValidationFailure
ValidationFailures represents a list of failures from a Validator engine
func (ValidationFailures) Empty ¶
func (v ValidationFailures) Empty() bool
Empty returns if there are validation failures present
type Validator ¶
type Validator interface {
Validate(*Model) (ValidationFailures, error)
}
Validator defines a generic validation engine
func NewFuncValidator ¶
func NewFuncValidator(checker model.ConditionalityChecker) Validator
NewFuncValidator creates a Validator engine using functional implementation