Skip to content

Commit

Permalink
Fixed the tests and a few typos
Browse files Browse the repository at this point in the history
  • Loading branch information
mat committed Jan 28, 2020
1 parent 2aed9bd commit b898690
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ These are the current checks/tricks we are using to give an indication of root.

**Java checks**

* CheckRootManagementApps
* CheckPotentiallyDangerousApps
* CheckRootCloakingApps
* CheckTestKeys
* checkRootManagementApps
* checkPotentiallyDangerousApps
* checkRootCloakingApps
* checkTestKeys
* checkForDangerousProps
* checkForBusyBoxBinary
* checkForSuBinary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public boolean checkForSuBinary(){
* @return true if found
*/
public boolean checkForBusyBoxBinary(){
return checkForBinary("busybox");
return checkForBinary(BINARY_BUSYBOX);
}

/**
Expand Down
16 changes: 6 additions & 10 deletions rootbeerlib/src/test/java/com/scottyab/rootbeer/RootBeerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public void testIsRooted() {

when(rootBeer.detectRootManagementApps()).thenReturn(false);
when(rootBeer.detectPotentiallyDangerousApps()).thenReturn(false);
when(rootBeer.checkForBinary(Const.BINARY_BUSYBOX)).thenReturn(false);
when(rootBeer.checkForBinary(Const.BINARY_SU)).thenReturn(false);
when(rootBeer.checkForDangerousProps()).thenReturn(false);
when(rootBeer.checkForRWPaths()).thenReturn(false);
Expand All @@ -40,7 +39,7 @@ public void testIsRooted() {
when(rootBeer.checkForRootNative()).thenReturn(false);

// Test we return false when all methods return false
assertTrue(!rootBeer.isRooted());
assertFalse(rootBeer.isRooted());

when(rootBeer.checkForRootNative()).thenReturn(true);

Expand All @@ -49,13 +48,11 @@ public void testIsRooted() {
}

@Test
public void testIsRootedWithoutBusyBoxCheck() {
public void testIsRootedWithBusyBoxCheck() {

RootBeer rootBeer = Mockito.mock(RootBeer.class);

when(rootBeer.isRooted()).thenCallRealMethod();
when(rootBeer.isRootedWithoutBusyBoxCheck()).thenCallRealMethod();

when(rootBeer.detectRootManagementApps()).thenReturn(false);
when(rootBeer.detectPotentiallyDangerousApps()).thenReturn(false);
when(rootBeer.checkForBinary(Const.BINARY_BUSYBOX)).thenReturn(true);
Expand All @@ -66,12 +63,11 @@ public void testIsRootedWithoutBusyBoxCheck() {
when(rootBeer.checkSuExists()).thenReturn(false);
when(rootBeer.checkForRootNative()).thenReturn(false);

// Test we return false when all methods return false
assertTrue(rootBeer.isRooted());

// Test it doesn't matter what checkForBinary("busybox") returns
assertTrue(!rootBeer.isRootedWithoutBusyBoxCheck());
// Test we return false as busybox binary presence is ignored
assertFalse(rootBeer.isRooted());

// Check busybox present is detected
assertTrue(rootBeer.checkForBinary(Const.BINARY_BUSYBOX));
}

@Test
Expand Down

0 comments on commit b898690

Please sign in to comment.