From 6f3aebc95a4839cf637aab710aeb2f857e4d801b Mon Sep 17 00:00:00 2001 From: Kartheek Palla Date: Wed, 19 Jun 2024 14:08:00 +0530 Subject: [PATCH] Issue KN-1096 fix: removed unused code and veriables --- .../resources/video-stream-generator.conf | 42 ------------------- .../service/AzureMediaService.scala | 27 +----------- .../VideoStreamGeneratorTaskTestSpec.scala | 4 +- .../service/VideoStreamServiceTestSpec.scala | 2 +- 4 files changed, 4 insertions(+), 71 deletions(-) diff --git a/video-stream-generator/src/main/resources/video-stream-generator.conf b/video-stream-generator/src/main/resources/video-stream-generator.conf index c758d40ad..f38d0f433 100644 --- a/video-stream-generator/src/main/resources/video-stream-generator.conf +++ b/video-stream-generator/src/main/resources/video-stream-generator.conf @@ -24,41 +24,6 @@ service { } # Azure Media Service Config -azure { - location = "centralindia" - tenant = "tenant" - subscription_id = "subscription id " - - login { - endpoint="https://login.microsoftonline.com" - } - - api { - endpoint="https://management.azure.com" - version = "2018-07-01" - } - - account_name = "account name" - resource_group_name = "group name" - - transform { - default = "media_transform_default" - hls = "media_transform_hls" - } - - stream { - base_url = "https://sunbirdspikemedia-inct.streaming.media.azure.net" - endpoint_name = "default" - protocol = "Hls" - policy_name = "Predefined_ClearStreamingOnly" - } - - token { - client_key = "client key" - client_secret = "client secret" - } -} - azure_mediakind{ project_name="subscriptionname" auth_token="authToken" @@ -77,13 +42,6 @@ azure_mediakind{ } } -azure_tenant="tenant" -azure_subscription_id="subscription id" -azure_account_name="account name" -azure_resource_group_name="group name" -azure_token_client_key="client key" -azure_token_client_secret="client secret" - # CSP Name. e.g: aws or azure media_service_type="oci" diff --git a/video-stream-generator/src/main/scala/org/sunbird/job/videostream/service/AzureMediaService.scala b/video-stream-generator/src/main/scala/org/sunbird/job/videostream/service/AzureMediaService.scala index 774990630..566d4a42b 100644 --- a/video-stream-generator/src/main/scala/org/sunbird/job/videostream/service/AzureMediaService.scala +++ b/video-stream-generator/src/main/scala/org/sunbird/job/videostream/service/AzureMediaService.scala @@ -13,32 +13,7 @@ import scala.collection.immutable.HashMap abstract class AzureMediaService extends IMediaService { private var API_ACCESS_TOKEN: String = "" - private def getToken()(implicit config: VideoStreamGeneratorConfig, httpUtil: HttpUtil): String = { - val tenant = config.getSystemConfig("azure.tenant") - val clientKey = config.getSystemConfig("azure.token.client_key") - val clientSecret = config.getSystemConfig("azure.token.client_secret") - val loginUrl = config.getConfig("azure.login.endpoint") + "/" + tenant + "/oauth2/token" - - val data = Map[String, String]( - "grant_type" -> "client_credentials", - "client_id" -> clientKey, - "client_secret" -> clientSecret, - "resource" -> "https://management.core.windows.net/" - ) - - val header = Map[String, String]( - "Content-Type" -> "application/x-www-form-urlencoded", - "Keep-Alive" -> "true" - ) - - val response:MediaResponse = Response.getResponse(httpUtil.post_map(loginUrl, data, header)) - if(response.responseCode == "OK"){ - response.result("access_token").asInstanceOf[String] - } else { - throw new Exception("Error while getting the azure access token::"+JSONUtil.serialize(response)) - } - } - + protected def getJobDetails(jobId: String)(implicit config: VideoStreamGeneratorConfig, httpUtil: HttpUtil): MediaResponse = { val url = getApiUrl("job").replace("jobIdentifier", jobId) val response:MediaResponse = Response.getResponse(httpUtil.get(url, getDefaultHeader())) diff --git a/video-stream-generator/src/test/scala/org/sunbird/job/spec/VideoStreamGeneratorTaskTestSpec.scala b/video-stream-generator/src/test/scala/org/sunbird/job/spec/VideoStreamGeneratorTaskTestSpec.scala index cff9e7e32..8ee7580e5 100644 --- a/video-stream-generator/src/test/scala/org/sunbird/job/spec/VideoStreamGeneratorTaskTestSpec.scala +++ b/video-stream-generator/src/test/scala/org/sunbird/job/spec/VideoStreamGeneratorTaskTestSpec.scala @@ -80,8 +80,8 @@ class VideoStreamGeneratorTaskTestSpec extends BaseTestSpec { ignore should "submit a job" in { when(mockKafkaUtil.kafkaJobRequestSource[Event](jobConfig.kafkaInputTopic)).thenReturn(new VideoStreamGeneratorMapSource) - when(mockHttpUtil.post_map(contains("/oauth2/token"), any[Map[String, AnyRef]](), any[Map[String, String]]())).thenReturn(HTTPResponse(200, accessTokenResp)) - when(mockHttpUtil.put(contains("/providers/Microsoft.Media/mediaServices/"+jobConfig.getSystemConfig("azure.account.name")+"/assets/asset-"), anyString(), any())).thenReturn(HTTPResponse(200, assetJson)) + // when(mockHttpUtil.post_map(contains("/oauth2/token"), any[Map[String, AnyRef]](), any[Map[String, String]]())).thenReturn(HTTPResponse(200, accessTokenResp)) + when(mockHttpUtil.put(contains(jobConfig.getConfig("azure_mediakind.project_name")+"/assets/asset-"), anyString(), any())).thenReturn(HTTPResponse(200, assetJson)) when(mockHttpUtil.put(contains("transforms/media_transform_default/jobs"), anyString(), any())).thenReturn(HTTPResponse(200, submitJobJson)) when(mockHttpUtil.get(contains("transforms/media_transform_default/jobs"), any())).thenReturn(HTTPResponse(200, getJobJson)) diff --git a/video-stream-generator/src/test/scala/org/sunbird/job/spec/service/VideoStreamServiceTestSpec.scala b/video-stream-generator/src/test/scala/org/sunbird/job/spec/service/VideoStreamServiceTestSpec.scala index 9ca159ff1..40c1158fc 100644 --- a/video-stream-generator/src/test/scala/org/sunbird/job/spec/service/VideoStreamServiceTestSpec.scala +++ b/video-stream-generator/src/test/scala/org/sunbird/job/spec/service/VideoStreamServiceTestSpec.scala @@ -57,7 +57,7 @@ class VideoStreamServiceTestSpec extends BaseTestSpec { } "VideoStreamService" should "submit job request" in { - when(mockHttpUtil.post_map(contains("/oauth2/token"), any[Map[String, AnyRef]](), any[Map[String, String]]())).thenReturn(HTTPResponse(200, accessTokenResp)) + // when(mockHttpUtil.post_map(contains("/oauth2/token"), any[Map[String, AnyRef]](), any[Map[String, String]]())).thenReturn(HTTPResponse(200, accessTokenResp)) when(mockHttpUtil.put(contains(jobConfig.getConfig("azure_mediakind.project_name")+"/assets/asset-"), anyString(), any())).thenReturn(HTTPResponse(200, assetJson)) when(mockHttpUtil.put(contains("transforms/media_transform_default/jobs"), anyString(), any())).thenReturn(HTTPResponse(200, submitJobJson)) when(mockHttpUtil.get(contains("transforms/media_transform_default/jobs"), any())).thenReturn(HTTPResponse(200, getJobJson))