Skip to content

Commit

Permalink
Merge pull request #280 from iegomez/fix/bump-flagged-golang-org-pack…
Browse files Browse the repository at this point in the history
…ages

Bump flagged go packages and add test workflow
  • Loading branch information
iegomez committed May 24, 2023
2 parents 9e9d90b + c963332 commit 83fa4e2
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 170 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build_and_push_docker_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Build docker images and publish to DockerHub

on:
push:
branches: [master]
release:
types: [published]
env:
Expand Down Expand Up @@ -44,7 +45,7 @@ jobs:
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO }}:${{ github.event.release.tag_name }}${{ format('{0}{1}', env.MOSQUITTO_VERSION_SUFFIX, env.MOSQUITTO_VERSION_1) }}
-
name: Build and push on push
if: github.event_name == 'push'
if: github.event_name == 'push' && github.event.pull_request.merged == true
uses: docker/build-push-action@v2
with:
context: .
Expand Down Expand Up @@ -84,7 +85,7 @@ jobs:
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO }}:${{ github.event.release.tag_name }}${{ format('{0}{1}', env.MOSQUITTO_VERSION_SUFFIX, env.MOSQUITTO_VERSION_2) }}
-
name: Build and push on push
if: github.event_name == 'push'
if: github.event_name == 'push' && github.event.pull_request.merged == true
uses: docker/build-push-action@v2
with:
context: .
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Test

on:
push:
env:
MOSQUITTO_VERSION_1: 1.6.14
MOSQUITTO_VERSION_2: 2.0.15
DOCKERFILE_MOSQUITTO_VERSION: 1.6.14
DOCKERHUB_REPO: mosquitto-go-auth
jobs:
mosq_1:
name: Test with Mosquitto version 1.x
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Set Mosquitto version
run: sed -i 's/ARG MOSQUITTO_VERSION=${{ env.DOCKERFILE_MOSQUITTO_VERSION }}/ARG MOSQUITTO_VERSION=${{ env.MOSQUITTO_VERSION_1 }}/' Dockerfile.runtest
-
name: Test
run: |
docker build -t mosquitto-go-auth.test -f Dockerfile.runtest .
docker run --rm mosquitto-go-auth.test ./run-test-in-docker.sh
mosq_2:
name: Test with Mosquitto version 2.x
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set Mosquitto version
run: sed -i 's/ARG MOSQUITTO_VERSION=${{ env.DOCKERFILE_MOSQUITTO_VERSION }}/ARG MOSQUITTO_VERSION=${{ env.MOSQUITTO_VERSION_2 }}/' Dockerfile.runtest
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Test
run: |
docker build -t mosquitto-go-auth.test -f Dockerfile.runtest .
docker run --rm mosquitto-go-auth.test ./run-test-in-docker.sh
74 changes: 40 additions & 34 deletions Dockerfile.runtest
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@

#Use debian:stable-slim as a builder and then copy everything.
FROM debian:stable-slim as builder
# Define Mosquitto version, see also .github/workflows/build_and_push_docker_images.yml for
# the automatically built images
ARG MOSQUITTO_VERSION=1.6.14
# Define libwebsocket version
ARG LWS_VERSION=4.2.2

# Use debian:stable-slim as a builder for Mosquitto and dependencies.
FROM debian:stable-slim as mosquitto_builder
ARG MOSQUITTO_VERSION
ARG LWS_VERSION

#Set mosquitto and plugin versions.
#Change them for your needs.
ENV MOSQUITTO_VERSION=1.6.10
ENV PLUGIN_VERSION=0.6.1
ENV GO_VERSION=1.18
# Used in run-test-in-docker.sh to check if the script
# is actually run in a container
Expand All @@ -14,40 +18,42 @@ ENV MOSQUITTO_GO_AUTH_TEST_RUNNING_IN_A_CONTAINER=true
WORKDIR /app

#Get mosquitto build dependencies.
RUN apt-get update && apt-get install -y libc-ares2 libc-ares-dev openssl uuid uuid-dev wget build-essential git

RUN if [ "$(echo $MOSQUITTO_VERSION | head -c 1)" != 2 ]; then \
apt install -y libwebsockets-dev ; \
else \
export LWS_VERSION=2.4.2 && \
wget https://github.com/warmcat/libwebsockets/archive/v${LWS_VERSION}.tar.gz -O /tmp/lws.tar.gz && \
mkdir -p /build/lws && \
tar --strip=1 -xf /tmp/lws.tar.gz -C /build/lws && \
rm /tmp/lws.tar.gz && \
cd /build/lws && \
cmake . \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_INSTALL_PREFIX=/usr \
-DLWS_IPV6=ON \
-DLWS_WITHOUT_BUILTIN_GETIFADDRS=ON \
-DLWS_WITHOUT_CLIENT=ON \
-DLWS_WITHOUT_EXTENSIONS=ON \
-DLWS_WITHOUT_TESTAPPS=ON \
-DLWS_WITH_HTTP2=OFF \
-DLWS_WITH_SHARED=OFF \
-DLWS_WITH_ZIP_FOPS=OFF \
-DLWS_WITH_ZLIB=OFF && \
make -j "$(nproc)" && \
rm -rf /root/.cmake ; \
fi
RUN apt-get update && apt-get install -y libc-ares2 libc-ares-dev cmake libssl-dev uuid uuid-dev wget build-essential git libcjson-dev

