Esempio n. 1
0
        public void Ctor_Identity_Certificates()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(7, 0))
            {
                Assert.Ignore("requires iOS7+");
            }

            using (var id = IdentityTest.GetIdentity())
                using (var trust = new SecTrust(id.Certificate, SecPolicy.CreateBasicX509Policy()))
                    using (var peer = new MCPeerID("me")) {
                        SecCertificate [] certs = new SecCertificate [trust.Count];
                        for (int i = 0; i < trust.Count; i++)
                        {
                            certs [i] = trust [i];
                        }

                        using (var s = new MCSession(peer, id, certs, MCEncryptionPreference.Required)) {
                            Assert.AreSame(s.MyPeerID, peer, "MyPeerID");
                            // it's a self-signed certificate that's used for the identity
                            // so it's not added twice to the collection being returned
                            Assert.That(s.SecurityIdentity.Count, Is.EqualTo(1), "SecurityIdentity");
                            Assert.That(s.SecurityIdentity.GetItem <SecIdentity> (0).Handle, Is.EqualTo(certs [0].Handle), "SecurityIdentity");
                            Assert.That(s.EncryptionPreference, Is.EqualTo(MCEncryptionPreference.Required), "EncryptionPreference");
                            Assert.That(s.ConnectedPeers, Is.Empty, "ConnectedPeers");
                        }
                    }
        }
Esempio n. 2
0
        public void Ctor_Identity_Certificates()
        {
            TestRuntime.AssertSystemVersion(ApplePlatform.iOS, 7, 0, throwIfOtherPlatform: false);
            TestRuntime.AssertSystemVersion(ApplePlatform.MacOSX, 10, 10, throwIfOtherPlatform: false);

            using (var id = IdentityTest.GetIdentity())
                using (var trust = new SecTrust(id.Certificate, SecPolicy.CreateBasicX509Policy()))
                    using (var peer = new MCPeerID("me")) {
                        SecCertificate [] certs = new SecCertificate [trust.Count];
                        for (int i = 0; i < trust.Count; i++)
                        {
                            certs [i] = trust [i];
                        }

                        using (var s = new MCSession(peer, id, certs, MCEncryptionPreference.Required)) {
                            Assert.AreSame(s.MyPeerID, peer, "MyPeerID");
                            // it's a self-signed certificate that's used for the identity
                            // so it's not added twice to the collection being returned
                            Assert.That(s.SecurityIdentity.Count, Is.EqualTo((nuint)1), "SecurityIdentity");
                            Assert.That(s.SecurityIdentity.GetItem <SecIdentity> (0).Handle, Is.EqualTo(certs [0].Handle), "SecurityIdentity");
                            Assert.That(s.EncryptionPreference, Is.EqualTo(MCEncryptionPreference.Required), "EncryptionPreference");
                            Assert.That(s.ConnectedPeers, Is.Empty, "ConnectedPeers");
                        }
                    }
        }
Esempio n. 3
0
        public void Ctor_Identity()
        {
            TestRuntime.AssertSystemVersion(PlatformName.iOS, 7, 0, throwIfOtherPlatform: false);
            TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 10, throwIfOtherPlatform: false);

            using (var id = IdentityTest.GetIdentity())
                using (var peer = new MCPeerID("me"))
                    using (var s = new MCSession(peer, id, MCEncryptionPreference.Required)) {
                        Assert.AreSame(s.MyPeerID, peer, "MyPeerID");
                        Assert.That(s.SecurityIdentity.Count, Is.EqualTo((nuint)1), "SecurityIdentity");
                        Assert.That(s.SecurityIdentity.GetItem <SecIdentity> (0).Handle, Is.EqualTo(id.Handle), "SecurityIdentity");
                        Assert.That(s.EncryptionPreference, Is.EqualTo(MCEncryptionPreference.Required), "EncryptionPreference");
                        Assert.That(s.ConnectedPeers, Is.Empty, "ConnectedPeers");
                    }
        }
Esempio n. 4
0
        public void Ctor_Identity()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(7, 0))
            {
                Assert.Ignore("requires iOS7+");
            }

            using (var id = IdentityTest.GetIdentity())
                using (var peer = new MCPeerID("me"))
                    using (var s = new MCSession(peer, id, MCEncryptionPreference.Required)) {
                        Assert.AreSame(s.MyPeerID, peer, "MyPeerID");
                        Assert.That(s.SecurityIdentity.Count, Is.EqualTo((nuint)1), "SecurityIdentity");
                        Assert.That(s.SecurityIdentity.GetItem <SecIdentity> (0).Handle, Is.EqualTo(id.Handle), "SecurityIdentity");
                        Assert.That(s.EncryptionPreference, Is.EqualTo(MCEncryptionPreference.Required), "EncryptionPreference");
                        Assert.That(s.ConnectedPeers, Is.Empty, "ConnectedPeers");
                    }
        }