コード例 #1
0
        public void CheckConfig()
        {
            Util.COut("\n\n\nRUNNING: UpdateChannelIT\n");
            TestUtils.TestUtils.ResetConfig();
            configHelper.CustomizeConfig();
//        Assert.AreEqual(256, Config.GetConfig().GetSecurityLevel());

            testSampleOrgs = testConfig.GetIntegrationTestsSampleOrgs();
        }
コード例 #2
0
        public virtual void CheckConfig()
        {
            Util.COut("\n\n\nRUNNING: {0}.\n", testName);

            //      configHelper.clearConfig();
            TestUtils.TestUtils.ResetConfig();
            configHelper.CustomizeConfig();
            //      Assert.AreEqual(256, Config.getConfig().getSecurityLevel());

            testSampleOrgs = testConfig.GetIntegrationTestsSampleOrgs();
            //Set up hfca for each sample org

            foreach (SampleOrg sampleOrg in testSampleOrgs)
            {
                string caURL = sampleOrg.CALocation;
                sampleOrg.CAClient = HFCAClient.Create(caURL, null);
            }
        }
コード例 #3
0
        public static void doMainSetup(TestContext context)
        {
            Util.COut("\n\n\nRUNNING: NetworkConfigIT.\n");

            TestUtils.TestUtils.ResetConfig();
            configHelper.CustomizeConfig();

            // Use the appropriate TLS/non-TLS network config file
            networkConfig = NetworkConfig.FromYamlFile(testConfig.GetTestNetworkConfigFileYAML());

            networkConfig.OrdererNames.ForEach(ordererName =>
            {
                try
                {
                    Properties ordererProperties = networkConfig.GetOrdererProperties(ordererName);
                    Properties testProp          = testConfig.GetEndPointProperties("orderer", ordererName);
                    ordererProperties.Set("clientCertFile", testProp.Get("clientCertFile"));
                    ordererProperties.Set("clientKeyFile", testProp.Get("clientKeyFile"));
                    networkConfig.SetOrdererProperties(ordererName, ordererProperties);
                }
                catch (ArgumentException e)
                {
                    throw new System.Exception(e.Message, e);
                }
            });

            networkConfig.PeerNames.ForEach(peerName =>
            {
                try
                {
                    Properties peerProperties = networkConfig.GetPeerProperties(peerName);
                    Properties testProp       = testConfig.GetEndPointProperties("peer", peerName);
                    peerProperties.Set("clientCertFile", testProp.Get("clientCertFile"));
                    peerProperties.Set("clientKeyFile", testProp.Get("clientKeyFile"));
                    networkConfig.SetPeerProperties(peerName, peerProperties);
                }
                catch (ArgumentException e)
                {
                    throw new System.Exception(e.Message, e);
                }
            });

            networkConfig.EventHubNames.ForEach(eventhubName =>
            {
                try
                {
                    Properties eventHubsProperties = networkConfig.GetEventHubsProperties(eventhubName);
                    Properties testProp            = testConfig.GetEndPointProperties("peer", eventhubName);
                    eventHubsProperties.Set("clientCertFile", testProp.Get("clientCertFile"));
                    eventHubsProperties.Set("clientKeyFile", testProp.Get("clientKeyFile"));
                    networkConfig.SetEventHubProperties(eventhubName, eventHubsProperties);
                }
                catch (ArgumentException e)
                {
                    throw new System.Exception(e.Message, e);
                }
            });

            //Check if we get access to defined CAs!
            NetworkConfig.OrgInfo org    = networkConfig.GetOrganizationInfo("Org1");
            NetworkConfig.CAInfo  caInfo = org.CertificateAuthorities[0];

            HFCAClient hfcaClient = HFCAClient.Create(caInfo);

            Assert.AreEqual(hfcaClient.CAName, caInfo.CAName);
            HFCAInfo info = hfcaClient.Info(); //makes actual REST call.

            Assert.AreEqual(caInfo.CAName, info.CAName);

            List <NetworkConfig.UserInfo> registrars = caInfo.Registrars;

            Assert.IsTrue(registrars.Count > 0);
            NetworkConfig.UserInfo registrar = registrars.First();
            registrar.Enrollment = hfcaClient.Enroll(registrar.Name, registrar.EnrollSecret);
            TestUtils.TestUtils.MockUser mockuser = TestUtils.TestUtils.GetMockUser(org.Name + "_mock_" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), registrar.MspId);
            RegistrationRequest          rr       = new RegistrationRequest(mockuser.Name, "org1.department1");

            mockuser.EnrollmentSecret = hfcaClient.Register(rr, registrar);
            mockuser.Enrollment       = hfcaClient.Enroll(mockuser.Name, mockuser.EnrollmentSecret);
            orgRegisteredUsers.Add(org.Name, mockuser);

            org    = networkConfig.GetOrganizationInfo("Org2");
            caInfo = org.CertificateAuthorities[0];

            hfcaClient = HFCAClient.Create(caInfo);
            Assert.AreEqual(hfcaClient.CAName, caInfo.CAName);
            info = hfcaClient.Info(); //makes actual REST call.
            Assert.AreEqual(info.CAName, "");

            registrars = caInfo.Registrars;
            Assert.IsTrue(registrars.Count > 0);
            registrar            = registrars.First();
            registrar.Enrollment = hfcaClient.Enroll(registrar.Name, registrar.EnrollSecret);
            mockuser             = TestUtils.TestUtils.GetMockUser(org.Name + "_mock_" + DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), registrar.MspId);
            rr = new RegistrationRequest(mockuser.Name, "org1.department1");
            mockuser.EnrollmentSecret = hfcaClient.Register(rr, registrar);
            mockuser.Enrollment       = hfcaClient.Enroll(mockuser.Name, mockuser.EnrollmentSecret);
            orgRegisteredUsers.Add(org.Name, mockuser);

            DeployChaincodeIfRequired();
        }