Skip to content

Commit

Permalink
Merge pull request #1 from isuPatches/develop
Browse files Browse the repository at this point in the history
v1.0.1
  • Loading branch information
isuPatches committed Apr 28, 2016
2 parents 3df4638 + b309b1c commit db745f2
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ To get the networks whose configuration is already stored:
List<WifiConfiguration> savedNetworks = WiseFy.getSmarts().getSavedNetworks(getActivity());
```

To check and see if a network is secure (WEP/PSK/EAP capabilities):

```java
boolean secure = WiseFy.getSmarts().isSecure(scanResult;
```

To reconnect to a network given an SSID:

```java
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0.0"
versionCode 2
versionName "1.0.1"
}

buildTypes {
Expand Down
30 changes: 30 additions & 0 deletions app/src/androidTest/java/com/metova/wisefy/WiseFyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.metova.wisefy.util.GetManagerUtil;
import com.metova.wisefy.util.TestActivity;
import com.robotium.solo.Condition;
import org.mockito.Mockito;
import java.util.ArrayList;
import java.util.List;
import static org.mockito.Mockito.*;
Expand Down Expand Up @@ -227,6 +228,35 @@ public void testGetSavedNetworks() {
assertEquals(wifiList, WiseFy.getSmarts().getSavedNetworks(getActivity()));
}

public void testIsSecureWithWEP() {
ScanResult scanResult = mock(ScanResult.class);
scanResult.capabilities = "WEP";
assertEquals(true, WiseFy.getSmarts().isSecure(scanResult));
}

public void testIsSecureWithPSK() {
ScanResult scanResult = mock(ScanResult.class);
scanResult.capabilities = "PSK";
assertEquals(true, WiseFy.getSmarts().isSecure(scanResult));
}

public void testIsSecureWithEAP() {
ScanResult scanResult = mock(ScanResult.class);
scanResult.capabilities = "EAP";
assertEquals(true, WiseFy.getSmarts().isSecure(scanResult));
}

public void testIsSecureEmptyCapabilities() {
ScanResult scanResult = mock(ScanResult.class);
scanResult.capabilities = "";
assertEquals(false, WiseFy.getSmarts().isSecure(scanResult));
}

public void testIsSecureNullCapabilities() {
ScanResult scanResult = mock(ScanResult.class);
assertEquals(false, WiseFy.getSmarts().isSecure(scanResult));
}

public void testReconnectToNetworkSuccess() {
WiseFy.getSmarts().mGetManagerUtil = mMockGetManagerUtil;
List<WifiConfiguration> wifiList = new ArrayList<>();
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/java/com/metova/wisefy/WiseFy.java
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,22 @@ public List<WifiConfiguration> getSavedNetworks(Activity activity) {
}
}

/**
* To check and return if a network is secure (WEP/PSK/EAP capabilities)
*
* @param scanResult - The network to see if it is secure
* @return boolean - Whether the network is secure
*/
public boolean isSecure(ScanResult scanResult) {
boolean isSecure = false;
if(scanResult != null && scanResult.capabilities != null) {
if (scanResult.capabilities.contains("WEP") || scanResult.capabilities.contains("PSK") || scanResult.capabilities.contains("EAP")) {
isSecure = true;
}
}
return isSecure;
}

/**
* Used to reconnect to a network
*
Expand Down

0 comments on commit db745f2

Please sign in to comment.