Skip to content

Commit

Permalink
Adapt workflow for conan.
Browse files Browse the repository at this point in the history
  • Loading branch information
aarlt committed Feb 28, 2022
1 parent 3e37056 commit 6c02721
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 231 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: build-and-test
on: [ push, workflow_dispatch ]

jobs:
job:
name: ${{ matrix.os }}-${{ github.workflow }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
include:
- os: windows-latest
triplet: x64-windows
- os: ubuntu-latest
triplet: x64-linux
- os: macos-latest
triplet: x64-osx

steps:
- uses: actions/checkout@v2
with:
submodules: true

- uses: actions/setup-python@v2
with:
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified

- name: Prepare Docker.
uses: docker-practice/actions-setup-docker@master

- name: Prepare Tools.
run: |
pip install conan
if [ "$RUNNER_OS" != "Windows" ]; then
docker pull crossbario/crossbar
fi
shell: bash

- name: Restore Dependency Cache.
uses: actions/cache@v2
with:
path: |
/home/runner/.conan/data
# The key is composed in a way that it gets properly invalidated: this must happen whenever vcpkg's Git commit id changes, or the list of packages changes. In this case a cache miss must happen and a new entry with a new key with be pushed to GitHub the cache service.
# The key includes: hash of the vcpkg.json file, the hash of the vcpkg Git commit id, and the used vcpkg's triplet. The vcpkg's commit id would suffice, but computing an hash out it does not harm.
# Note: given a key, the cache content is immutable. If a cache entry has been created improperly, in order the recreate the right content the key must be changed as well, and it must be brand new (i.e. not existing already).
key: |
${{ hashFiles( 'conanfile.py' ) }}-${{ matrix.triplet }}
# Run CMake to generate Ninja project files, using the vcpkg's toolchain file to resolve and install the dependencies as specified in vcpkg.json.
- name: Build and Test.
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make
if [ "$RUNNER_OS" != "Windows" ]; then
ctest
fi
shell: bash
94 changes: 0 additions & 94 deletions .github/workflows/hosted-pure-workflow.yml

This file was deleted.

4 changes: 2 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from conans import ConanFile, CMake, tools


class autobahn_cppConan(ConanFile):
name = "autobahn-cpp"
version = "v20.8.1"
license = "Boost Software License - Version 1.0 - August 17th, 2003"
author = "Crossbar.io Technologies GmbH and contributors"
description = "WAMP for C++ on Boost/ASIO"
url = "https://github.com/crossbario/autobahn-cpp"
requires = "boost/1.77.0", "msgpack-cxx/4.0.3", "websocketpp/0.8.2", "openssl/3.0.1", "botan/2.19.1", "catch2/2.13.8"
requires = "openssl/3.0.1", "botan/2.19.1", "boost/1.78.0", "msgpack-cxx/4.0.3", "websocketpp/0.8.2", "catch2/2.13.8"
generators = "cmake"
scm = {
"type": "git",
Expand All @@ -23,4 +24,3 @@ def package(self):

def package_id(self):
self.info.header_only()

168 changes: 78 additions & 90 deletions test/auth/auth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,100 +31,88 @@
#include "test/wamp_test.hpp"
#include <catch2/catch.hpp>

struct Config
{
std::string realm{"realm1"};
std::string uri{"ws://127.0.0.1:8080/ws"};
bool debug{false};
struct Config {
std::string realm{"realm1"};
std::string uri{"ws://127.0.0.1:8080/ws"};
bool debug{false};
};

TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.auth.cra")
{
bool joined_realm_with_success = join_realm(
"client1_cra",
wamp_test::Secret("client1_secret"),
[&](Transport& transport, Session& session)
{
auto welcome_details = session.welcome_details();
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
REQUIRE(welcome_details["authid"].as<std::string>() == "client1_cra");
REQUIRE(welcome_details["authrole"].as<std::string>() == "frontend");
});
REQUIRE(true == joined_realm_with_success);
joined_realm_with_success = join_realm(
"client2_cra",
wamp_test::Secret("client2_secret"),
[&](Transport& transport, Session& session)
{
auto welcome_details = session.welcome_details();
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
REQUIRE(welcome_details["authid"].as<std::string>() == "client2_cra");
REQUIRE(welcome_details["authrole"].as<std::string>() == "backend");
});
REQUIRE(true == joined_realm_with_success);
REQUIRE(false == join_realm("client3", wamp_test::Secret("unknown")));
TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.auth.cra") {
bool joined_realm_with_success = join_realm(
"client1_cra", wamp_test::Secret("client1_secret"),
[&](Transport &transport, Session &session) {
auto welcome_details = session.welcome_details();
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
REQUIRE(welcome_details["authid"].as<std::string>() == "client1_cra");
REQUIRE(welcome_details["authrole"].as<std::string>() == "frontend");
});
REQUIRE(true == joined_realm_with_success);
joined_realm_with_success = join_realm(
"client2_cra", wamp_test::Secret("client2_secret"),
[&](Transport &transport, Session &session) {
auto welcome_details = session.welcome_details();
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
REQUIRE(welcome_details["authid"].as<std::string>() == "client2_cra");
REQUIRE(welcome_details["authrole"].as<std::string>() == "backend");
});
REQUIRE(true == joined_realm_with_success);
REQUIRE(false == join_realm("client3", wamp_test::Secret("unknown")));
}

TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.auth.ticket")
{
bool joined_realm_with_success = join_realm(
"client1",
wamp_test::Ticket("client1_ticket"),
[&](Transport& transport, Session& session)
{
auto welcome_details = session.welcome_details();
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
REQUIRE(welcome_details["authid"].as<std::string>() == "client1");
REQUIRE(welcome_details["authrole"].as<std::string>() == "frontend");
});
REQUIRE(true == joined_realm_with_success);
joined_realm_with_success = join_realm(
"client2",
wamp_test::Ticket("client2_ticket"),
[&](Transport& transport, Session& session)
{
auto welcome_details = session.welcome_details();
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
REQUIRE(welcome_details["authid"].as<std::string>() == "client2");
REQUIRE(welcome_details["authrole"].as<std::string>() == "backend");
});
REQUIRE(true == joined_realm_with_success);
REQUIRE(false == join_realm("client3", wamp_test::Ticket("unknown")));
TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.auth.ticket") {
bool joined_realm_with_success = join_realm(
"client1", wamp_test::Ticket("client1_ticket"),
[&](Transport &transport, Session &session) {
auto welcome_details = session.welcome_details();
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
REQUIRE(welcome_details["authid"].as<std::string>() == "client1");
REQUIRE(welcome_details["authrole"].as<std::string>() == "frontend");
});
REQUIRE(true == joined_realm_with_success);
joined_realm_with_success = join_realm(
"client2", wamp_test::Ticket("client2_ticket"),
[&](Transport &transport, Session &session) {
auto welcome_details = session.welcome_details();
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
REQUIRE(welcome_details["authid"].as<std::string>() == "client2");
REQUIRE(welcome_details["authrole"].as<std::string>() == "backend");
});
REQUIRE(true == joined_realm_with_success);
REQUIRE(false == join_realm("client3", wamp_test::Ticket("unknown")));
}

TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.auth.cryptosign")
{
bool joined_realm_with_success = join_realm(
"3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29",
wamp_test::Cryptosign(Botan::secure_vector<uint8_t>(32, 0)),
[&](Transport& transport, Session& session)
{
auto welcome_details = session.welcome_details();
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
REQUIRE(
welcome_details["authid"].as<std::string>()
== "3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29");
REQUIRE(welcome_details["authrole"].as<std::string>() == "frontend");
});
REQUIRE(true == joined_realm_with_success);
joined_realm_with_success = join_realm(
"8a88e3dd7409f195fd52db2d3cba5d72ca6709bf1d94121bf3748801b40f6f5c",
wamp_test::Cryptosign(Botan::secure_vector<uint8_t>(32, 1)),
[&](Transport& transport, Session& session)
{
auto welcome_details = session.welcome_details();
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
REQUIRE(
welcome_details["authid"].as<std::string>()
== "8a88e3dd7409f195fd52db2d3cba5d72ca6709bf1d94121bf3748801b40f6f5c");
REQUIRE(welcome_details["authrole"].as<std::string>() == "backend");
});
REQUIRE(true == joined_realm_with_success);
REQUIRE(false == join_realm("unknown", wamp_test::Cryptosign(Botan::secure_vector<uint8_t>(32, 3))));
TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.auth.cryptosign") {
bool joined_realm_with_success = join_realm(
"3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29",
wamp_test::Cryptosign(Botan::secure_vector<uint8_t>(32, 0)),
[&](Transport &transport, Session &session) {
auto welcome_details = session.welcome_details();
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
REQUIRE(
welcome_details["authid"].as<std::string>() ==
"3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29");
REQUIRE(welcome_details["authrole"].as<std::string>() == "frontend");
});
REQUIRE(true == joined_realm_with_success);
joined_realm_with_success = join_realm(
"8a88e3dd7409f195fd52db2d3cba5d72ca6709bf1d94121bf3748801b40f6f5c",
wamp_test::Cryptosign(Botan::secure_vector<uint8_t>(32, 1)),
[&](Transport &transport, Session &session) {
auto welcome_details = session.welcome_details();
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
REQUIRE(
welcome_details["authid"].as<std::string>() ==
"8a88e3dd7409f195fd52db2d3cba5d72ca6709bf1d94121bf3748801b40f6f5c");
REQUIRE(welcome_details["authrole"].as<std::string>() == "backend");
});
REQUIRE(true == joined_realm_with_success);
REQUIRE(false ==
join_realm("unknown", wamp_test::Cryptosign(
Botan::secure_vector<uint8_t>(32, 3))));
}
Loading

0 comments on commit 6c02721

Please sign in to comment.