mirror of https://github.com/gophish/gophish
Added ability to delete campaign from campaign results - needs some cleanup, but it works
parent
66dbe2e799
commit
be9064f718
|
@ -99,7 +99,6 @@ func GetGroupByName(n string, uid int64) (Group, error) {
|
||||||
|
|
||||||
// PostGroup creates a new group in the database.
|
// PostGroup creates a new group in the database.
|
||||||
func PostGroup(g *Group) error {
|
func PostGroup(g *Group) error {
|
||||||
Logger.Printf("%v", g.Targets)
|
|
||||||
if err := g.Validate(); err != nil {
|
if err := g.Validate(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,17 +5,17 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/jordan-wright/gophish/config"
|
"github.com/jordan-wright/gophish/config"
|
||||||
"launchpad.net/gocheck"
|
"gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Hook up gocheck into the "go test" runner.
|
// 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{}
|
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"
|
config.Conf.DBPath = "../gophish_test.db"
|
||||||
err := Setup()
|
err := Setup()
|
||||||
if err != nil {
|
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)
|
u, err := GetUser(1)
|
||||||
c.Assert(err, gocheck.Equals, nil)
|
c.Assert(err, check.Equals, nil)
|
||||||
c.Assert(u.Username, gocheck.Equals, "admin")
|
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, err := GetUser(1)
|
||||||
u.Username = "admin_changed"
|
u.Username = "admin_changed"
|
||||||
err = PutUser(&u)
|
err = PutUser(&u)
|
||||||
c.Assert(err, gocheck.Equals, nil)
|
c.Assert(err, check.Equals, nil)
|
||||||
u, err = GetUser(1)
|
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()
|
db.DB().Close()
|
||||||
err := os.Remove(config.Conf.DBPath)
|
err := os.Remove(config.Conf.DBPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -290,6 +290,22 @@ app.controller('CampaignResultsCtrl', function($scope, $filter, CampaignService,
|
||||||
"icon": "fa-check-circle"
|
"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({
|
$scope.mainTableParams = new ngTableParams({
|
||||||
page: 1, // show first page
|
page: 1, // show first page
|
||||||
count: 10, // count per page
|
count: 10, // count per page
|
||||||
|
|
|
@ -21,52 +21,66 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main" ng-controller="CampaignResultsCtrl">
|
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main" ng-controller="CampaignResultsCtrl">
|
||||||
<div class="row">
|
<div ng-show="campaign">
|
||||||
<h1 class="page-header">Results for {{campaign.name}}</h1>
|
<div class="row">
|
||||||
</div>
|
<div class="alert alert-info">
|
||||||
<div class="row">
|
No groups created yet. Let's create one!
|
||||||
<div class="btn-group">
|
</div>
|
||||||
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
|
|
||||||
<i class="fa fa-cogs fa-lg"></i>
|
|
||||||
<span class="caret"></span>
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<li><a href="#">Export</a>
|
|
||||||
</li>
|
|
||||||
<li><a href="#">Relaunch</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
<button type="button" class="btn btn-danger" tooltip="Delete Campaign" tooltip-placement="right"><i class="fa fa-times fa-lg"></i>
|
<div class="row">
|
||||||
</button>
|
<h1 class="page-header">Results for {{campaign.name}}</h1>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<div class="row">
|
||||||
<div class="row">
|
<div class="btn-group">
|
||||||
<tabset>
|
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
|
||||||
<tab heading="Overview">
|
<i class="fa fa-cogs fa-lg"></i>
|
||||||
<br/>
|
<span class="caret"></span>
|
||||||
<div class="row">
|
</button>
|
||||||
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
<ul class="dropdown-menu">
|
||||||
<highchart config="timeline_chart"></highchart>
|
<li><a href="#">Export</a>
|
||||||
|
</li>
|
||||||
|
<li><a href="#">Relaunch</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="btn btn-danger" tooltip="Delete Campaign" tooltip-placement="right" ng-click="delete(campaign)" ng-href="#/dashboard"><i class="fa fa-times fa-lg"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
<div class="row">
|
||||||
|
<tabset>
|
||||||
|
<tab heading="Overview">
|
||||||
|
<br/>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
||||||
|
<highchart config="timeline_chart"></highchart>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
||||||
|
<highchart config="email_chart"></highchart>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
</tab>
|
||||||
<highchart config="email_chart"></highchart>
|
<tab heading="Plugins">Plugins here</tab>
|
||||||
</div>
|
<tab heading="Demographics">Demographics here</tab>
|
||||||
</div>
|
</tabset>
|
||||||
</tab>
|
</div>
|
||||||
<tab heading="Plugins">Plugins here</tab>
|
<div class="row">
|
||||||
<tab heading="Demographics">Demographics here</tab>
|
<h2>Details</h2>
|
||||||
</tabset>
|
<table ng-table="mainTableParams" class="table table-hover table-striped table-bordered">
|
||||||
|
<tbody>
|
||||||
|
<tr ng-repeat="result in $data" class="editable-row">
|
||||||
|
<td data-title="'Email'" class="col-sm-1">{{result.email}}</td>
|
||||||
|
<td data-title="'Status'" class="col-sm-2">{{result.status}}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div ng-show="!campaign">
|
||||||
<h2>Details</h2>
|
<div class="row">
|
||||||
<table ng-table="mainTableParams" class="table table-hover table-striped table-bordered">
|
<div class="alert alert-danger">
|
||||||
<tbody>
|
<i class="fa fa-exclamation-circle"></i> Campaign not found!
|
||||||
<tr ng-repeat="result in $data" class="editable-row">
|
</div>
|
||||||
<td data-title="'Email'" class="col-sm-1">{{result.email}}</td>
|
</div>
|
||||||
<td data-title="'Status'" class="col-sm-2">{{result.status}}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue