aboutsummaryrefslogtreecommitdiff
path: root/application_context_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'application_context_test.go')
-rw-r--r--application_context_test.go28
1 files changed, 26 insertions, 2 deletions
diff --git a/application_context_test.go b/application_context_test.go
index eed0fd6..11d1ed4 100644
--- a/application_context_test.go
+++ b/application_context_test.go
@@ -1,3 +1,20 @@
+/*
+ * This file is part of caronte (https://github.com/eciavatta/caronte).
+ * Copyright (c) 2020 Emiliano Ciavatta.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
package main
import (
@@ -10,7 +27,7 @@ func TestCreateApplicationContext(t *testing.T) {
wrapper := NewTestStorageWrapper(t)
wrapper.AddCollection(Settings)
- appContext, err := CreateApplicationContext(wrapper.Storage)
+ appContext, err := CreateApplicationContext(wrapper.Storage, "test")
assert.NoError(t, err)
assert.False(t, appContext.IsConfigured)
assert.Zero(t, appContext.Config)
@@ -18,6 +35,10 @@ func TestCreateApplicationContext(t *testing.T) {
assert.Nil(t, appContext.PcapImporter)
assert.Nil(t, appContext.RulesManager)
+ notificationController := NewNotificationController(appContext)
+ appContext.SetNotificationController(notificationController)
+ assert.Equal(t, notificationController, appContext.NotificationController)
+
config := Config{
ServerAddress: "10.10.10.10",
FlagRegex: "FLAG{test}",
@@ -39,13 +60,16 @@ func TestCreateApplicationContext(t *testing.T) {
appContext.SetConfig(config)
appContext.SetAccounts(accounts)
- checkAppContext, err := CreateApplicationContext(wrapper.Storage)
+ checkAppContext, err := CreateApplicationContext(wrapper.Storage, "test")
assert.NoError(t, err)
+ checkAppContext.SetNotificationController(notificationController)
+ checkAppContext.Configure()
assert.True(t, checkAppContext.IsConfigured)
assert.Equal(t, checkAppContext.Config, config)
assert.Equal(t, checkAppContext.Accounts, accounts)
assert.NotNil(t, checkAppContext.PcapImporter)
assert.NotNil(t, checkAppContext.RulesManager)
+ assert.Equal(t, notificationController, appContext.NotificationController)
wrapper.Destroy(t)
}