# Get libwebsocket. Debian's libwebsockets is too old for Mosquitto version > 2.x so it gets built from source.
RUN set -ex; \
wget https://github.com/warmcat/libwebsockets/archive/v${LWS_VERSION}.tar.gz -O /tmp/lws.tar.gz; \
mkdir -p /build/lws; \
tar --strip=1 -xf /tmp/lws.tar.gz -C /build/lws; \
rm /tmp/lws.tar.gz; \
cd /build/lws; \
cmake . \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_INSTALL_PREFIX=/usr \
-DLWS_IPV6=ON \
-DLWS_WITHOUT_BUILTIN_GETIFADDRS=ON \
-DLWS_WITHOUT_CLIENT=ON \
-DLWS_WITHOUT_EXTENSIONS=ON \
-DLWS_WITHOUT_TESTAPPS=ON \
-DLWS_WITH_HTTP2=OFF \
-DLWS_WITH_SHARED=OFF \
-DLWS_WITH_ZIP_FOPS=OFF \
-DLWS_WITH_ZLIB=OFF \
-DLWS_WITH_EXTERNAL_POLL=ON; \
make -j "$(nproc)"; \
rm -rf /root/.cmake

RUN mkdir -p mosquitto/auth mosquitto/conf.d

RUN wget http:https://mosquitto.org/files/source/mosquitto-${MOSQUITTO_VERSION}.tar.gz
RUN tar xzvf mosquitto-${MOSQUITTO_VERSION}.tar.gz && rm mosquitto-${MOSQUITTO_VERSION}.tar.gz

#Build mosquitto.
RUN cd mosquitto-${MOSQUITTO_VERSION} && make WITH_WEBSOCKETS=yes && make install && cd ..
# Build mosquitto.
RUN set -ex; \
cd mosquitto-${MOSQUITTO_VERSION}; \
make CFLAGS="-Wall -O2 -I/build/lws/include" LDFLAGS="-L/build/lws/lib" WITH_WEBSOCKETS=yes; \
make install; \
cd ..;

#Get Go.
RUN wget https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz
Expand Down
6 changes: 3 additions & 3 deletions backends/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func TestMysqlTls(t *testing.T) {
Convey("Given custom ssl disabled, it should fail", t, func() {
mysql, err := NewMysql(authOpts, log.DebugLevel, hashing.NewHasher(authOpts, "mysql"))
So(err, ShouldBeError)
So(err.Error(), ShouldContainSubstring, "Error 1045: Access denied for user")
So(err.Error(), ShouldContainSubstring, "Access denied for user")
So(mysql.DB, ShouldBeNil)
})

Expand Down Expand Up @@ -271,7 +271,7 @@ func TestMysqlMutualTls(t *testing.T) {
Convey("Given custom ssl enabled and no client certificate is given, it should fail", t, func() {
mysql, err := NewMysql(authOpts, log.DebugLevel, hashing.NewHasher(authOpts, "mysql"))
So(err, ShouldBeError)
So(err.Error(), ShouldContainSubstring, "Error 1045: Access denied for user")
So(err.Error(), ShouldContainSubstring, "Access denied for user")
So(mysql.DB, ShouldBeNil)
})

Expand All @@ -281,7 +281,7 @@ func TestMysqlMutualTls(t *testing.T) {
Convey("Given custom ssl enabled and unauthorized client certificate is given, it should fail", t, func() {
mysql, err := NewMysql(authOpts, log.DebugLevel, hashing.NewHasher(authOpts, "mysql"))
So(err, ShouldBeError)
So(err.Error(), ShouldContainSubstring, "Error 1045: Access denied for user")
So(err.Error(), ShouldContainSubstring, "Access denied for user")
So(mysql.DB, ShouldBeNil)
})

Expand Down
44 changes: 22 additions & 22 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,46 @@ go 1.18

require (
github.com/go-redis/redis/v8 v8.11.5
github.com/go-sql-driver/mysql v1.6.0
github.com/go-sql-driver/mysql v1.7.1
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/golang/protobuf v1.5.2
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/golang/protobuf v1.5.3
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/jmoiron/sqlx v1.3.5
github.com/lib/pq v1.10.6
github.com/lib/pq v1.10.9
github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pkg/errors v0.9.1
github.com/robertkrimen/otto v0.0.0-20211024170158-b87d35c0b86f
github.com/sirupsen/logrus v1.8.1
github.com/robertkrimen/otto v0.2.1
github.com/sirupsen/logrus v1.9.2
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a
github.com/stretchr/testify v1.7.0
go.mongodb.org/mongo-driver v1.9.1
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e
google.golang.org/grpc v1.47.0
github.com/stretchr/testify v1.8.1
go.mongodb.org/mongo-driver v1.11.6
golang.org/x/crypto v0.9.0
google.golang.org/grpc v1.55.0
)

require (
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gopherjs/gopherjs v0.0.0-20190328170749-bb2674552d8f // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/klauspost/compress v1.15.6 // indirect
github.com/klauspost/compress v1.16.5 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/smartystreets/assertions v0.0.0-20190401211740-f487f9de1cd3 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.1 // indirect
github.com/xdg-go/stringprep v1.0.3 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
golang.org/x/net v0.0.0-20220531201128-c960675eff93 // indirect
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20220602131408-e326c6e8e9c8 // indirect
google.golang.org/protobuf v1.28.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sync v0.2.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/sourcemap.v1 v1.0.5 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

0 comments on commit 83fa4e2

Please sign in to comment.