Documentation ¶
Index ¶
- Constants
- Variables
- func CompareStringArray_NoOrder(strArray1 []string, strArray2 []string) bool
- func GenerateJsonFileWithPolicy(fileNameWithPath string, policy *pmsapi.Policy)
- func GenerateJsonFileWithRolePolicy(fileNameWithPath string, service *pmsapi.RolePolicy)
- func GenerateJsonFileWithService(fileNameWithPath string, service *pmsapi.Service)
- func GeneratePdlFile(fileNameWithPath string, pdlList []string)
- func GetOSEnv(name string, defaultValue string) string
- func InitSpecialNames()
- func PostCreateGetPolicyTest(data interface{}, context *TestContext)
- func PostCreateGetRolePolicyTest(data interface{}, context *TestContext)
- func PostCreateGetServiceTest(data interface{}, context *TestContext)
- func PostGetAllGrantedPermissions(data interface{}, context *TestContext)
- func PostGetAllGrantedRoles(data interface{}, context *TestContext)
- func PostListPolicyTest(data interface{}, context *TestContext)
- func PostListRolePolicyTest(data interface{}, context *TestContext)
- func PostListServiceTest(data interface{}, context *TestContext)
- func PreGetDeletePolicyTest(data interface{}, context *TestContext)
- func RunTestCases(t *testing.T, testcases *[]TestCase, ctx *TestContext)
- func SetOSEnv(name string, value string) error
- func VerifyCmdTestByDefault(data interface{}, context *TestContext) bool
- func VerifyGRpcAllGrantedPermissions(data interface{}, context *TestContext) bool
- func VerifyGRpcAllGrantedRoleResult(data interface{}, context *TestContext) bool
- func VerifyGRpcTestByDefault(data interface{}, context *TestContext) bool
- func VerifyRestTestByDefault(data interface{}, context *TestContext) bool
- type Cmd
- type CmdClient
- type CmdTest
- type CmdTestData
- type GRpcClient
- type GRpcTest
- type GRpcTestData
- type RestClient
- func (client *RestClient) Delete(data interface{}) error
- func (client *RestClient) Get(data interface{}) error
- func (client *RestClient) Post(data interface{}) error
- func (client *RestClient) Prefix() string
- func (client *RestClient) Put(data interface{}) error
- func (client *RestClient) SetBasicAuth(name string, pwd string)
- func (client *RestClient) SetPrefix(newPrefix string)
- func (client *RestClient) SetToken(newToken string)
- func (client *RestClient) Token() string
- type RestTest
- type RestTestData
- type TestCase
- func GetRestTestData_CreatePolicy(step string, srvName string, policyName string, effect string, ...) TestCase
- func GetRestTestData_CreateRolePolicy(step string, srvName string, rolePolicyName string, effect string, ...) TestCase
- func GetRestTestData_CreateService(step string, srvName string) TestCase
- func GetRestTestData_DeleteService(step string, srvName string) TestCase
- func GetTestData_Sleep(sleep int) TestCase
- type TestContext
- type TestExecuter
Constants ¶
const ( PMS_ENDPOINT = "PMS_ENDPOINT" //policy management endpoint ADS_ENDPOINT = "ADS_ENDPOINT" //authorization check endpoint PMS_ADMIN_TOKEN = "PMS_ADMIN_TOKEN" //token when do policy management ADS_ADMIN_TOKEN = "ADS_ADMIN_TOKEN" //token when do authorization check CA_LOCATION = "CA_LOCATION" //CA file absoulute location CERT_LOCATION = "CERT_LOCATION" //CERT file absoulute location KEY_LOCATION = "KEY_LOCATION" //public key file location )
const ( URI_POLICY_MGMT = svcs.PolicyMgmtPath URI_IS_ALLOWD = svcs.PolicyAtzPath + "is-allowed" URI_GRANTED_ROLES = svcs.PolicyAtzPath + "all-granted-roles" URI_GRANTED_PERMS = svcs.PolicyAtzPath + "all-granted-permissions" WAIT_POLICY_Initialize = 500 //ms )
const ( METHOD_CREATE_SERVICE = "createService" METHOD_GET_SERVICE = "getService" //not used in grpc METHOD_QUERY_SERVICE = "queryService" METHOD_DELETE_SERVICE = "deleteService" METHOD_CREATE_POLICY = "createPolicy" METHOD_GET_POLICY = "getPolicy" //not used in grpc METHOD_QUERY_POLICY = "queryPolicy" METHOD_DELETE_POLICY = "deletePolicy" METHOD_CREATE_ROLEPOLICY = "createRolePolicy" METHOD_GET_ROLEPOLICY = "getRolePolicy" //not used in grpc METHOD_QUERY_ROLEPOLICY = "queryRolePolicy" METHOD_DELETE_ROLEPOLICY = "deleteRolePolicy" METHOD_IS_ALLOWED = "isAllowed" METHOD_GET_GRANTED_PERMISSIONS = "getPerssions" METHOD_GET_GRANTED_ROLES = "getRoles" METHOD_SLEEP = "sleep" )
Test Methods for Speedle
const (
ERROR_SPEEDLE_NOT_SUPPORTED = "speedle doesn't support"
)
const (
METHOD_CONFIG = "config"
)
Test Methods for Speedle
const (
SP_APP_NAME = "SP_APP_NAME"
)
Variables ¶
var SpecialNames []string
Functions ¶
func CompareStringArray_NoOrder ¶
CompareStringArray_NoOrder check two string arrays containing same elements ignoring the order
func GenerateJsonFileWithPolicy ¶
generate a json file according to policy object
func GenerateJsonFileWithRolePolicy ¶
func GenerateJsonFileWithRolePolicy(fileNameWithPath string, service *pmsapi.RolePolicy)
generate a json file according to role policy object
func GenerateJsonFileWithService ¶
generate a json file according to service object
func GeneratePdlFile ¶
generate a file according to pdl list
func GetOSEnv ¶
Get OS environment, if not exists, return the default Value
func InitSpecialNames ¶
func InitSpecialNames()
func PostCreateGetPolicyTest ¶
func PostCreateGetPolicyTest(data interface{}, context *TestContext)
*
Function called after create/get policy test Modify the ID in outputBody and expected body
*
func PostCreateGetRolePolicyTest ¶
func PostCreateGetRolePolicyTest(data interface{}, context *TestContext)
*
Function called after create/get role policy test Modify the ID in outputBody and expected body
*
func PostCreateGetServiceTest ¶
func PostCreateGetServiceTest(data interface{}, context *TestContext)
*
Function called after Create or Get service test Modify the ID in outputBody and expected body
*
func PostGetAllGrantedPermissions ¶
func PostGetAllGrantedPermissions(data interface{}, context *TestContext)
Sort the output by resource name string
func PostGetAllGrantedRoles ¶
func PostGetAllGrantedRoles(data interface{}, context *TestContext)
Sort the output by role name string
func PostListPolicyTest ¶
func PostListPolicyTest(data interface{}, context *TestContext)
func PostListRolePolicyTest ¶
func PostListRolePolicyTest(data interface{}, context *TestContext)
*
Function called after List role policy test Modify the ID in outputBody and expected body
*
func PostListServiceTest ¶
func PostListServiceTest(data interface{}, context *TestContext)
*
Function called after listing service test Modify the ID in outputBody and expected body
*
func PreGetDeletePolicyTest ¶
func PreGetDeletePolicyTest(data interface{}, context *TestContext)
Function called before Get/Delete policy/rolepolicy Update the policy/rolepolicy name with ID in the request since we only support get/delete with ID
func RunTestCases ¶
func RunTestCases(t *testing.T, testcases *[]TestCase, ctx *TestContext)
Run a group of Test cases
func VerifyCmdTestByDefault ¶
func VerifyCmdTestByDefault(data interface{}, context *TestContext) bool
Verify CmdTestData By Default
func VerifyGRpcAllGrantedPermissions ¶
func VerifyGRpcAllGrantedPermissions(data interface{}, context *TestContext) bool
VerifyGRpcAllGrantedPermissions verify allGrantedPermissions response
func VerifyGRpcAllGrantedRoleResult ¶
func VerifyGRpcAllGrantedRoleResult(data interface{}, context *TestContext) bool
Verify RestTestData By Default
func VerifyGRpcTestByDefault ¶
func VerifyGRpcTestByDefault(data interface{}, context *TestContext) bool
Verify RestTestData By Default
func VerifyRestTestByDefault ¶
func VerifyRestTestByDefault(data interface{}, context *TestContext) bool
Verify RestTestData By Default
Types ¶
type Cmd ¶
type Cmd struct {
// contains filtered or unexported fields
}
Class for exec.Cmd, standard output & error message & execute error
type CmdClient ¶
type CmdClient struct {
// contains filtered or unexported fields
}
func NewCmdClient_token ¶
Get the test client for Cmd
func (*CmdClient) CreateServiceWithPDL ¶
Create service with PDL file
func (*CmdClient) ExecuteCmd ¶
func (client *CmdClient) ExecuteCmd(parameter string, data *CmdTestData) error
execute spxctl command with specified parameter and test data
type CmdTest ¶
type CmdTest struct {
Client *CmdClient
}
func (*CmdTest) Execute ¶
func (test *CmdTest) Execute(testcase *TestCase, ctx *TestContext) error
Execute current test with test data and context
func (*CmdTest) ParseOutputForCreate ¶
Parse output result for creating service/policy/rolepolicy
func (*CmdTest) ParseOutputForGet ¶
Parse output result for getting service/policy/rolepolicy
func (*CmdTest) PreExecute ¶
func (test *CmdTest) PreExecute(testcase *TestCase, ctx *TestContext) error
Prepare for Test Execution. Set the default func in testcase
type CmdTestData ¶
type CmdTestData struct { Param string //parameter string after spxctl command FileContent interface{} //The content of File (JSON or PDL ) OutputMsg string //Actual output Message OutputBody interface{} //Actual output body for json object ExpectedMsg string //expected message for the command ExpectedBody interface{} //expected body about json object string }
test data for spctl command
type GRpcClient ¶
type GRpcClient struct {
// contains filtered or unexported fields
}
func NewGRpcClient ¶
func NewGRpcClient() *GRpcClient
func (*GRpcClient) CloseConnection ¶
func (gc *GRpcClient) CloseConnection()
func (*GRpcClient) SetupConnection ¶
func (gc *GRpcClient) SetupConnection() error
type GRpcTest ¶
type GRpcTest struct {
Client *GRpcClient
}
func (*GRpcTest) Execute ¶
func (test *GRpcTest) Execute(testcase *TestCase, tc *TestContext) error
Execute current test with test data and context
func (*GRpcTest) PreExecute ¶
func (test *GRpcTest) PreExecute(testcase *TestCase, tc *TestContext) error
Prepare for Test Execution. Set the default func in testcase
type GRpcTestData ¶
type GRpcTestData struct { InputBody interface{} //Optional. Request body for method OutputMsg string //Optional. Actual output Message OutputBody interface{} //Optional. Actual output body for json object ExpectedMsg string //Optional. expected message for the command ExpectedBody interface{} //Optional. expected body about json object string }
-------------------GRpcTest definition------------------------ test data for spxctl command
type RestClient ¶
type RestClient struct {
// contains filtered or unexported fields
}
func NewRestClient ¶
func NewRestClient(endpoint string, curToken string, basicAuthName string, basicAuthPwd string) (*RestClient, error)
Get Rest Client if both curToken and basicAuth are specified, curToken would do effect
func (*RestClient) Delete ¶
func (client *RestClient) Delete(data interface{}) error
Do REST DELETE api method with specified data (RestTestData)
func (*RestClient) Get ¶
func (client *RestClient) Get(data interface{}) error
Do REST GET api method with specified data (RestTestData)
func (*RestClient) Post ¶
func (client *RestClient) Post(data interface{}) error
Do REST POST api method with specified data (RestTestData)
func (*RestClient) Put ¶
func (client *RestClient) Put(data interface{}) error
Do REST PUT api method with specified data (RestTestData)
func (*RestClient) SetBasicAuth ¶
func (client *RestClient) SetBasicAuth(name string, pwd string)
Set baisc auth userName/userPwd of RestClient
func (*RestClient) SetPrefix ¶
func (client *RestClient) SetPrefix(newPrefix string)
Set prefix of RestClient
func (*RestClient) SetToken ¶
func (client *RestClient) SetToken(newToken string)
Set token of RestClient
type RestTest ¶
type RestTest struct {
Client *RestClient
}
Rest Test including RestClient and implementing Executer interface
func (*RestTest) Execute ¶
func (test *RestTest) Execute(testcase *TestCase, ctx *TestContext) error
Execute current test with test data and context
func (*RestTest) PreExecute ¶
func (test *RestTest) PreExecute(testcase *TestCase, ctx *TestContext) error
Prepare for Test Execution. Set the default func in testcase
type RestTestData ¶
type RestTestData struct { URI string ExpectedStatus int InputBody interface{} //input data for test OutputBody interface{} //Actual output data ExpectedBody interface{} //Expected output data // contains filtered or unexported fields }
TestData for REST API testing
type TestCase ¶
type TestCase struct { Name string //Required. test name Enabled bool //Required. test case would be execute or not Executer func() TestExecuter //Required. function to get the client, if not specified, default client would be created accroding to the type of Data Method string //Method for current Testing Data interface{} //Required. The input/output and func used during the test PreTestFunc func(data interface{}, context *TestContext) //Optional. function executed before test. Optional PostTestFunc func(data interface{}, context *TestContext) //Optional. function executed after test/ If not specified, default func would be used VerifyTestFunc func(data interface{}, context *TestContext) bool //Optional. function executed to verify test result. If not specified, default func would be used }
TestCase struct
func GetRestTestData_CreatePolicy ¶
func GetRestTestData_CreatePolicy(step string, srvName string, policyName string, effect string, principals [][]string, resource string, actions []string) TestCase
GetRestTestData for creating policy
func GetRestTestData_CreateRolePolicy ¶
func GetRestTestData_CreateRolePolicy(step string, srvName string, rolePolicyName string, effect string, roles []string, principals []string, resources []string) TestCase
GetRestTestData for creating rolepolicy
func GetRestTestData_CreateService ¶
GetRestTestData for creating service
func GetRestTestData_DeleteService ¶
GetRestTestData for deleting service
func GetTestData_Sleep ¶
Get TestData for sleeping a while (in ms)
func (*TestCase) SetPostTestFunc ¶
func (tc *TestCase) SetPostTestFunc(curFunc func(data interface{}, context *TestContext))
Set PostTestFunc if PostTestFunc is nil
func (*TestCase) SetPreTestFunc ¶
func (tc *TestCase) SetPreTestFunc(curFunc func(data interface{}, context *TestContext))
Set PreTestFunc if PreTestFunc is nil
func (*TestCase) SetVerifyTestFunc ¶
func (tc *TestCase) SetVerifyTestFunc(curFunc func(data interface{}, context *TestContext) bool)
Set VerifyTestFunc if VerifyTestFunc is nil
type TestContext ¶
type TestContext struct { NameIDMap map[string]string //Name:ID map. Name is specified by user, ID is generated by speedle NameObjectMap map[string]interface{} //Name:Object map. FileName string //File Name used in test }
Test context
type TestExecuter ¶
type TestExecuter interface { PreExecute(testcase *TestCase, context *TestContext) (err error) Execute(testcase *TestCase, context *TestContext) (err error) }
Test Executer interface
func NewCmdTest ¶
func NewCmdTest() TestExecuter
func NewGRpcTestExecuter ¶
func NewGRpcTestExecuter() TestExecuter