2daf511c08f3eb7031d8d054b57673e371521370
David Blume Run the test code again wit...

David Blume authored 4 years ago

1) sub init()
2)     m.top.functionName = "executeTest"
David Blume Add test support for DIAL;...

David Blume authored 4 years ago

3)     m.top.ObserveField("pucidHash", "onUpdatePucidHash")
David Blume Run the test code again wit...

David Blume authored 4 years ago

4) end sub
5) 
David Blume Add test support for DIAL;...

David Blume authored 4 years ago

6) 
7) function GetRequest() as object
8)     r = CreateObject("roUrlTransfer")
9)     r.InitClientCertificates()
David Blume Add a certificates file to...

David Blume authored 4 years ago

10)     r.SetCertificatesFile("pkg:/certificates/rokuca.pem")
11)     ' r.SetCertificatesFile("common:/certs/ca-bundle.crt")
David Blume Add test support for DIAL;...

David Blume authored 4 years ago

12) 
13)     r.SetUrl("https://api.roku.com/registrysvc/api/" + CreateObject("roAppInfo").GetDevID())
14)     r.AddHeader("accept", "application/json")
15)     r.AddHeader("content-type", "application/*")
16)     r.AddHeader("x-roku-registry-aes-key-version", "v1")
17)     r.AddHeader("x-roku-reserved-regsvc-token", "")
18) 
19)     ' Note if called from init(), then m.top.pucidHash won't have been set yet.
20)     r.AddHeader("x-roku-registry-aes-encryption-key", m.top.pucidHash)
21) 
22)     print "GetRequest() x-roku-registry-aes-encryption-key:" + m.top.pucidHash
23)     print "             URL:" + r.GetUrl()
24)     return r
25) end function
26) 
27) 
28) function onUpdatePucidHash() as void
29)     ' Maybe do something with m.top.pucidHash
30) end function
31) 
32) 
dblume Add support for printing ro...

dblume authored 1 year ago

33) sub printAA(aa)
34)     for each key in aa.Keys()
35)         val = aa[key]
36)         if type(val) = "roByteArray"
37)             m.top.updateText = "  " + key + " = a byte array"
38)         elseif type(val) = "roArray"
dblume Fix off-by-one loop error

dblume authored 1 year ago

39)             for i=0 to val.Count() - 1
dblume Fix typo in roArray printer

dblume authored 1 year ago

40)                 m.top.updateText = "  " + key + "[" + i.toStr() + "] = " + val[i]
dblume Add support for printing ro...

dblume authored 1 year ago

41)             end for
42)         else
43)             m.top.updateText = "  " + key + " = " + val.ToStr()
44)         endif
45)     end for
46) end sub
47) 
48) 
David Blume Run the test code again wit...

David Blume authored 4 years ago

49) function executeTest() as void
50)     ' This task gets run one at the start, and then
51)     ' again every time the OK button is pressed.
52) 
dblume Add scrolling to right pane

dblume authored 1 year ago

53)     deviceInfo = CreateObject("roDeviceInfo")
54)     aaConnectionInfo = deviceInfo.GetDisplayProperties()
55)     m.top.updateText = "roDeviceInfo.GetDisplayProperties"
dblume Add support for printing ro...

dblume authored 1 year ago

56)     printAA(aaConnectionInfo)
dblume Add scrolling to right pane

dblume authored 1 year ago

57) 
David Blume Run the test code again wit...

David Blume authored 4 years ago

58)     aaConnectionInfo = deviceInfo.GetConnectionInfo()
dblume Sort connection info

dblume authored 1 year ago

59)     m.top.updateText = "roDeviceInfo.GetConnectionInfo"
dblume Add support for printing ro...

dblume authored 1 year ago

60)     printAA(aaConnectionInfo)
David Blume Run the test code again wit...

David Blume authored 4 years ago

61) 
David Blume Add test support for DIAL;...

David Blume authored 4 years ago

62)     request = GetRequest()
63)     port = CreateObject("roMessagePort")
64)     request.SetMessagePort(port)
65) 
David Blume Add some invariant info to...

David Blume authored 4 years ago

66)     requestBody = { "token": "auth" }
67)     res = request.AsyncPostFromString(FormatJson(requestBody))
David Blume Add test support for DIAL;...

David Blume authored 4 years ago

68)     if res = true
69)         msg = wait(0, port)
70)         if type(msg) = "roUrlEvent"
71)             if msg.GetInt() = 1
dblume Sort connection info

dblume authored 1 year ago

72)                 print "PSI Request roUrlEvent = " + msg.GetResponseCode().ToStr()
David Blume Add test support for DIAL;...

David Blume authored 4 years ago

73)             end if
74) '        else if msg = invalid
75) '            request.AsyncCancel()
76)         end if
77)     else
78)         m.top.updateText = "AsyncPostFromString failed"
79)     end if