dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

spamInterceptor_test.go (3685B)


      1 package interceptors
      2 
      3 import (
      4 	"dkforest/pkg/database"
      5 	"github.com/stretchr/testify/assert"
      6 	"regexp"
      7 	"testing"
      8 )
      9 
     10 func Test_autoHellbanCheck(t *testing.T) {
     11 	type args struct {
     12 		authUser         *database.User
     13 		lowerCaseMessage string
     14 	}
     15 	tests := []struct {
     16 		name string
     17 		args args
     18 		want bool
     19 	}{
     20 		{name: "", args: args{authUser: &database.User{GeneralMessagesCount: 2}, lowerCaseMessage: "hi new here"}, want: true},
     21 		{name: "", args: args{authUser: &database.User{GeneralMessagesCount: 2}, lowerCaseMessage: "hello anybody know of any legit market places ? its getting tough on here to find any that actually do what they supposed to "}, want: true},
     22 		{name: "", args: args{authUser: &database.User{GeneralMessagesCount: 2}, lowerCaseMessage: "Hello Guys and Ladys someone can help me? I Have a Little problem.."}, want: true},
     23 	}
     24 	for _, tt := range tests {
     25 		t.Run(tt.name, func(t *testing.T) {
     26 			assert.Equalf(t, tt.want, autoHellbanCheck(tt.args.authUser, tt.args.lowerCaseMessage), "autoHellbanCheck(%v, %v)", tt.args.authUser, tt.args.lowerCaseMessage)
     27 		})
     28 	}
     29 }
     30 
     31 func Test_regex(t *testing.T) {
     32 	type args struct {
     33 		authUser         *database.User
     34 		lowerCaseMessage string
     35 	}
     36 	tests := []struct {
     37 		name string
     38 		args args
     39 		want bool
     40 	}{
     41 		{name: "", args: args{authUser: &database.User{GeneralMessagesCount: 2}, lowerCaseMessage: "gore"}, want: true},
     42 		{name: "", args: args{authUser: &database.User{GeneralMessagesCount: 2}, lowerCaseMessage: "my name is igore"}, want: false},
     43 		{name: "", args: args{authUser: &database.User{GeneralMessagesCount: 2}, lowerCaseMessage: "you can igore this"}, want: false},
     44 		{name: "", args: args{authUser: &database.User{GeneralMessagesCount: 2}, lowerCaseMessage: "anyone has gore?"}, want: true},
     45 		{name: "", args: args{authUser: &database.User{GeneralMessagesCount: 2}, lowerCaseMessage: "I want gore lol"}, want: true},
     46 	}
     47 	for _, tt := range tests {
     48 		rgx := regexp.MustCompile(`\bgore\b`)
     49 		t.Run(tt.name, func(t *testing.T) {
     50 			assert.Equalf(t, tt.want, rgx.MatchString(tt.args.lowerCaseMessage), "regex(%v)", tt.args.lowerCaseMessage)
     51 		})
     52 	}
     53 }
     54 
     55 func Test_autoKickSpammers(t *testing.T) {
     56 	type args struct {
     57 		authUser         *database.User
     58 		lowerCaseMessage string
     59 	}
     60 	tests := []struct {
     61 		name string
     62 		args args
     63 		want bool
     64 	}{
     65 		{name: "", args: args{authUser: &database.User{GeneralMessagesCount: 2}, lowerCaseMessage: "blablabla l e m y _ b e a u t y on "}, want: true},
     66 	}
     67 	for _, tt := range tests {
     68 		t.Run(tt.name, func(t *testing.T) {
     69 			assert.Equalf(t, tt.want, autoKickSpammers(tt.args.authUser, tt.args.lowerCaseMessage), "autoKickSpammers(%v, %v)", tt.args.authUser, tt.args.lowerCaseMessage)
     70 		})
     71 	}
     72 }
     73 
     74 func Test_autoKickProfanityTmp(t *testing.T) {
     75 	type args struct {
     76 		orig string
     77 	}
     78 	tests := []struct {
     79 		name string
     80 		args args
     81 		want bool
     82 	}{
     83 		{"", args{orig: "biden is dumb fuck can suck my dick stupid nigger"}, true},
     84 		{"", args{orig: "u can suck his nuts like the submissive faggot u are. slurping eye contact for deep man love with dirty butthole sniffing."}, true},
     85 		{"", args{orig: "how to tear a human slut bitch from the cunt to the part in her hairline then shit into the chest cavity for happy dumpling poop soup"}, true},
     86 		{"", args{orig: "lets murder a nun and fuck the blood scabs into her corpse pussy hole"}, true},
     87 		{"", args{orig: "quick question, whats the best method to plant a grenaed in old ladys stinky rotted cunt hole to blast her bloods on a hotel walls"}, true},
     88 	}
     89 	for _, tt := range tests {
     90 		t.Run(tt.name, func(t *testing.T) {
     91 			assert.Equalf(t, tt.want, autoKickProfanityTmp(tt.args.orig), "autoKickProfanityTmp(%v)", tt.args.orig)
     92 		})
     93 	}
     94 }