rokucommunity / rooibos

simple, flexible, fun brightscript test framework for roku scenegraph apps
MIT License
75 stars 29 forks source link

creating MAIN|TASK-only component failed on RENDER thread #117

Closed rl240s closed 3 years ago

rl240s commented 4 years ago

I get this intermittent error, even though my tests are written in a Task node:

> TEST: _verifyRSASignature0 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
BRIGHTSCRIPT: ERROR: roRSA: creating MAIN|TASK-only component failed on RENDER thread: pkg:/components/Crypto.brs(164)

Suspending threads... 
--
Thread selected:  1*   ...Crypto.brs(165)   rsa.SetPublicKey(pemFilePath)
Current Function:
157:      sha256HashHexString = _sha256(messageAsciiString)
158:      sha256HashBA = CreateObject("roByteArray") 
159:      sha256HashBA.FromHexString(sha256HashHexString) 
160:   
161:      signatureBA = CreateObject("roByteArray") 
162:      signatureBA.FromBase64String(signatureBase64) 163:
164:      rsa = CreateObject("roRSA") 
165:*     rsa.SetPublicKey(pemFilePath) 
166:      rsa.SetDigestAlgorithm("sha256") 
167:      result = rsa.Verify(sha256HashBA, signatureBA)
168:      return result 169:  end function Source Digest(s):  pkg: dev 1.0.100 3e0a0bbaa3bd805b892d30ae93993e55
'Dot' Operator attempted with invalid BrightScript Component or interface reference. (runtime error &hec)
165:     rsa.SetPublicKey(pemFilePath) 

Backtrace: 
#4  Function _verifyrsasignature(messageasciistring As String, signaturebase64 As String, pemfilepath As String) As Integer    file/line: pkg:/components/Crypto.brs(165) 
#3  Function xf_verifyrsasignature_test(env As String, expected As Integer) As Void
file/line: pkg:/source/tests/specs/NetworkingTaskTests.brs(735) 
#2  Function rooibos_testrunnermixin_runtestcases(metatestsuite As Dynamic, itgroup As Dynamic, testsuite As Dynamic, totalstatobj As Dynamic, config As Dynamic, runtimeconfig As Dynamic) As Void    file/line: pkg:/source/tests/rooibos/rooibosDist.brs(2552) 
#1  Function rooibos_testrunnermixin_runitgroups(metatestsuite As Dynamic, totalstatobj As Dynamic, testutilsdecoratormethodname As Dynamic, config As Dynamic, runtimeconfig As Dynamic, nodecontext As Dynamic) As Void    file/line: pkg:/source/tests/rooibos/rooibosDist.brs(2501) #0  Function rooibos_runnodetests(args As Dynamic) As Object    file/line: pkg:/source/tests/rooibos/rooibosDist.brs(1868)

Local Variables:
messageasciistring roString (2.1 was String) refcnt=2 val:"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnRJZCI6IjVkNzY1MzM5MzlkNTNhMDAxOTY2NWI4YiIsImFwc"... signaturebase64  roString (2.1 was String) refcnt=2 val:"a+KDfOleRd0D1BlvvGz7FvCpJNMpHXLPcnIsP6qh4gf5DwSsTmzzwH2ifMys3m6ZodoKwehtE9Ek0UxRq6mqQKwbhphaM3"... pemfilepath      roString (2.1 was String) refcnt=2 val:"tmp:/public.pem" global           Interface:ifGlobal m                roAssociativeArray refcnt=7 count:56 sha256hashhexstring roString (2.1 was String) refcnt=1 val:"deff03692d3eb6d9e1ae818d4ed69038c92c75b1c6d0c64d5e9ff6a11acd5148" sha256hashba     roByteArray refcnt=1 signatureba      roByteArray refcnt=1 rsa              Invalid result           <uninitialized> Threads: ID    Location                                Source Code
0[u] ??
1*   ...orkingTask/utils/XFCrypto.brs(165)   rsa.SetPublicKey(pemFilePath)
2    ...kingTask/XFNetworkingTask.brs(110)   msg = wait(m.globalTimeout, m.port)
3    ...kingTask/XFNetworkingTask.brs(110)   msg = wait(m.globalTimeout, m.port)
4    ...kingTask/XFNetworkingTask.brs(110)   msg = wait(m.globalTimeout, m.port)
5    ...kingTask/XFNetworkingTask.brs(110)   msg = wait(m.globalTimeout, m.port)
6    ...kingTask/XFNetworkingTask.brs(110)   msg = wait(m.globalTimeout, m.port)
7    ...kingTask/XFNetworkingTask.brs(110)   msg = wait(m.globalTimeout, m.port)
8    ...kingTask/XFNetworkingTask.brs(110)   msg = wait(m.globalTimeout, m.port)
9    ...kingTask/XFNetworkingTask.brs(110)   msg = wait(m.globalTimeout, m.port)
10[u] ??
11    ...nents/RoxNode/RoxTaskImpl.brs(134)   res = m._http.GetToString()
12    ...kingTask/XFNetworkingTask.brs(110)   msg = wait(m.globalTimeout, m.port)
13[u] ??
*selected   [u]unattached(not debuggable)

This is the test node

<?xml version="1.0" encoding="utf-8" ?>
<component name="NetworkingTaskTestNode" extends="NetworkingTask" xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <interface>
        <function name="Rooibos_RunNodeTests" />
    </interface>
    <script type="text/brightscript" uri="pkg:/source/tests/specs/utils/NetworkingTaskTestUtilities.brs" />
    <!-- Import test framework. -->
    <script type="text/brightscript" uri="pkg:/source/tests/rooibos/rooibosFunctionMap.brs" />
    <script type="text/brightscript" uri="pkg:/source/tests/rooibos/rooibosDist.brs" />
</component>

Networking task extends Task:

<component name="NetworkingTask" extends="Task" xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...

Thanks

georgejecook commented 3 years ago

I have no short term plans to support this. closing