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

David Blume authored 4 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 1 year 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]
42)         m.top.updateText = "  " + key + " = " + val.ToStr()
43)     end for
44) 
David Blume Run the test code again wit...

David Blume authored 4 years ago

45)     deviceInfo = CreateObject("roDeviceInfo")
46)     aaConnectionInfo = deviceInfo.GetConnectionInfo()
dblume Sort connection info

dblume authored 1 year ago

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

David Blume authored 4 years ago

49)         val = aaConnectionInfo[key]
dblume Sort connection info

dblume authored 1 year ago

50)         m.top.updateText = "  " + key + " = " + val.ToStr()
David Blume Run the test code again wit...

David Blume authored 4 years ago

51)     end for
52) 
David Blume Add test support for DIAL;...

David Blume authored 4 years ago

53)     request = GetRequest()
54)     port = CreateObject("roMessagePort")
55)     request.SetMessagePort(port)
56) 
David Blume Add some invariant info to...

David Blume authored 4 years ago

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

David Blume authored 4 years ago

59)     if res = true
60)         msg = wait(0, port)
61)         if type(msg) = "roUrlEvent"
62)             if msg.GetInt() = 1
dblume Sort connection info

dblume authored 1 year ago

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

David Blume authored 4 years ago

64)             end if
65) '        else if msg = invalid
66) '            request.AsyncCancel()
67)         end if
68)     else
69)         m.top.updateText = "AsyncPostFromString failed"
70)     end if