Untitled
unknown
plain_text
18 days ago
5.0 kB
3
Indexable
@Then("The IPVS live stream v5 call with valid headers {string} and {string} and {string} should return expected stream data structure") public void request_and_verify_ipvs_live_streamv5_data(String xAccountId, String xMso, String ip) throws JSONException { softAssertionErrors.clear(); String ncsServiceId = getNcsServiceIdFromChannelsV3(xAccountId, xMso, ip); JSONObject requestBody = new JSONObject(); try { requestBody.put("deviceCapabilities", props().getDeviceCapabilities()); } catch (IllegalArgumentException e) { JSONObject deviceCapabilities = new JSONObject(); deviceCapabilities.put("packaging", "dash"); deviceCapabilities.put("drm", "cenc"); JSONArray audioCodecs = new JSONArray(); audioCodecs.add("aac"); audioCodecs.add("ac3"); audioCodecs.add("eac3"); deviceCapabilities.put("audioCodecs", audioCodecs); JSONArray videoCodecs = new JSONArray(); videoCodecs.add("avc"); videoCodecs.add("hevc"); deviceCapabilities.put("videoCodecs", videoCodecs); JSONArray videoFormats = new JSONArray(); videoFormats.add("HDR"); videoFormats.add("4K"); deviceCapabilities.put("videoFormats", videoFormats); requestBody.put("deviceCapabilities", deviceCapabilities); } ServiceApiResponse ipvsResponse = restIPVS().apiSmarttvStreamLiveV5(xAccountId, xMso, ip, ncsServiceId) .post(requestBody.toString()); assertTrue(ipvsResponse.isSuccess(), "Call failed with " + ipvsResponse.status() + " and TXID: " + ipvsResponse.txId()); JSON json = ipvsResponse.json(); softAssert(json.size()>0, "Response object should not be empty"); validateStreamV5Response(json); assertSoftAssertions(); } public void validateStreamV5Response(JSON json) { // Required fields for v5 response based on actual Postman response final String[] REQUIRED_STREAM_V5_FIELDS = { "altContent", "initLocation", "streamUrl", "dai", "drm", "packaging", "videoCodec", "videoFormat", "drmContentId", "outputFeedId", "jwtToken", "streamableLocations" }; for (String field : REQUIRED_STREAM_V5_FIELDS) { softAssert(json.hasField(field), "Response is missing field: " + field); } if (json.hasField("initLocation")) { JSON initLocation = json.get("initLocation"); final String[] REQUIRED_INITLOCATION_V5_FIELDS = { "OTT", "behindOwnModem", "inMarket", "inUS", "inUsOrTerritory", "ip", "mso", "geoZip", "serviceZip", "stateAbbr", "trafficOriginId" }; for (String field : REQUIRED_INITLOCATION_V5_FIELDS) { softAssert(initLocation.hasField(field), "initLocation object missing field: " + field); } if (initLocation.hasField("ip")) { softAssert(initLocation.get("ip").toString().equals(ip), "IP in initLocation should match requested IP"); } } if (json.hasField("jwtToken")) { softAssert(json.get("jwtToken") instanceof String && !json.get("jwtToken").toString().isEmpty(), "jwtToken should be a non-empty string"); } if (json.hasField("streamableLocations")) { softAssert(json.get("streamableLocations") instanceof JSONArray, "streamableLocations should be an array"); JSON locations = json.get("streamableLocations"); softAssert(locations.size() > 0, "streamableLocations should not be empty"); } } // Extending the IPVSApiController with v5 endpoint method public class IPVSApiController { // Existing code... public IPVSApiController apiSmarttvStreamLiveV5(String xAccountId, String xMso, String xPiForwardedFor, String ncsServiceId) { request.reset(); request.path(API); request.path(SMARTTV); request.path(STREAM); request.path(LIVE); request.path(V5); request.path(ncsServiceId); request.query("drm-supported", true); request.query("dai-supported", true); request.query("adId", "f0d065cc-ab18-4849-b01e-02f22fcfc861"); request.query("lat", 0); request.query("vast-supported", true); request.query("secureTransport", true); request.query("use_token", true); request.query("clientType", "stva-ipstbxumo"); request.query("sessionId", UUID.randomUUID().toString()); request.query("cdn_profile", "stvaAkamaiLab"); if (xAccountId != null) { headerXAccountid(xAccountId); } if (xMso != null) { headerXMso(xMso); } if (xPiForwardedFor != null) { headerXPiForwardedFor(xPiForwardedFor); } request.header("Content-Type", "application/json"); request.header("x-request-id", UUID.randomUUID().toString()); request.header("x-in-home", "true"); return this; } }
Editor is loading...
Leave a Comment