Skip to content

Commit

Permalink
Fix lint CI, bump test plugin (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc authored Mar 21, 2023
1 parent 27e785f commit 28a9f45
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 138 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,7 @@ jobs:
version: v1.51
args: --issues-exit-code=1 --timeout 10m
only-new-issues: false
# the cache is already managed above, enabling it here
# gives errors when extracting
skip-pkg-cache: true
skip-build-cache: true
5 changes: 1 addition & 4 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[packages]
pytest-dotenv = "*"
flask = "*"
pytimeparse = "*"
psutil = "*"
pytest-cs = {ref = "0.4.0", git = "https://github.com/crowdsecurity/pytest-cs.git"}
pytest-cs = {ref = "0.5.0", git = "https://github.com/crowdsecurity/pytest-cs.git"}

[dev-packages]
gnureadline = "*"
Expand Down
128 changes: 12 additions & 116 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func newConfig(reader io.Reader) (*bouncerConfig, error) {

if config.CacheRetentionDuration == 0 {
log.Infof("cache_retention_duration defaults to 10 seconds")
config.CacheRetentionDuration = time.Duration(10 * time.Second)
config.CacheRetentionDuration = 10 * time.Second
}

return config, nil
Expand Down
2 changes: 1 addition & 1 deletion custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func serializeDecision(decision *models.Decision, action string) (string, error)
d := DecisionWithAction{Decision: *decision, Action: action, ID: decision.ID}
serbyte, err := json.Marshal(d)
if err != nil {
return "", fmt.Errorf("serialize error : %s", err)
return "", fmt.Errorf("serialize error : %w", err)
}
return string(serbyte), nil
}
Expand Down
5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import (
"golang.org/x/sync/errgroup"

"github.com/crowdsecurity/crowdsec/pkg/models"
"github.com/crowdsecurity/cs-custom-bouncer/pkg/version"
csbouncer "github.com/crowdsecurity/go-cs-bouncer"

"github.com/crowdsecurity/cs-custom-bouncer/pkg/version"
)

const (
Expand Down Expand Up @@ -76,7 +77,6 @@ func deleteDecisions(custom *customBouncer, decisions []*models.Decision) {
}
}


func addDecisions(custom *customBouncer, decisions []*models.Decision) {
if len(decisions) == 1 {
log.Infof("adding 1 decision")
Expand All @@ -92,7 +92,6 @@ func addDecisions(custom *customBouncer, decisions []*models.Decision) {
}
}


func main() {
var err error
var promServer *http.Server
Expand Down
13 changes: 0 additions & 13 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
"""
Full integration test with a real Crowdsec running in Docker
"""

import contextlib
import os
import pathlib
import secrets
import string

import pytest

Expand Down Expand Up @@ -94,10 +88,3 @@ def closure(**kw):
cfg |= cb_cfg_factory(**kw)
return cfg
yield closure


@pytest.fixture(scope='session')
def api_key_factory():
def closure(alphabet=string.ascii_letters + string.digits):
return ''.join(secrets.choice(alphabet) for i in range(32))
yield closure

0 comments on commit 28a9f45

Please sign in to comment.