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 641098d
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 230 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
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
else
echo "Skipping on Windows."
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.

2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from conans import ConanFile, CMake, tools


class autobahn_cppConan(ConanFile):
name = "autobahn-cpp"
version = "v20.8.1"
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))));
}
36 changes: 19 additions & 17 deletions test/calls/calls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,25 @@
#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.calls.simple")
{
bool joined_realm_with_success = join_realm(
"client1",
wamp_test::Ticket("ticket"),
[&](Transport& transport, Session& session)
{
REQUIRE(3 == call<int>("com.example.add2", std::tuple<int, int>(1, 2)).get());
REQUIRE(5 == call<int>("com.example.add2", std::tuple<int, int>(2, 3)).get());
REQUIRE(!call<int>("com.example.unknown", std::tuple<int, int, int>(3, 4, 5)).has_value());
});
REQUIRE(true == joined_realm_with_success);
TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.calls.simple") {
bool joined_realm_with_success = join_realm(
"client1", wamp_test::Ticket("ticket"),
[&](Transport &transport, Session &session) {
REQUIRE(
3 ==
call<int>("com.example.add2", std::tuple<int, int>(1, 2)).get());
REQUIRE(
5 ==
call<int>("com.example.add2", std::tuple<int, int>(2, 3)).get());
REQUIRE(!call<int>("com.example.unknown",
std::tuple<int, int, int>(3, 4, 5))
.has_value());
});
REQUIRE(true == joined_realm_with_success);
}
Loading

0 comments on commit 641098d

Please sign in to comment.