46773893dfa63835a14b560c90a9e06b87fa74ba
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) 
37)     deviceInfo = CreateObject("roDeviceInfo")
38)     aaConnectionInfo = deviceInfo.GetConnectionInfo()
dblume Sort connection info

dblume authored 1 year ago

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

David Blume authored 4 years ago

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

dblume authored 1 year ago

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

David Blume authored 4 years ago

43)     end for
44) 
David Blume Add test support for DIAL;...

David Blume authored 4 years ago

45)     request = GetRequest()
46)     port = CreateObject("roMessagePort")
47)     request.SetMessagePort(port)
48) 
David Blume Add some invariant info to...

David Blume authored 4 years ago

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

David Blume authored 4 years ago

51)     if res = true
52)         msg = wait(0, port)
53)         if type(msg) = "roUrlEvent"
54)             if msg.GetInt() = 1
dblume Sort connection info

dblume authored 1 year ago

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

David Blume authored 4 years ago

56)             end if
57) '        else if msg = invalid
58) '            request.AsyncCancel()
59)         end if
60)     else
61)         m.top.updateText = "AsyncPostFromString failed"
62)     end if