discovery

package
v1.1.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SupportedTokenAcquisitions

func SupportedTokenAcquisitions() []string

SupportedTokenAcquisitions returns a collection of supported token acquisition methods

func SupportedVersions

func SupportedVersions() map[string]bool

SupportedVersions - returns map of supported versions

func Version

func Version() string

Version returns the current version of the Discovery Model parser

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

func UnmarshalDiscoveryJSON(discoveryJSON string) (*Model, error)

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"`
	Manifest      string `json:"manifest" validate:"required,fileorhttps"`
	SpecType      string `json:"-"`
}

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 NullTLSValidator added in v1.1.17

type NullTLSValidator struct{}

func NewNullTLSValidator added in v1.1.17

func NewNullTLSValidator() NullTLSValidator

func (NullTLSValidator) ValidateTLSVersion added in v1.1.17

func (v NullTLSValidator) ValidateTLSVersion(uri string) (TLSValidationResult, error)

type ResourceIds

type ResourceIds map[string]string

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 StdTLSValidator added in v1.1.17

type StdTLSValidator struct {
	// contains filtered or unexported fields
}

func NewStdTLSValidator added in v1.1.17

func NewStdTLSValidator(minSupportedTLSVersion uint16) StdTLSValidator

func (StdTLSValidator) ValidateTLSVersion added in v1.1.17

func (v StdTLSValidator) ValidateTLSVersion(uri string) (TLSValidationResult, error)

type TLSValidationResult added in v1.1.17

type TLSValidationResult struct {
	Valid      bool
	TLSVersion string
}

type TLSValidator added in v1.1.17

type TLSValidator interface {
	ValidateTLSVersion(uri string) (TLSValidationResult, error)
}

type ValidationFailure

type ValidationFailure struct {
	Key   string `json:"key"`
	Error string `json:"error"`
}

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 NoValidationFailures

func NoValidationFailures() ValidationFailures

NoValidationFailures represents a return of no validation errors found

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL