helpers

package
v0.0.0-...-e39aa76 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Copyright 2018 Pantacor Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2018 Pantacor Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2018 Pantacor Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2019 Pantacor Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2018 Pantacor Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2018 Pantacor Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright 2018 Pantacor Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var BaseAPIUrl = "http://" + utils.GetEnv("PANTAHUB_HOST") + ":" + utils.GetEnv("PANTAHUB_PORT")

BaseAPIUrl : Pantahub Base API END POINT

View Source
var Devices []models.Device

Devices : to keep the generated devices documents

View Source
var DevicesCount = 0

DevicesCount : to keep the generated DeviceCount

View Source
var GCAPIUrl = utils.GetEnv("PANTAHUB_GC_API")

GCAPIUrl : Garbage collector API END POINT

View Source
var InvalidObjectsCount = 0

InvalidObjectsCount : Invalid Objects Count

View Source
var InvalidStepsCount = 0

InvalidStepsCount : Invalid Steps Count

View Source
var InvalidTrailsCount = 0

InvalidTrailsCount : Invalid Trails Count

View Source
var Objects []models.Object

Objects : to keep the generated object documents

View Source
var ObjectsCount = 0

ObjectsCount : Objects Count

View Source
var ReUsedObjectsCount = 0

ReUsedObjectsCount : ReUsed Objects Count

View Source
var Steps []models.Step

Steps : to keep the generated steps documents

View Source
var StepsCount = 0

StepsCount : Steps Count

View Source
var Trails []models.Trail

Trails : to keep the generated trails documents

View Source
var TrailsCount = 0

TrailsCount : TrailsCount

View Source
var UTOKEN = ""

UTOKEN : to keep User access token

Functions

func AssignUserToDevice

func AssignUserToDevice(
	t *testing.T,
	deviceID string,
	Challenge string,
) (
	map[string]interface{},
	*resty.Response,
)

AssignUserToDevice : Assign User To Device

func ChangeDeviceSecret

func ChangeDeviceSecret(
	t *testing.T,
	deviceID string,
	newSecret string,
) (
	map[string]interface{},
	*resty.Response,
)

ChangeDeviceSecret : Change Device Secret

func CheckResult

func CheckResult(result map[string]interface{}, expectedResult map[string]interface{}) bool

CheckResult : Used to compare expected result vs obtained result

func ClearOldData

func ClearOldData(t *testing.T, mongoDb *mongo.Database) bool

ClearOldData : Clear all old data and reset counters

func CreateDevice

func CreateDevice(t *testing.T, claim bool, secret string) (models.Device, *resty.Response)

CreateDevice : Register a Device (As User)

func CreateLog

func CreateLog(
	t *testing.T,
	dToken string,
	logData map[string]interface{},
) (
	[]interface{},
	*resty.Response,
)

CreateLog : Create A Log

func CreateObject

func CreateObject(
	t *testing.T,
	sha string,
) (
	objectSha string,
	object models.Object,
	res *resty.Response,
)

CreateObject : Create new Object

func CreateStep

func CreateStep(
	t *testing.T,
	device models.Device,
	revision int,
	includeState bool,
	objectSha string,
) (
	models.Step,
	*resty.Response,
)

CreateStep : Create new Step under a trail

func CreateTrail

func CreateTrail(
	t *testing.T,
	device models.Device,
	includeState bool,
	objectSha string,
) (
	models.Trail,
	*resty.Response,
)

CreateTrail : Create a trail

func DeleteAllDevices

func DeleteAllDevices(t *testing.T, mongoDb *mongo.Database) bool

DeleteAllDevices : Delete All Devices

func DeleteAllObjects

func DeleteAllObjects(t *testing.T, mongoDb *mongo.Database) bool

DeleteAllObjects : Delete All Objects

func DeleteAllPersonalLogs

func DeleteAllPersonalLogs(t *testing.T, mongoDb *mongo.Database) bool

DeleteAllPersonalLogs : Delete All Personal Logs

func DeleteAllSteps

func DeleteAllSteps(t *testing.T, mongoDb *mongo.Database) bool

DeleteAllSteps : Delete All Steps from the database

func DeleteAllTrails

func DeleteAllTrails(t *testing.T, mongoDb *mongo.Database) bool

DeleteAllTrails : Delete All Trails

func DeleteAllUserAccounts

func DeleteAllUserAccounts(t *testing.T, mongoDb *mongo.Database) bool

DeleteAllUserAccounts : Delete All User Accounts

func DeleteDevice

func DeleteDevice(t *testing.T, deviceID string, mongoDb *mongo.Database) bool

DeleteDevice : Delete a Device from database

func DeleteDeviceGarbages

func DeleteDeviceGarbages(t *testing.T) (map[string]interface{}, *resty.Response)

DeleteDeviceGarbages : Delete Device Garbages

func DeleteTrail

func DeleteTrail(t *testing.T, trailID string, mongoDb *mongo.Database) bool

DeleteTrail : Delete a Trail

func DisplayCounters

func DisplayCounters()

DisplayCounters : Display Counters

func GenerateObjectSha

func GenerateObjectSha() string

GenerateObjectSha : Generate ObjectSha string

func GetDevice

func GetDevice(
	t *testing.T,
	deviceID string,
) (
	map[string]interface{},
	*resty.Response,
)

GetDevice : Get Device Details

func GetStep

func GetStep(
	t *testing.T,
	trailID string,
	step string,
) (
	map[string]interface{},
	*resty.Response,
)

GetStep : Get Step Details

func GetUser

func GetUser(t *testing.T, email string, mongoDb *mongo.Database) accounts.Account

GetUser : Get User Object

func ListLogs

func ListLogs(t *testing.T) (
	map[string]interface{},
	*resty.Response,
)

ListLogs : List logs

func ListObjects

func ListObjects(t *testing.T) (
	response []interface{},
	res *resty.Response,
)

ListObjects : List Objects

func ListSteps

func ListSteps(
	t *testing.T,
	trailID string,
) (
	[]interface{},
	*resty.Response,
)

ListSteps : List Steps of a trail

func ListTrails

func ListTrails(
	t *testing.T,
	deviceID string,
	dToken string,
) (
	[]interface{},
	*resty.Response,
)

ListTrails : List Trails Of A Device

func ListUserDevices

func ListUserDevices(t *testing.T) (
	[]interface{},
	*resty.Response,
)

ListUserDevices : List User Devices

func Login

func Login(
	t *testing.T,
	username string,
	password string,
) (
	map[string]interface{},
	*resty.Response,
)

Login : Login user

func LoginDevice

func LoginDevice(
	t *testing.T,
	username string,
	password string,
) (
	map[string]interface{},
	*resty.Response,
)

LoginDevice : Login Device

func MakeDeviceNonPublic

func MakeDeviceNonPublic(
	t *testing.T,
	deviceID string,
) (
	map[string]interface{},
	*resty.Response,
)

MakeDeviceNonPublic : Make Device Non Public

func MakeDevicePublic

func MakeDevicePublic(
	t *testing.T,
	deviceID string,
) (
	map[string]interface{},
	*resty.Response,
)

MakeDevicePublic : Make Device Public

func MarkAllUnClaimedDevicesAsGrabage

func MarkAllUnClaimedDevicesAsGrabage(t *testing.T) (
	map[string]interface{},
	*resty.Response,
)

MarkAllUnClaimedDevicesAsGrabage : Mark All UnClaimed Devices As Grabage

func MarkDeviceAsGarbage

func MarkDeviceAsGarbage(t *testing.T, deviceID string) (
	map[string]interface{},
	*resty.Response,
)

MarkDeviceAsGarbage : Mark Device as Garbage

func MarkTrailsAsGarbage

func MarkTrailsAsGarbage(t *testing.T) (
	map[string]interface{},
	*resty.Response,
)

MarkTrailsAsGarbage : Mark Trails as Garbages that lost their parent devices

func ParseDuration

func ParseDuration(str string) time.Duration

ParseDuration : Parse Duration referece : https://stackoverflow.com/questions/28125963/golang-parse-time-duration

func ParseInt64

func ParseInt64(value string) int64

ParseInt64 : ParseInt64

func PopulateStepUsedObjects

func PopulateStepUsedObjects(t *testing.T, stepID string) (
	map[string]interface{},
	*resty.Response,
)

PopulateStepUsedObjects : Populate Step used_objects field

func PopulateStepsUsedObjects

func PopulateStepsUsedObjects(t *testing.T) (
	map[string]interface{},
	*resty.Response,
)

PopulateStepsUsedObjects : Populate Steps used_objects field

func PopulateTrailUsedObjects

func PopulateTrailUsedObjects(t *testing.T, trailID string) (
	map[string]interface{},
	*resty.Response,
)

PopulateTrailUsedObjects : Populate Trail used_objects field

func PopulateTrailsUsedObjects

func PopulateTrailsUsedObjects(t *testing.T) (
	map[string]interface{},
	*resty.Response,
)

PopulateTrailsUsedObjects : Populate Trails used_objects field

func ProcessDeviceGarbages

func ProcessDeviceGarbages(t *testing.T) (
	map[string]interface{},
	*resty.Response,
)

ProcessDeviceGarbages : Process Device Garbages

func ProcessStepGarbages

func ProcessStepGarbages(t *testing.T) (
	map[string]interface{},
	*resty.Response,
)

ProcessStepGarbages : Process Step Garbages

func ProcessTrailGarbages

func ProcessTrailGarbages(t *testing.T) (
	map[string]interface{},
	*resty.Response,
)

ProcessTrailGarbages : Process Device Garbages

func RandStringRunes

func RandStringRunes(n int) string

RandStringRunes : Generate Random string

func RefreshToken

func RefreshToken(t *testing.T, token string) (map[string]interface{}, *resty.Response)

RefreshToken : Refresh Token

func Register

func Register(
	t *testing.T,
	email string,
	password string,
	nick string,
) (
	map[string]interface{},
	*resty.Response,
)

Register : Register user account

func RemoveDevice

func RemoveDevice(
	t *testing.T,
	deviceID string,
) (
	map[string]interface{},
	*resty.Response,
)

RemoveDevice : Delete Device using base API

func ResetCounters

func ResetCounters()

ResetCounters : Reset Counters

func UpdateDeviceMetaDetails

func UpdateDeviceMetaDetails(
	t *testing.T,
	dToken string,
	deviceID string,
	details map[string]interface{},
) (
	map[string]interface{},
	*resty.Response,
)

UpdateDeviceMetaDetails : Update Device Meta Details

func UpdateDeviceNick

func UpdateDeviceNick(
	t *testing.T,
	deviceID string,
	newNick string,
) (
	map[string]interface{},
	*resty.Response,
)

UpdateDeviceNick : Update Device Nick Name

func UpdateDeviceTimeCreated

func UpdateDeviceTimeCreated(t *testing.T, deviceID string, mongoDb *mongo.Database) bool

UpdateDeviceTimeCreated : Update Device timecreated field

func UpdateObjectGarbageRemovalDate

func UpdateObjectGarbageRemovalDate(t *testing.T, objectID string, mongoDb *mongo.Database) bool

UpdateObjectGarbageRemovalDate : Update Object Garbage Removal Date

func UpdateStepGarbageRemovalDate

func UpdateStepGarbageRemovalDate(t *testing.T, stepID string, mongoDb *mongo.Database) bool

UpdateStepGarbageRemovalDate : Update Step Garbage Removal Date

func UpdateStepProgress

func UpdateStepProgress(
	t *testing.T,
	trailID string,
	step string,
	dtoken string,
	progressData map[string]interface{},
) (
	map[string]interface{},
	*resty.Response,
)

UpdateStepProgress : Update Step Progress

func UpdateTrailGarbageRemovalDate

func UpdateTrailGarbageRemovalDate(t *testing.T, trailID string, mongoDb *mongo.Database) bool

UpdateTrailGarbageRemovalDate : Update Trail Garbage Removal Date

func UpdateUserMetaDetails

func UpdateUserMetaDetails(
	t *testing.T,
	deviceID string,
	details map[string]interface{},
) (
	map[string]interface{},
	*resty.Response,
)

UpdateUserMetaDetails : Update User Meta Details of a device

func VerifyUserAccount

func VerifyUserAccount(
	t *testing.T,
	id string,
	challenge string,
) (
	map[string]interface{},
	*resty.Response,
)

VerifyUserAccount : Verify User Account

Types

This section is empty.

Jump to

Keyboard shortcuts

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