Exemplo n.º 1
0
 public void TestExtractAgentTwinAndVerify(bool isExceptionExpected, bool expectedResult, TwinConfigSource twinConfigSource, TwinCollection twinDesiredProperties)
 {
     if (isExceptionExpected)
     {
         Assert.Throws <ManifestSigningIsNotEnabledProperly>(() => twinConfigSource.ExtractHubTwinAndVerify(twinDesiredProperties));
     }
     else
     {
         Assert.Equal(expectedResult, twinConfigSource.ExtractHubTwinAndVerify(twinDesiredProperties));
     }
 }
Exemplo n.º 2
0
        public void TestExtractHubTwinAndVerify(string type, string schemaVersion, string algo, string[] signercert, string[] intermediatecacert, string signature)
        {
            var desiredProperties = new
            {
                routes = new
                {
                    route = "FROM /messages/* INTO $upstream"
                },
                schemaVersion,
                storeAndForwardConfiguration = new
                {
                    timeToLiveSecs = 7200
                },
                integrity = new
                {
                    header = new
                    {
                        signercert,
                        intermediatecacert,
                    },
                    signature = new
                    {
                        bytes     = signature,
                        algorithm = algo
                    }
                },
                version = "10"
            };

            TwinCollection twinDesiredProperties = new TwinCollection(JsonConvert.SerializeObject(desiredProperties));

            if (type == "good")
            {
                Assert.True(TwinConfigSource.ExtractHubTwinAndVerify(twinDesiredProperties));
            }
            else
            {
                Assert.False(TwinConfigSource.ExtractHubTwinAndVerify(twinDesiredProperties));
            }
        }