public bool CreateProfile(string profile, string profileName) { try { using (Wlan wlanApi = new Wlan()) { testLogger.LogTrace("CreateProfile"); var wlanInterfaceList = wlanApi.EnumWlanInterfaces(); if (NetworkInterfaceDataPathTests.CheckWlanInterfaceCount(wlanApi) == false) { return(false); } var wlanInterface = wlanInterfaceList[0]; testLogger.LogComment("Creating Profile {0}", profileName); wlanApi.CreateProfile(wlanInterface.Id, profile); return(true); } } catch (Exception error) { testLogger.LogError("Error encountered while Creating the Wlan Profile {0}", profileName); testLogger.LogError(error.ToString()); return(false); } }
private void SetupProfiles(bool b5Ghz) { string Profile = null; string ssid = null; AuthenticationMethod authMethod; EncryptionMethod encryptionMethod; if (b5Ghz) { ssid = APConfigs[1].SSID_5GHZ; authMethod = APConfigs[1].Authentication_5GHZ; encryptionMethod = APConfigs[1].Encryption_5GHZ; } else { authMethod = APConfigs[1].Authentication_24GHZ; ssid = APConfigs[1].SSID_24GHZ; encryptionMethod = APConfigs[1].Encryption_24GHZ; } Log("Setting up Profile SSID " + ssid + " Auth = " + authMethod + " Cipher = " + encryptionMethod + " b5GHz = " + b5Ghz); if (authMethod == AuthenticationMethod.WPA2Enterprise) { Profile = Helpers.CreateEnterpriseProfile(ssid, ConnectionMode.Manual, encryptionMethod, phase1Auth, phase2Auth); } else if (b5Ghz) { Profile = APConfigs[1].CreateProfile5ghz(ConnectionMode.Manual, false); } else { Profile = APConfigs[1].CreateProfile24ghz(ConnectionMode.Manual, false); } if (null == Profile) { Log("CreateProfile24ghz: null Profile"); throw new Exception("CreateProfile24ghz ; null Profile"); } Helpers.DeleteProfile( Api, TestInterface.Id, ssid); Api.CreateProfile( TestInterface.Id, Profile, Wlan.ProfileScope.AllUser); if (authMethod == AuthenticationMethod.WPA2Enterprise) { Helpers.SetProfileEapXmlUserDataMSChapV2(phase1Auth, phase2Auth, TestInterface.Id, Api, ssid, EnterpriseUser, EnterprisePassword, EnterpriseDomain); } }
private string CreateProfile(int RouterIndex, ConnectionMode mode, bool b5GHZ) { string Profile = null; string ssid = null; AuthenticationMethod authMethod; EncryptionMethod encryptionMethod; // Create a Radius Server if needed first StartRadius(RouterIndex, b5GHZ); if (b5GHZ) { ssid = m_APConfigs[RouterIndex].SSID_5GHZ; authMethod = m_APConfigs[RouterIndex].Authentication_5GHZ; encryptionMethod = m_APConfigs[RouterIndex].Encryption_5GHZ; } else { authMethod = m_APConfigs[RouterIndex].Authentication_24GHZ; ssid = m_APConfigs[RouterIndex].SSID_24GHZ; encryptionMethod = m_APConfigs[RouterIndex].Encryption_24GHZ; } if (authMethod == AuthenticationMethod.WPA2Enterprise) { bool FIPSMode = false; // The FIPS Mode parameter will only be honored for AES + WPA2 profiles if (encryptionMethod == EncryptionMethod.AES) { FIPSMode = m_AssociationConfiguration.FIPSMode; } Profile = Helpers.CreateEnterpriseProfile(ssid, mode, encryptionMethod, m_Phase1Auth[RouterIndex], m_Phase2Auth[RouterIndex], FIPSMode); } else if (b5GHZ) { Profile = m_APConfigs[RouterIndex].CreateProfile5ghz(mode, false); } else { Profile = m_APConfigs[RouterIndex].CreateProfile24ghz(mode, false); } if (null == Profile) { Log("CreateProfile24ghz: null Profile"); throw new Exception("CreateProfile24ghz ; null Profile"); } Helpers.DeleteProfile( m_WlanApi, m_TestInterface.Id, ssid); Log(String.Format(CultureInfo.InvariantCulture, "Create profile for ssid: {0}", ssid)); m_WlanApi.CreateProfile( m_TestInterface.Id, Profile, Wlan.ProfileScope.AllUser); if (authMethod == AuthenticationMethod.WPA2Enterprise) { Log(String.Format(CultureInfo.InvariantCulture, "Adding EAP Data for MSCHAPV2 for ssid: {0}", ssid)); Helpers.SetProfileEapXmlUserDataMSChapV2(m_Phase1Auth[RouterIndex], m_Phase2Auth[RouterIndex], m_TestInterface.Id, m_WlanApi, ssid, m_EnterpriseUser, m_EnterprisePassword, m_EnterpriseDomain); if (mode == ConnectionMode.Auto) //must issue a connect after updating the eap data in the profile after an auto connect { m_WlanApi.ProfileConnect(m_TestInterface.Id, ssid); } } return(Profile); }
private void ConnectForIntegrityCheck(ApConfigClient apConfigClient, int port, int streamBytes) { using (Wlan wlanApi = new Wlan()) { var wlanInterfaceList = wlanApi.EnumWlanInterfaces(); Verify.IsTrue(wlanInterfaceList.Count >= 1, string.Format(CultureInfo.InvariantCulture, "wlanInterfaceList.Count = {0}", wlanInterfaceList.Count)); var wlanInterface = wlanInterfaceList[0]; if (wlanInterface.State == WLAN_INTERFACE_STATE.wlan_interface_state_connected) { return; } if (apConfigCreated == false) { var currentConfig1 = WlanAccessPointHelper.CreateWirelessAccessPoint(AuthenticationMethod.WPA2Personal, EncryptionMethod.AES, PhyType.n, "Password", AuthenticationMethod.WPA2Personal, EncryptionMethod.AES, PhyType.n, "Password"); var currentConfig2 = WlanAccessPointHelper.CreateWirelessAccessPoint(AuthenticationMethod.WPA2Personal, EncryptionMethod.AES, PhyType.n, "Password", AuthenticationMethod.WPA2Personal, EncryptionMethod.AES, PhyType.n, "Password"); ConfiguredSSIDs configuredSSID1 = new ConfiguredSSIDs("", ""); ConfiguredSSIDs configuredSSID2 = new ConfiguredSSIDs("", ""); if (apConfigClient.ApplyConfiguration(routers[0], currentConfig1, out configuredSSID1)) { currentConfig1.SSID_24GHZ = configuredSSID1.TwoPoint4GhzSSID; currentConfig1.SSID_5GHZ = configuredSSID1.FiveghzSSID; testLogger.LogComment("Successfully applied the Configuration to AP[0]"); } else { testLogger.LogError("Unable to apply the configuration to AP [0]"); } testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "Applying AP Configuration to AP[1] {0}", currentConfig2.SSID_24GHZ)); if (apConfigClient.ApplyConfiguration(routers[1], currentConfig2, out configuredSSID2)) { currentConfig2.SSID_24GHZ = configuredSSID1.TwoPoint4GhzSSID; currentConfig2.SSID_5GHZ = configuredSSID1.FiveghzSSID; testLogger.LogComment("Successfully applied the Configuration to AP[2]"); } else { testLogger.LogError("Unable to apply the configuration to AP[2]"); } string profile1; string profile2; profile1 = currentConfig1.CreateProfile24ghz(ConnectionMode.Manual, false); profileName1 = currentConfig1.SSID_24GHZ; profile2 = currentConfig2.CreateProfile24ghz(ConnectionMode.Manual, false); profileName2 = currentConfig2.SSID_24GHZ; testLogger.LogComment(profile1); wlanApi.CreateProfile(wlanInterface.Id, profile1); wlanApi.CreateProfile(wlanInterface.Id, profile2); testLogger.LogComment("Wait to allow APs to beacon"); Wlan.Sleep(10000); apConfigCreated = true; } int retries = 3; while (retries > 0) { retries--; testLogger.LogComment("Scan"); wlanApi.TryScan(wlanInterface.Id, false, ScanWait); try { testLogger.LogComment(String.Format(CultureInfo.InvariantCulture, "Attempt to Connect to SSID : {0}", profileName1)); wlanApi.ProfileConnect(wlanInterface.Id, profileName1, ConnectWait); break; } catch (Exception) { testLogger.LogComment("Connect failed."); if (retries == 0) { testLogger.LogError(String.Format(CultureInfo.InvariantCulture, "Could not connect to SSID: {0}", profileName1)); return; } } } testLogger.LogComment("Wait for DHCP"); Microsoft.Test.Networking.Kit.Helpers.WaitForWlanConnectivity(wlanInterface.Id, 1000 * 15, testLogger); } }
public void TestDot11wConnection() { Guid interfaceId; testLogger.LogComment("Testing 802.11w Connection to AP with SSID " + dot11wSSID + " and password " + dot11wPassword); using (Wlan wlanApi = new Wlan()) { var wlanInterfaceList = wlanApi.EnumWlanInterfaces(); Verify.IsTrue(wlanInterfaceList.Count >= 1, string.Format(CultureInfo.InvariantCulture, "wlanInterfaceList.Count = {0}", wlanInterfaceList.Count)); var wlanInterface = wlanInterfaceList[0]; interfaceId = wlanInterface.Id; // Delete Profile if present DisconnectAndDeleteProfile(wlanApi); // Scan testLogger.LogComment("Scan"); wlanApi.Scan(wlanInterface.Id, false, ScanWait); // Check to see if SSID is in scan list testLogger.LogComment("Check to see if SSID is in scan list"); var networkList = wlanApi.GetAvailableNetworkList(interfaceId); bool found = false; foreach (WlanNetwork network in networkList) { if (String.Compare(network.Ssid, dot11wSSID, StringComparison.Ordinal) == 0) { found = true; break; } } if (found == false) { testLogger.LogError("Could not find 11w router in scan list: " + dot11wSSID); testLogger.LogResult(TestResult.Failed); return; } else { testLogger.LogComment("Found the 11w router in the scan list: " + dot11wSSID); } // Create Profile string profile = GenerateProfile(); testLogger.LogComment("Creating Profile"); wlanApi.CreateProfile(interfaceId, profile); // Connect testLogger.LogComment("Connecting to AP"); wlanApi.ProfileConnect(interfaceId, dot11wSSID, new TimeSpan(0, 0, 30)); } // Check MFP Status bool mfpStatus = IsMfpNeogotiated(interfaceId); testLogger.LogComment("IsMfpNeogotiated == " + mfpStatus); if (mfpStatus == false) { testLogger.LogError("The device connected to the dot11w router but IsMfpNeogotiated == false"); testLogger.LogResult(TestResult.Failed); return; } if (enableSleepTest) { PowerManager powerManager; powerManager = new PowerManager(); // Wait for DHCP Stable testLogger.LogComment("Wait for DHCP to be stable"); Wlan.Sleep(1000 * 60 * 2); testLogger.LogComment("Going into Connected standby/Sleep for 1 minute"); powerManager.DeepestSleep(60); using (Wlan wlanApi = new Wlan()) { bool isConnected = IsConnected(wlanApi); if (isConnected == false) { testLogger.LogError("After waking from connected standby the device is no longer connected to the AP"); } else { testLogger.LogComment("After waking from connected standby the device is still connected to the AP"); } } // Check MFP Status mfpStatus = IsMfpNeogotiated(interfaceId); testLogger.LogComment("IsMfpNeogotiated == " + mfpStatus); if (mfpStatus == false) { testLogger.LogError("The device connected to the dot11w router but IsMfpNeogotiated == false"); return; } } }