bdd

package
v0.0.0-...-d841f61 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Overview

bdd contains feature context utils.

Index

Constants

View Source
const ApiEnvURL = "API_URL"

Variables

This section is empty.

Functions

func GetApiURL

func GetApiURL() (*url.URL, error)

GetApiURL retrieves API url from env var.

Types

type AmqpClient

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

AmqpClient represents utility struct which implements AMQP steps to feature context.

func NewAmqpClient

func NewAmqpClient(
	exchange, key string,
	encoder encoding.Encoder,
	decoder encoding.Decoder,
	eventLogger zerolog.Logger,
) (*AmqpClient, error)

NewAmqpClient creates new AMQP client.

func (*AmqpClient) ICallRPCAxeRequest

func (c *AmqpClient) ICallRPCAxeRequest(eid string, doc *messages.PickleStepArgument_PickleDocString) error

* Step example:

When I call RPC request to engine-axe with alarm resource/component:
"""
{
  "event_type": "ack"
}
"""

func (*AmqpClient) ICallRPCWebhookRequest

func (c *AmqpClient) ICallRPCWebhookRequest(eid string, doc *messages.PickleStepArgument_PickleDocString) error

* Step example:

When I call RPC request to engine-webhook with alarm resource/component:
"""
{
  "request": {
	  "method": "POST",
	  "url": "http://test-url.com"
	}
}
"""

func (*AmqpClient) IWaitTheEndOfEventProcessing

func (c *AmqpClient) IWaitTheEndOfEventProcessing() error

* Step example:

When I wait the end of event processing

func (*AmqpClient) IWaitTheEndOfEventsProcessing

func (c *AmqpClient) IWaitTheEndOfEventsProcessing(count int) error

* Step example:

When I wait the end of 2 events processing

func (*AmqpClient) Reset

func (c *AmqpClient) Reset(_ *messages.Pickle)

type ApiClient

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

ApiClient represents utility struct which implements API steps to feature context.

func NewApiClient

func NewApiClient() (*ApiClient, error)

NewApiClient creates new API client.

func (*ApiClient) IAm

func (a *ApiClient) IAm(role string) error

* Step example:

Given I am admin

func (*ApiClient) IAmAuthenticatedByApiKey

func (a *ApiClient) IAmAuthenticatedByApiKey(apiKey string) error

* Step example:

When I am authenticated with api key "key"

func (*ApiClient) IAmAuthenticatedByBasicAuth

func (a *ApiClient) IAmAuthenticatedByBasicAuth(username, password string) error

* Step example:

When I am authenticated with username "user" password "pass"

func (*ApiClient) IDoRequest

func (a *ApiClient) IDoRequest(method, uri string) error

* Step example:

When I do GET /api/v4/alarms
When I do GET /api/v4/entitybasic/{{ .lastResponse._id}}

func (*ApiClient) IDoRequestWithBody

func (a *ApiClient) IDoRequestWithBody(method, uri string, doc *messages.PickleStepArgument_PickleDocString) error

* Step example:

When I do POST /api/v4/event:
"""
  {
	"connector" : "test_post_connector",
	"connector_name" : "test_post_connector_name",
	"source_type" : "resource",
	"event_type" : "check",
	"component" : "test_post_component",
	"resource" : "test_post_resource",
	"state" : 1,
	"output" : "noveo alarm"
  }
"""
When I do PUT /api/v4/entitybasics/{{ .lastResponse._id}}:
"""
  {
	"state": 1
  }
"""

func (*ApiClient) ISaveResponse

func (a *ApiClient) ISaveResponse(key, value string) error

* Step example:

When I save response id={{ .lastResponse._id }}

func (*ApiClient) ISendAnEvent

func (a *ApiClient) ISendAnEvent(doc *messages.PickleStepArgument_PickleDocString) (err error)

* Step example:

When I send an event:
"""
  {
	"connector" : "test_post_connector",
	"connector_name" : "test_post_connector_name",
	"source_type" : "resource",
	"event_type" : "check",
	"component" : "test_post_component",
	"resource" : "test_post_resource",
	"state" : 1,
	"output" : "noveo alarm"
  }
"""

func (*ApiClient) ResetResponse

func (a *ApiClient) ResetResponse(_ *messages.Pickle)

ResetResponse clears all saved response data.

func (*ApiClient) SetRequestContentType

func (a *ApiClient) SetRequestContentType(contentType string) error

* Step example:

func (*ApiClient) TheResponseBodyShouldBe

func (a *ApiClient) TheResponseBodyShouldBe(doc *messages.PickleStepArgument_PickleDocString) error

* Step example:

Then the response body should be:
"""
{
	"_id": "441d896b-c0bd-40f4-9926-0568f4a94ec7",
	"name": "Test name",
	"created": 1603882800
}
"""

func (*ApiClient) TheResponseBodyShouldContain

func (a *ApiClient) TheResponseBodyShouldContain(doc *messages.PickleStepArgument_PickleDocString) error

* If some fields are not defined in step content they are ignored.

Step example:

Then the response body should contain:
"""
{
	"name": "Test name"
}
"""

func (*ApiClient) TheResponseCodeShouldBe

func (a *ApiClient) TheResponseCodeShouldBe(code int) error

* Step example:

Then the response code should be 200

func (*ApiClient) TheResponseKeyShouldNotBe

func (a *ApiClient) TheResponseKeyShouldNotBe(path, value string) error

* Step example:

Then the response key "data.0.created_at" should not be "0"

func (*ApiClient) TheResponseKeyShouldNotExist

func (a *ApiClient) TheResponseKeyShouldNotExist(path string) error

* Step example:

Then the response key "data.0.created_at" should not exist

func (*ApiClient) TheResponseRawBodyShouldBe

func (a *ApiClient) TheResponseRawBodyShouldBe(doc *messages.PickleStepArgument_PickleDocString) error

* Step example:

Then the response raw body should be:
"""
Test
"""

type MongoClient

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

MongoClient represents utility struct which implements db steps to feature context.

func NewMongoClient

func NewMongoClient() (*MongoClient, error)

NewMongoClient creates new mongo client.

func (*MongoClient) AlarmShouldBeInTheDb

func (c *MongoClient) AlarmShouldBeInTheDb(eid string) error

* Step example:

And an alarm test_post_resource/test_post_component should be in the db

func (*MongoClient) EntityShouldBeInTheDb

func (c *MongoClient) EntityShouldBeInTheDb(eid string) error

* Step example:

And an entity test_post_resource/test_post_component should be in the db

Jump to

Keyboard shortcuts

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