+ assert.Contains(t, *problemDetails.Cause, "Provider not valid")
+ assert.Contains(t, *problemDetails.Cause, "regSec")
+}
+
+func TestGetExposedFunctionsForPublishingFunction(t *testing.T) {
+ managerUnderTest := NewProviderManager()
+
+ provider := getProvider()
+ provider.ApiProvDomId = &domainID
+ (*provider.ApiProvFuncs)[0].ApiProvFuncId = &funcIdAPF
+ (*provider.ApiProvFuncs)[1].ApiProvFuncId = &funcIdAMF
+ (*provider.ApiProvFuncs)[2].ApiProvFuncId = &funcIdAEF
+ managerUnderTest.registeredProviders[domainID] = provider
+ managerUnderTest.registeredProviders[otherDomainID] = getOtherProvider()
+
+ exposedFuncs := managerUnderTest.GetAefsForPublisher(funcIdAPF)
+ assert.Equal(t, 1, len(exposedFuncs))
+ assert.Equal(t, funcIdAEF, exposedFuncs[0])
+}
+
+func getProvider() provapi.APIProviderEnrolmentDetails {
+ testFuncs := []provapi.APIProviderFunctionDetails{
+ {
+ ApiProvFuncInfo: &funcInfoAPF,
+ ApiProvFuncRole: provapi.ApiProviderFuncRoleAPF,
+ RegInfo: provapi.RegistrationInformation{
+ ApiProvPubKey: "key",
+ },
+ },
+ {
+ ApiProvFuncInfo: &funcInfoAMF,
+ ApiProvFuncRole: provapi.ApiProviderFuncRoleAMF,
+ RegInfo: provapi.RegistrationInformation{
+ ApiProvPubKey: "key",
+ },
+ },
+ {
+ ApiProvFuncInfo: &funcInfoAEF,
+ ApiProvFuncRole: provapi.ApiProviderFuncRoleAEF,
+ RegInfo: provapi.RegistrationInformation{
+ ApiProvPubKey: "key",
+ },
+ },
+ }
+ return provapi.APIProviderEnrolmentDetails{
+ RegSec: "sec",
+ ApiProvDomInfo: &domainInfo,
+ ApiProvFuncs: &testFuncs,
+ }
+
+}
+
+func getOtherProvider() provapi.APIProviderEnrolmentDetails {
+ otherDomainInfo := "other domain"
+ otherFuncInfoAPF := "other as APF"
+ otherApfId := "APF_id_other_as_APF"
+ otherFuncInfoAMF := "other as AMF"
+ otherAmfId := "AMF_id_other_as_AMF"
+ otherFuncInfoAEF := "other as AEF"
+ otherAefId := "AEF_id_other_as_AEF"
+ testFuncs := []provapi.APIProviderFunctionDetails{
+ {
+ ApiProvFuncId: &otherApfId,
+ ApiProvFuncInfo: &otherFuncInfoAPF,
+ ApiProvFuncRole: provapi.ApiProviderFuncRoleAPF,
+ },
+ {
+ ApiProvFuncId: &otherAmfId,
+ ApiProvFuncInfo: &otherFuncInfoAMF,
+ ApiProvFuncRole: provapi.ApiProviderFuncRoleAMF,
+ },
+ {
+ ApiProvFuncId: &otherAefId,
+ ApiProvFuncInfo: &otherFuncInfoAEF,
+ ApiProvFuncRole: provapi.ApiProviderFuncRoleAEF,
+ },
+ }
+ return provapi.APIProviderEnrolmentDetails{
+ ApiProvDomId: &otherDomainID,
+ ApiProvDomInfo: &otherDomainInfo,
+ ApiProvFuncs: &testFuncs,
+ }
+