private WiFiKeyType GetKeyType(string source)
        {
            WiFiKeyType wiFiKeyType = default(WiFiKeyType);

            switch (source)
            {
            case "networkKey":
                wiFiKeyType = WiFiKeyType.NetworkKey;
                break;

            case "passPhrase":
                wiFiKeyType = WiFiKeyType.PassPhrase;
                break;
            }

            return(wiFiKeyType);
        }
 public Profile(Guid id, bool isConnected, string profileName, string ssid,
                WiFiProfileType profileType, WiFiBssType bssType, WiFiAuthentication authentication,
                WiFiEncryptionType encryption, WiFiKeyType keyType, bool keyIsEncrypted, string keyValue,
                bool isAutoConnectEnabled, bool isAutoSwitchEnabled, string xml, int position)
 {
     Id                   = id;
     IsConnected          = isConnected;
     ProfileName          = profileName;
     Ssid                 = ssid;
     ProfileType          = profileType;
     BssType              = bssType;
     Authentication       = authentication;
     Encryption           = encryption;
     KeyType              = keyType;
     KeyIsEncrypted       = keyIsEncrypted;
     KeyValue             = keyValue;
     IsAutoConnectEnabled = isAutoConnectEnabled;
     IsAutoSwitchEnabled  = isAutoSwitchEnabled;
     Xml                  = xml;
     Position             = position;
 }
        /// <summary>
        /// Converts enum KeyTypeMode (ManagedNativeWifi) to internal type WiFiKeyType.
        /// </summary>
        private WiFiKeyType KeyTypeModeConverter(KeyTypes keyType)
        {
            WiFiKeyType wiFiKeyType = default(WiFiKeyType);

            switch (keyType)
            {
            case KeyTypes.None:
                wiFiKeyType = WiFiKeyType.None;
                break;

            case KeyTypes.NetworkKey:
                wiFiKeyType = WiFiKeyType.NetworkKey;
                break;

            case KeyTypes.PassPhrase:
                wiFiKeyType = WiFiKeyType.PassPhrase;
                break;
            }

            return(wiFiKeyType);
        }
예제 #4
0
        /// <summary>
        /// Validates the profile Parser method.
        /// </summary>
        /// <param name="index">Index of testcase see ProfileTestCases.</param>
        /// <param name="profileXml">Example profile used to call Parser method.</param>
        /// <param name="authentication">Authentication type of access point.</param>
        /// <param name="encryption">Encryption type of access point.</param>
        /// <param name="ssid">Ssid of access point.</param>
        /// <param name="bssType">BssType of access point.</param>
        /// <param name="IsAutoConnectEnabled">Is profile auto connectable.</param>
        /// <param name="IsAutoSwitchEnabled">Is auto switch enabled.</param>
        /// <param name="keyType">KeyType of access point.</param>
        /// <param name="keyIsEncrypted">Key/password specified in profile is encrypted or not.</param>
        /// <param name="password">Password needed to connect to access point, null if open access point.</param>
        public void ValidateProfileParser(int index, string profileXml,
                                          WiFiAuthentication authentication, WiFiEncryptionType encryption,
                                          string ssid, WiFiBssType bssType, bool IsAutoConnectEnabled,
                                          bool IsAutoSwitchEnabled, WiFiKeyType keyType, bool keyIsEncrypted, string password)
        {
            /* Attributes of generated profile are returned in profile object. */
            Profile profile = new Profile();
            bool    result  = _profileService.Parse(profileXml, ref profile);

            Assert.IsTrue(result, $"Testcase[{index}]: failed to parse example profile.");
            /* Validate attributes of generated profile. */
            Assert.AreEqual(authentication, profile.Authentication, $"Testcase[{index}]: failed to validate authentication.");
            Assert.AreEqual(encryption, profile.Encryption, $"Testcase[{index}]: failed to validate encryption.");
            Assert.AreEqual(ssid, profile.Ssid, $"Testcase[{index}]: failed to validate ssid.");
            Assert.AreEqual(ssid, profile.ProfileName, $"Testcase[{index}]: failed to validate profile name.");
            Assert.AreEqual(bssType, profile.BssType, $"Testcase[{index}]: failed to validate profile BSS type.");
            Assert.AreEqual(IsAutoConnectEnabled, profile.IsAutoConnectEnabled, $"Testcase[{index}]: failed to validate profile automatic connection property.");
            Assert.AreEqual(IsAutoSwitchEnabled, profile.IsAutoSwitchEnabled, $"Testcase[{index}]: failed to validate profile automatic switch property.");
            Assert.AreEqual(keyType, profile.KeyType, $"Testcase[{index}]: failed to validate wireless profile KeyType.");
            Assert.AreEqual(keyIsEncrypted, profile.KeyIsEncrypted, $"Testcase[{index}]: failed to validate profile property KeyIsEncrypted.");
            Assert.AreEqual(password, profile.KeyValue, $"Testcase[{index}]: wireless profile password is not equal to expected password.");
        }
예제 #5
0
        /// <summary>
        /// Validates the profile creation process for different encryption and authentication types.
        /// </summary>
        /// <param name="authentication">Authentication type of access point.</param>
        /// <param name="encryption">Encryption type of access point.</param>
        /// <param name="ssid">Ssid of access point.</param>
        /// <param name="keyType">KeyType of access point.</param>
        /// <param name="keyIsEncrypted">Key/password specified in profile is encrypted or not.</param>
        /// <param name="password">Password needed to connect to access point, null if open access point.</param>
        public void CreateAndValidateProfile(WiFiAuthentication authentication,
                                             WiFiEncryptionType encryption, string ssid, WiFiKeyType keyType,
                                             bool keyIsEncrypted, string password)
        {
            /* Create access point, needed in order to create connection profile. */
            AccessPoint accessPoint = new AccessPoint()
            {
                Ssid           = ssid,
                Authentication = authentication,
                Encryption     = encryption,
                BssType        = WiFiBssType.Infrastructure
            };

            string profileXml = _profileService.CreateProfileXml(accessPoint, password);

            Assert.IsNotNull(profileXml, "Generated connection profile is null.");
            Assert.IsNotEmpty(profileXml, "Generated connection profile is string.Empty.");

            /* Attributes of generated profile are returned in profile object. */
            Profile profile = new Profile();
            bool    result  = _profileService.Parse(profileXml, ref profile);

            Assert.IsTrue(result, "Failed to parse generated profile.");
            /* Validate attributes of generated profile. */
            Assert.AreEqual(authentication, profile.Authentication, "Failed to validate authentication.");
            Assert.AreEqual(encryption, profile.Encryption, "Failed to validate encryption.");
            Assert.AreEqual(ssid, profile.Ssid, "Failed to validate ssid.");
            Assert.AreEqual(ssid, profile.ProfileName, "Failed to validate profile name.");
            Assert.AreEqual(WiFiBssType.Infrastructure, profile.BssType, "Failed to validate profile BSS type.");
            Assert.IsFalse(profile.IsAutoConnectEnabled, "Wireless profile automatic connection is enabled.");
            Assert.IsFalse(profile.IsAutoSwitchEnabled, "Wireless profile automatic switch is enabled.");
            Assert.AreEqual(keyType, profile.KeyType, "Failed to validate wireless profile KeyType.");
            Assert.AreEqual(keyIsEncrypted, profile.KeyIsEncrypted, "Failed to validate profile property KeyIsEncrypted.");
            Assert.AreEqual(password, profile.KeyValue, "Wireless profile password is not equal to expected password.");
        }