diff --git a/models/group.go b/models/group.go
index 4d2ecf61..6b4e5df3 100644
--- a/models/group.go
+++ b/models/group.go
@@ -99,7 +99,6 @@ func GetGroupByName(n string, uid int64) (Group, error) {
// PostGroup creates a new group in the database.
func PostGroup(g *Group) error {
- Logger.Printf("%v", g.Targets)
if err := g.Validate(); err != nil {
return err
}
diff --git a/models/models_test.go b/models/models_test.go
index 1bd8bd6d..747d3749 100644
--- a/models/models_test.go
+++ b/models/models_test.go
@@ -5,17 +5,17 @@ import (
"testing"
"github.com/jordan-wright/gophish/config"
- "launchpad.net/gocheck"
+ "gopkg.in/check.v1"
)
// Hook up gocheck into the "go test" runner.
-func Test(t *testing.T) { gocheck.TestingT(t) }
+func Test(t *testing.T) { check.TestingT(t) }
type ModelsSuite struct{}
-var _ = gocheck.Suite(&ModelsSuite{})
+var _ = check.Suite(&ModelsSuite{})
-func (s *ModelsSuite) SetUpSuite(c *gocheck.C) {
+func (s *ModelsSuite) SetUpSuite(c *check.C) {
config.Conf.DBPath = "../gophish_test.db"
err := Setup()
if err != nil {
@@ -23,22 +23,48 @@ func (s *ModelsSuite) SetUpSuite(c *gocheck.C) {
}
}
-func (s *ModelsSuite) TestGetUser(c *gocheck.C) {
+func (s *ModelsSuite) TestGetUser(c *check.C) {
u, err := GetUser(1)
- c.Assert(err, gocheck.Equals, nil)
- c.Assert(u.Username, gocheck.Equals, "admin")
+ c.Assert(err, check.Equals, nil)
+ c.Assert(u.Username, check.Equals, "admin")
}
-func (s *ModelsSuite) TestPutUser(c *gocheck.C) {
+func (s *ModelsSuite) TestPostGroup(c *check.C) {
+ g := Group{Name: "Test Group"}
+ g.Targets = []Target{Target{Email: "test@example.com"}}
+ g.UserId = 1
+ err := PostGroup(&g)
+ c.Assert(err, check.Equals, nil)
+ c.Assert(g.Name, check.Equals, "Test Group")
+ c.Assert(g.Targets[0].Email, check.Equals, "test@example.com")
+}
+
+func (s *ModelsSuite) TestPostGroupNoName(c *check.C) {
+ g := Group{Name: ""}
+ g.Targets = []Target{Target{Email: "test@example.com"}}
+ g.UserId = 1
+ err := PostGroup(&g)
+ c.Assert(err, check.Equals, ErrGroupNameNotSpecified)
+}
+
+func (s *ModelsSuite) TestPostGroupNoTargets(c *check.C) {
+ g := Group{Name: "No Target Group"}
+ g.Targets = []Target{}
+ g.UserId = 1
+ err := PostGroup(&g)
+ c.Assert(err, check.Equals, ErrNoTargetsSpecified)
+}
+
+func (s *ModelsSuite) TestPutUser(c *check.C) {
u, err := GetUser(1)
u.Username = "admin_changed"
err = PutUser(&u)
- c.Assert(err, gocheck.Equals, nil)
+ c.Assert(err, check.Equals, nil)
u, err = GetUser(1)
- c.Assert(u.Username, gocheck.Equals, "admin_changed")
+ c.Assert(u.Username, check.Equals, "admin_changed")
}
-func (s *ModelsSuite) TearDownSuite(c *gocheck.C) {
+func (s *ModelsSuite) TearDownSuite(c *check.C) {
db.DB().Close()
err := os.Remove(config.Conf.DBPath)
if err != nil {
diff --git a/static/js/app/controllers.js b/static/js/app/controllers.js
index 9db97850..154a6513 100644
--- a/static/js/app/controllers.js
+++ b/static/js/app/controllers.js
@@ -290,6 +290,22 @@ app.controller('CampaignResultsCtrl', function($scope, $filter, CampaignService,
"icon": "fa-check-circle"
})
}
+
+ $scope.delete = function(campaign) {
+ if (confirm("Delete campaign?")) {
+ var deleteCampaign = new CampaignService(campaign);
+ deleteCampaign.$delete({
+ id: deleteCampaign.id
+ }, function(response) {
+ if (response.success) {
+ $scope.successFlash(response.message)
+ } else {
+ $scope.errorFlash(response.message)
+ }
+ $scope.mainTableParams.reload();
+ });
+ }
+ }
$scope.mainTableParams = new ngTableParams({
page: 1, // show first page
count: 10, // count per page
diff --git a/static/js/app/partials/campaign_results.html b/static/js/app/partials/campaign_results.html
index a55afa84..558101c9 100644
--- a/static/js/app/partials/campaign_results.html
+++ b/static/js/app/partials/campaign_results.html
@@ -21,52 +21,66 @@
-
-
-
-
-
-
-
+
+
+
+ No groups created yet. Let's create one!
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
Plugins here
-
Demographics here
-
+
+
Plugins here
+
Demographics here
+
+
+
+
Details
+
+
+
+ {{result.email}} |
+ {{result.status}} |
+
+
+
+
-
-
Details
-
-
-
- {{result.email}} |
- {{result.status}} |
-
-
-
+
+
+
+ Campaign not found!
+
+