public void TestBadAffiliationNameMultipleDots() { HFCAClient client = HFCAClient.Create("http://localhost:99", null); client.CryptoSuite = crypto; client.NewHFCAAffiliation("foo...bar"); }
public void TestReenrollNullUser() { HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null); client.CryptoSuite = crypto; client.Reenroll(null); }
public void TestHFCAIdentityCryptoNull() { HFCAClient client = HFCAClient.Create("http://localhost:99", null); client.CryptoSuite = null; client.NewHFCAIdentity("testid"); }
public void TestNewInstanceWithName() { HFCAClient memberServices = HFCAClient.Create("name", "http://localhost:99", null); Assert.IsNotNull(memberServices); Assert.AreSame(typeof(HFCAClient), memberServices.GetType()); }
public void TestIdemixNullEnrollment() { HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null); client.CryptoSuite = crypto; client.IdemixEnroll(null, "idemixMSP"); }
public void TestHFCAIdentityCryptoNull() { HFCAClient client = HFCAClient.Create("http://localhost:99", null); client.CryptoSuite = null; client.NewHFCAAffiliation("org1"); }
public void TestBadAffiliationNameEndingDot() { HFCAClient client = HFCAClient.Create("http://localhost:99", null); client.CryptoSuite = crypto; client.NewHFCAAffiliation("foo."); }
public void TestHFCAIdentityIDNull() { HFCAClient client = HFCAClient.Create("http://localhost:99", null); client.CryptoSuite = crypto; client.NewHFCAAffiliation(null); }
public void TestRevoke2NullUser() { HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null); client.CryptoSuite = crypto; client.Revoke(null, admin.Name, "keyCompromise"); }
public void TestRevoke2NullEnrollment() { HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null); client.CryptoSuite = crypto; client.Revoke(admin, (string)null, "keyCompromise"); }
public void TestReenrollNullEnrollment() { HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null); client.CryptoSuite = crypto; admin.Enrollment = null; client.Reenroll(admin); }
public void TestNewInstanceWithNameAndProperties() { Properties testProps = new Properties(); HFCAClient memberServices = HFCAClient.Create("name", "http://localhost:99", testProps); Assert.IsNotNull(memberServices); Assert.AreSame(typeof(HFCAClient), memberServices.GetType()); }
public void DeleteAffiliationNoServer() { HFCAClient client = HFCAClient.Create("http://localhost:99", null); client.CryptoSuite = crypto; HFCAAffiliation aff = client.NewHFCAAffiliation("neworg1"); aff.Delete(admin); }
public void TestSetCryptoSuite() { HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null); CryptoPrimitives testcrypt = new CryptoPrimitives(); client.CryptoSuite = testcrypt; Assert.AreEqual(testcrypt, client.CryptoSuite); }
public void GetAffiliationNoServerResponse() { HFCAClient client = HFCAClient.Create("http://localhost:99", null); client.CryptoSuite = crypto; HFCAAffiliation aff = client.NewHFCAAffiliation("neworg1"); aff.Read(admin); }
public void TestIdemixWrongEnrollment() { HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null); client.CryptoSuite = crypto; IEnrollment enrollment = new IdemixEnrollment(null, null, "mspid", null, null, null, "ou", IdemixRoles.MEMBER); client.IdemixEnroll(enrollment, "mspid"); }
public void TestAddCAToURL() { string url = "http://localhost:99"; HFCAClient client = HFCAClient.Create("ca1", url, null); client.CryptoSuite = crypto; string url2 = client.AddCAToURL(url); Assert.AreEqual(url + "?ca=ca1", url2); }
public void DeleteIdentityNoServerResponse() { HFCAClient client = HFCAClient.Create("http://localhost:99", null); client.CryptoSuite = crypto; HFCAIdentity ident = client.NewHFCAIdentity("testuser1"); ident.Delete(admin); }
public void TestRegisterNullRegistrar() { RegistrationRequest regreq = new RegistrationRequest("name", "affiliation"); regreq.EnrollmentID = "abc"; HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null); client.CryptoSuite = crypto; client.Register(regreq, null); }
public void TestRevoke1NullUser() { HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null); client.CryptoSuite = crypto; KeyPair keypair = crypto.KeyGen(); IEnrollment enrollment = new X509Enrollment(keypair, "abc"); client.Revoke(null, enrollment, "keyCompromise"); }
public void GetCertificateNoServerResponse() { HFCAClient client = HFCAClient.Create("http://localhost:99", null); client.CryptoSuite = crypto; HFCACertificateRequest certReq = client.NewHFCACertificateRequest(); client.GetHFCACertificates(admin, certReq); }
public void TestHFCACertificateNewInstance() { HFCAClient client = HFCAClient.Create("http://localhost:99", null); client.CryptoSuite = crypto; HFCACertificateRequest certReq = client.NewHFCACertificateRequest(); Assert.IsNotNull(certReq); Assert.AreEqual(typeof(HFCACertificateRequest).Name, certReq.GetType().Name); }
public void TestHFCAIdentityNewInstance() { HFCAClient client = HFCAClient.Create("http://localhost:99", null); client.CryptoSuite = crypto; HFCAAffiliation aff = client.NewHFCAAffiliation("org1"); Assert.IsNotNull(aff); Assert.AreSame(typeof(HFCAAffiliation), aff.GetType()); }
public void TestHFCAIdentityNewInstance() { HFCAClient client = HFCAClient.Create("http://localhost:99", null); client.CryptoSuite = crypto; HFCAIdentity ident = client.NewHFCAIdentity("testid"); Assert.IsNotNull(ident); Assert.AreSame(typeof(HFCAIdentity), ident.GetType()); Assert.AreEqual(ident.EnrollmentId, "testid"); }
public void TestEnrollmentNoServerResponse() { ICryptoSuite cryptoSuite = Factory.Instance.GetCryptoSuite(); EnrollmentRequest req = new EnrollmentRequest("profile 1", "label 1", null); HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null); client.CryptoSuite = cryptoSuite; client.Enroll(TEST_ADMIN_NAME, TEST_ADMIN_NAME, req); }
public void TestRegisterNoServerResponse() { Properties testProps = new Properties(); HFCAClient client = HFCAClient.Create("client", "https://localhost:99", testProps); CryptoPrimitives testcrypt = new CryptoPrimitives(); client.CryptoSuite = testcrypt; RegistrationRequest regreq = new RegistrationRequest("name", "affiliation"); client.Register(regreq, admin); }
public void TestIdemixMissingMSPID() { HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null); client.CryptoSuite = crypto; var gen = new ECKeyPairGenerator(); var keyGenParam = new KeyGenerationParameters(new SecureRandom(), 256); gen.Init(keyGenParam); KeyPair pair = KeyPair.Create(gen.GenerateKeyPair()); IEnrollment enrollment = new X509Enrollment(pair, ""); client.IdemixEnroll(enrollment, null); }
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); } }
public void TestTLSTrustedCertProperites() { Properties testprops = new Properties(); testprops.Set("pemFile", "fixture/testPems/caBundled.pems".Locate() + "," + // has 3 certs "fixture/testPems/Org1MSP_CA.pem".Locate()); // has 1 testprops.Set("pemBytes", File.ReadAllText("fixture/testPems/Org2MSP_CA.pem".Locate())); CryptoPrimitives cpto = new CryptoPrimitives(); cpto.Init(); HFCAClient client = HFCAClient.Create("client", "https://localhost:99", testprops); client.CryptoSuite = cpto; client.SetUpSSL(); int count = 0; KeyStore trustStore = client.CryptoSuite.Store; List <BigInteger> expected = new List <BigInteger> { new BigInteger("4804555946196630157804911090140692961"), new BigInteger("127556113420528788056877188419421545986539833585"), new BigInteger("704500179517916368023344392810322275871763581896"), new BigInteger("70307443136265237483967001545015671922421894552"), new BigInteger("276393268186007733552859577416965113792") }; foreach (X509Certificate2 cert in trustStore.Certificates.Select(a => a.X509Certificate2)) { BigInteger serialNumber = new BigInteger(cert.SerialNumber.FromHexString()); Assert.IsTrue(expected.Contains(serialNumber), $"Missing certifiate with serial no. {serialNumber}"); ++count; } Assert.AreEqual(expected.Count, count, "Number of CA certificates mismatch"); }
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(); }