Skip to content

Commit

Permalink
Issue KN-1096 fix: removed unused code and veriables
Browse files Browse the repository at this point in the history
  • Loading branch information
pallakartheekreddy committed Jun 19, 2024
1 parent c2bd021 commit 6f3aebc
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 6f3aebc

Please sign in to comment.