assert.Contains(t, err.Error(), "apiProvFuncRole")
}
+ var invalidFuncRole ApiProviderFuncRole = "invalid"
+ funcDetailsUnderTest.ApiProvFuncRole = invalidFuncRole
+ err = funcDetailsUnderTest.Validate()
+ if assert.Error(t, err) {
+ assert.Contains(t, err.Error(), "invalid")
+ assert.Contains(t, err.Error(), "apiProvFuncRole")
+ }
+
funcDetailsUnderTest.ApiProvFuncRole = ApiProviderFuncRoleAEF
err = funcDetailsUnderTest.Validate()
if assert.Error(t, err) {
assert.Contains(t, err.Error(), "apiProvFuncs")
assert.Contains(t, err.Error(), "contains invalid")
}
-}
-func TestUpdateFuncs_addNewFunction(t *testing.T) {
- providerUnderTest := getProvider()
-
- newFuncInfoAEF := "new func as AEF"
- newFuncs := append(*providerUnderTest.ApiProvFuncs, APIProviderFunctionDetails{
- ApiProvFuncInfo: &newFuncInfoAEF,
+ (*providerDetailsUnderTest.ApiProvFuncs)[0] = APIProviderFunctionDetails{
ApiProvFuncRole: ApiProviderFuncRoleAEF,
- })
- providerUnderTest.ApiProvFuncs = &newFuncs
-
- err := providerUnderTest.UpdateFuncs(getProvider())
-
- assert.Nil(t, err)
- assert.Len(t, *providerUnderTest.ApiProvFuncs, 4)
- assert.True(t, providerUnderTest.IsFunctionRegistered("AEF_id_new_func_as_AEF"))
-}
-
-func TestUpdateFuncs_deleteFunction(t *testing.T) {
- providerUnderTest := getProvider()
-
- modFuncs := []APIProviderFunctionDetails{(*providerUnderTest.ApiProvFuncs)[0], (*providerUnderTest.ApiProvFuncs)[1]}
- providerUnderTest.ApiProvFuncs = &modFuncs
-
- err := providerUnderTest.UpdateFuncs(getProvider())
-
- assert.Nil(t, err)
- assert.Len(t, *providerUnderTest.ApiProvFuncs, 2)
- assert.True(t, providerUnderTest.IsFunctionRegistered(funcIdAPF))
- assert.True(t, providerUnderTest.IsFunctionRegistered(funcIdAMF))
+ RegInfo: RegistrationInformation{
+ ApiProvPubKey: "key",
+ },
+ }
+ assert.Nil(t, providerDetailsUnderTest.Validate())
}
-func TestUpdateFuncs_unregisteredFunction(t *testing.T) {
- providerUnderTest := getProvider()
-
- unRegId := "unRegId"
- modFuncs := []APIProviderFunctionDetails{
- {
- ApiProvFuncId: &unRegId,
- },
+func TestValidateAlreadyRegistered(t *testing.T) {
+ regSec := "regSec"
+ providerUnderTest := APIProviderEnrolmentDetails{
+ RegSec: regSec,
}
- providerUnderTest.ApiProvFuncs = &modFuncs
- err := providerUnderTest.UpdateFuncs(getProvider())
- if assert.Error(t, err) {
- assert.Contains(t, err.Error(), unRegId)
- assert.Contains(t, err.Error(), "not registered")
+ otherProvider := APIProviderEnrolmentDetails{
+ RegSec: "otherRegSec",
}
+ assert.Nil(t, providerUnderTest.ValidateAlreadyRegistered(otherProvider))
+
+ otherProvider.RegSec = regSec
+ assert.NotNil(t, providerUnderTest.ValidateAlreadyRegistered(otherProvider))
}
func getProvider() APIProviderEnrolmentDetails {