d84dac5ddc5aacc62146d93211bfa541f4f924ce
David Blume Run the test code again wit...

David Blume authored 5 years ago

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

David Blume authored 5 years ago

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

David Blume authored 5 years ago

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

David Blume authored 5 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 5 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 5 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) 
David Blume Run the test code again wit...

David Blume authored 5 years ago

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

dblume authored 2 years ago

37)     deviceInfo = CreateObject("roDeviceInfo")
38)     aaConnectionInfo = deviceInfo.GetDisplayProperties()
39)     m.top.updateText = "roDeviceInfo.GetDisplayProperties"
40)     for each key in aaConnectionInfo.Keys()
41)         val = aaConnectionInfo[key]
dblume Defensive code for AA data...

dblume authored 2 years ago

42)         if type(aaConnectionInfo[key]) <> "roByteArray"
43)             m.top.updateText = "  " + key + " = " + val.ToStr()
44)         else
45)             m.top.updateText = "  " + key + " = a byte array"
46)         endif
dblume Add scrolling to right pane

dblume authored 2 years ago

47)     end for
48) 
David Blume Run the test code again wit...

David Blume authored 5 years ago

49)     deviceInfo = CreateObject("roDeviceInfo")
50)     aaConnectionInfo = deviceInfo.GetConnectionInfo()
dblume Sort connection info

dblume authored 2 years ago

51)     m.top.updateText = "roDeviceInfo.GetConnectionInfo"
52)     for each key in aaConnectionInfo.Keys()
David Blume Run the test code again wit...

David Blume authored 5 years ago

53)         val = aaConnectionInfo[key]
dblume Defensive code for AA data...

dblume authored 2 years ago

54)         if type(aaConnectionInfo[key]) <> "roByteArray"
55)             m.top.updateText = "  " + key + " = " + val.ToStr()
56)         else
57)             m.top.updateText = "  " + key + " = a byte array"
58)         endif
David Blume Run the test code again wit...

David Blume authored 5 years ago

59)     end for
60) 
David Blume Add test support for DIAL;...

David Blume authored 5 years ago

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

David Blume authored 4 years ago

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

David Blume authored 5 years ago

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

dblume authored 2 years ago

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

David Blume authored 5 years ago

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