-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding tests and reorging file structure
- Loading branch information
Showing
33 changed files
with
128 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> | ||
|
||
<wb-module deploy-name="FactionExtender"> | ||
<wb-resource deploy-path="/" source-path="/FactionExtender/src"/> | ||
<wb-resource deploy-path="/" source-path="/src"/> | ||
<wb-resource deploy-path="/" source-path="/src/main/java"/> | ||
<wb-resource deploy-path="/" source-path="/src/test/java"/> | ||
|
||
</wb-module> | ||
|
||
</project-modules> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.faction.extender; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
import com.faction.elements.utils.Log; | ||
|
||
public interface BaseInterface { | ||
/** | ||
* This function is used by Faction to set the configurations for the extension. This should not be called | ||
* locally in your classes | ||
* | ||
* @param configs | ||
*/ | ||
public void setConfigs(HashMap<String,String>configs); | ||
|
||
|
||
/** | ||
* This function is used by Faction to get all logs for the extension. This should not be called locally in | ||
* your classes | ||
* | ||
* @return List<Log> logs : Returns a list of logs that can be displayed in the Faction UI | ||
*/ | ||
public List<Log> getLogs(); | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.faction.unittests; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import java.io.File; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.net.URLClassLoader; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.ServiceLoader; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import com.faction.elements.Assessment; | ||
import com.faction.elements.BaseExtension; | ||
import com.faction.elements.Vulnerability; | ||
import com.faction.elements.results.AssessmentManagerResult; | ||
import com.faction.elements.utils.Log; | ||
import com.faction.elements.utils.Log.LEVEL; | ||
import com.faction.extender.AssessmentManager; | ||
import com.faction.extender.AssessmentManager.Operation; | ||
|
||
|
||
|
||
public class ExtenderTestCase { | ||
|
||
@Test | ||
void test() { | ||
AssessmentManager asmtMgr = new MyAssmtMgr(); | ||
HashMap<String,String>configs = new HashMap<>(); | ||
configs.put("Test1", "Test Config 1"); | ||
configs.put("Test2", "Test Config 2"); | ||
|
||
asmtMgr.setConfigs(configs); | ||
|
||
Assessment asmt = new Assessment(); | ||
asmt.setSummary("Default"); | ||
|
||
Vulnerability vuln = new Vulnerability(); | ||
List<Vulnerability> vulns = new ArrayList<>(); | ||
vulns.add(vuln); | ||
|
||
AssessmentManagerResult result = asmtMgr.assessmentChange(asmt, vulns, Operation.Create); | ||
|
||
assertTrue(result.getAssessment().getSummary().equals("This is a test")); | ||
|
||
assertTrue(asmtMgr.getLogs().size() == 2); | ||
|
||
List<Log> logs = asmtMgr.getLogs(); | ||
assertTrue(logs.stream().anyMatch( log -> log.getMessage().equals("Got Config1: Test Config 1"))); | ||
assertTrue(logs.stream().anyMatch( log -> log.getMessage().equals("Got Config2: Test Config 2"))); | ||
|
||
|
||
|
||
assertTrue(true); | ||
|
||
} | ||
|
||
public class MyAssmtMgr extends BaseExtension implements AssessmentManager{ | ||
|
||
@Override | ||
public AssessmentManagerResult assessmentChange(Assessment asmt, List<Vulnerability> vulns, | ||
Operation Operation) { | ||
String config1 = this.getConfigs().get("Test1"); | ||
String config2 = this.getConfigs().get("Test2"); | ||
|
||
asmt.setSummary("This is a test"); | ||
|
||
this.getLogger().addLog(LEVEL.INFO, "Got Config1: " + config1); | ||
this.getLogger().addLog(LEVEL.INFO, "Got Config2: " + config2); | ||
|
||
AssessmentManagerResult result = new AssessmentManagerResult(); | ||
result.setAssessment(asmt); | ||
result.setVulnerabilities(vulns); | ||
return result; | ||
} | ||
} | ||
|
||
} | ||
|
||
|