Skip to content

Commit

Permalink
Fix: add OAuth in UDM service request
Browse files Browse the repository at this point in the history
  • Loading branch information
andy89923 committed Mar 6, 2024
1 parent d6681a8 commit 2a2ec51
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions internal/sbi/consumer/subscriber_data_management.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package consumer

import (
"context"

"github.com/antihax/optional"
"github.com/pkg/errors"

Expand Down Expand Up @@ -34,9 +32,14 @@ func SDMGetSmData(smCtx *smf_context.SMContext,

SubscriberDataManagementClient := smf_context.GetSelf().SubscriberDataManagementClient

ctx, pd, oauthErr := smf_context.GetSelf().GetTokenCtx(models.ServiceName_NUDM_SDM, models.NfType_UDM)
if oauthErr != nil {
return pd, oauthErr
}

sessSubData, rsp, localErr := SubscriberDataManagementClient.
SessionManagementSubscriptionDataRetrievalApi.
GetSmData(context.Background(), smCtx.Supi, smDataParams)
GetSmData(ctx, smCtx.Supi, smDataParams)
if localErr == nil {
defer func() {
if rspCloseErr := rsp.Body.Close(); rspCloseErr != nil {
Expand All @@ -56,7 +59,7 @@ func SDMGetSmData(smCtx *smf_context.SMContext,
} else if rsp != nil {
if rsp.Status != localErr.Error() {
err = localErr
return
return nil, err
}
problem := localErr.(openapi.GenericOpenAPIError).Model().(models.ProblemDetails)
problemDetails = &problem
Expand Down Expand Up @@ -87,8 +90,13 @@ func SDMSubscribe(smCtx *smf_context.SMContext, smPlmnID *models.PlmnId) (
PlmnId: smPlmnID,
}

ctx, pd, oauthErr := smf_context.GetSelf().GetTokenCtx(models.ServiceName_NUDM_SDM, models.NfType_UDM)
if oauthErr != nil {
return pd, oauthErr
}

resSubscription, httpResp, localErr := client.SubscriptionCreationApi.Subscribe(
context.Background(), smCtx.Supi, sdmSubscription)
ctx, smCtx.Supi, sdmSubscription)
defer func() {
if httpResp != nil {
if rspCloseErr := httpResp.Body.Close(); rspCloseErr != nil {
Expand Down Expand Up @@ -134,7 +142,12 @@ func SDMUnSubscribe(smCtx *smf_context.SMContext) (problemDetails *models.Proble

subscriptionId := smf_context.GetSelf().Ues.GetSubscriptionId(smCtx.Supi)

httpResp, localErr := client.SubscriptionDeletionApi.Unsubscribe(context.Background(), smCtx.Supi, subscriptionId)
ctx, pd, oauthErr := smf_context.GetSelf().GetTokenCtx(models.ServiceName_NUDM_SDM, models.NfType_UDM)
if oauthErr != nil {
return pd, oauthErr
}

httpResp, localErr := client.SubscriptionDeletionApi.Unsubscribe(ctx, smCtx.Supi, subscriptionId)
defer func() {
if httpResp != nil {
if rspCloseErr := httpResp.Body.Close(); rspCloseErr != nil {
Expand Down

0 comments on commit 2a2ec51

Please sign in to comment.