|
31 | 31 | #include "test/wamp_test.hpp"
|
32 | 32 | #include <catch2/catch.hpp>
|
33 | 33 |
|
34 |
| -struct Config |
35 |
| -{ |
36 |
| - std::string realm{"realm1"}; |
37 |
| - std::string uri{"ws://127.0.0.1:8080/ws"}; |
38 |
| - bool debug{false}; |
| 34 | +struct Config { |
| 35 | + std::string realm{"realm1"}; |
| 36 | + std::string uri{"ws://127.0.0.1:8080/ws"}; |
| 37 | + bool debug{false}; |
39 | 38 | };
|
40 | 39 |
|
41 |
| -TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.auth.cra") |
42 |
| -{ |
43 |
| - bool joined_realm_with_success = join_realm( |
44 |
| - "client1_cra", |
45 |
| - wamp_test::Secret("client1_secret"), |
46 |
| - [&](Transport& transport, Session& session) |
47 |
| - { |
48 |
| - auto welcome_details = session.welcome_details(); |
49 |
| - REQUIRE(welcome_details["authprovider"].as<std::string>() == "static"); |
50 |
| - REQUIRE(welcome_details["realm"].as<std::string>() == "realm1"); |
51 |
| - REQUIRE(welcome_details["authid"].as<std::string>() == "client1_cra"); |
52 |
| - REQUIRE(welcome_details["authrole"].as<std::string>() == "frontend"); |
53 |
| - }); |
54 |
| - REQUIRE(true == joined_realm_with_success); |
55 |
| - joined_realm_with_success = join_realm( |
56 |
| - "client2_cra", |
57 |
| - wamp_test::Secret("client2_secret"), |
58 |
| - [&](Transport& transport, Session& session) |
59 |
| - { |
60 |
| - auto welcome_details = session.welcome_details(); |
61 |
| - REQUIRE(welcome_details["authprovider"].as<std::string>() == "static"); |
62 |
| - REQUIRE(welcome_details["realm"].as<std::string>() == "realm1"); |
63 |
| - REQUIRE(welcome_details["authid"].as<std::string>() == "client2_cra"); |
64 |
| - REQUIRE(welcome_details["authrole"].as<std::string>() == "backend"); |
65 |
| - }); |
66 |
| - REQUIRE(true == joined_realm_with_success); |
67 |
| - REQUIRE(false == join_realm("client3", wamp_test::Secret("unknown"))); |
| 40 | +TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.auth.cra") { |
| 41 | + bool joined_realm_with_success = join_realm( |
| 42 | + "client1_cra", wamp_test::Secret("client1_secret"), |
| 43 | + [&](Transport &transport, Session &session) { |
| 44 | + auto welcome_details = session.welcome_details(); |
| 45 | + REQUIRE(welcome_details["authprovider"].as<std::string>() == "static"); |
| 46 | + REQUIRE(welcome_details["realm"].as<std::string>() == "realm1"); |
| 47 | + REQUIRE(welcome_details["authid"].as<std::string>() == "client1_cra"); |
| 48 | + REQUIRE(welcome_details["authrole"].as<std::string>() == "frontend"); |
| 49 | + }); |
| 50 | + REQUIRE(true == joined_realm_with_success); |
| 51 | + joined_realm_with_success = join_realm( |
| 52 | + "client2_cra", wamp_test::Secret("client2_secret"), |
| 53 | + [&](Transport &transport, Session &session) { |
| 54 | + auto welcome_details = session.welcome_details(); |
| 55 | + REQUIRE(welcome_details["authprovider"].as<std::string>() == "static"); |
| 56 | + REQUIRE(welcome_details["realm"].as<std::string>() == "realm1"); |
| 57 | + REQUIRE(welcome_details["authid"].as<std::string>() == "client2_cra"); |
| 58 | + REQUIRE(welcome_details["authrole"].as<std::string>() == "backend"); |
| 59 | + }); |
| 60 | + REQUIRE(true == joined_realm_with_success); |
| 61 | + REQUIRE(false == join_realm("client3", wamp_test::Secret("unknown"))); |
68 | 62 | }
|
69 | 63 |
|
70 |
| -TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.auth.ticket") |
71 |
| -{ |
72 |
| - bool joined_realm_with_success = join_realm( |
73 |
| - "client1", |
74 |
| - wamp_test::Ticket("client1_ticket"), |
75 |
| - [&](Transport& transport, Session& session) |
76 |
| - { |
77 |
| - auto welcome_details = session.welcome_details(); |
78 |
| - REQUIRE(welcome_details["authprovider"].as<std::string>() == "static"); |
79 |
| - REQUIRE(welcome_details["realm"].as<std::string>() == "realm1"); |
80 |
| - REQUIRE(welcome_details["authid"].as<std::string>() == "client1"); |
81 |
| - REQUIRE(welcome_details["authrole"].as<std::string>() == "frontend"); |
82 |
| - }); |
83 |
| - REQUIRE(true == joined_realm_with_success); |
84 |
| - joined_realm_with_success = join_realm( |
85 |
| - "client2", |
86 |
| - wamp_test::Ticket("client2_ticket"), |
87 |
| - [&](Transport& transport, Session& session) |
88 |
| - { |
89 |
| - auto welcome_details = session.welcome_details(); |
90 |
| - REQUIRE(welcome_details["authprovider"].as<std::string>() == "static"); |
91 |
| - REQUIRE(welcome_details["realm"].as<std::string>() == "realm1"); |
92 |
| - REQUIRE(welcome_details["authid"].as<std::string>() == "client2"); |
93 |
| - REQUIRE(welcome_details["authrole"].as<std::string>() == "backend"); |
94 |
| - }); |
95 |
| - REQUIRE(true == joined_realm_with_success); |
96 |
| - REQUIRE(false == join_realm("client3", wamp_test::Ticket("unknown"))); |
| 64 | +TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.auth.ticket") { |
| 65 | + bool joined_realm_with_success = join_realm( |
| 66 | + "client1", wamp_test::Ticket("client1_ticket"), |
| 67 | + [&](Transport &transport, Session &session) { |
| 68 | + auto welcome_details = session.welcome_details(); |
| 69 | + REQUIRE(welcome_details["authprovider"].as<std::string>() == "static"); |
| 70 | + REQUIRE(welcome_details["realm"].as<std::string>() == "realm1"); |
| 71 | + REQUIRE(welcome_details["authid"].as<std::string>() == "client1"); |
| 72 | + REQUIRE(welcome_details["authrole"].as<std::string>() == "frontend"); |
| 73 | + }); |
| 74 | + REQUIRE(true == joined_realm_with_success); |
| 75 | + joined_realm_with_success = join_realm( |
| 76 | + "client2", wamp_test::Ticket("client2_ticket"), |
| 77 | + [&](Transport &transport, Session &session) { |
| 78 | + auto welcome_details = session.welcome_details(); |
| 79 | + REQUIRE(welcome_details["authprovider"].as<std::string>() == "static"); |
| 80 | + REQUIRE(welcome_details["realm"].as<std::string>() == "realm1"); |
| 81 | + REQUIRE(welcome_details["authid"].as<std::string>() == "client2"); |
| 82 | + REQUIRE(welcome_details["authrole"].as<std::string>() == "backend"); |
| 83 | + }); |
| 84 | + REQUIRE(true == joined_realm_with_success); |
| 85 | + REQUIRE(false == join_realm("client3", wamp_test::Ticket("unknown"))); |
97 | 86 | }
|
98 | 87 |
|
99 |
| -TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.auth.cryptosign") |
100 |
| -{ |
101 |
| - bool joined_realm_with_success = join_realm( |
102 |
| - "3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29", |
103 |
| - wamp_test::Cryptosign(Botan::secure_vector<uint8_t>(32, 0)), |
104 |
| - [&](Transport& transport, Session& session) |
105 |
| - { |
106 |
| - auto welcome_details = session.welcome_details(); |
107 |
| - REQUIRE(welcome_details["authprovider"].as<std::string>() == "static"); |
108 |
| - REQUIRE(welcome_details["realm"].as<std::string>() == "realm1"); |
109 |
| - REQUIRE( |
110 |
| - welcome_details["authid"].as<std::string>() |
111 |
| - == "3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29"); |
112 |
| - REQUIRE(welcome_details["authrole"].as<std::string>() == "frontend"); |
113 |
| - }); |
114 |
| - REQUIRE(true == joined_realm_with_success); |
115 |
| - joined_realm_with_success = join_realm( |
116 |
| - "8a88e3dd7409f195fd52db2d3cba5d72ca6709bf1d94121bf3748801b40f6f5c", |
117 |
| - wamp_test::Cryptosign(Botan::secure_vector<uint8_t>(32, 1)), |
118 |
| - [&](Transport& transport, Session& session) |
119 |
| - { |
120 |
| - auto welcome_details = session.welcome_details(); |
121 |
| - REQUIRE(welcome_details["authprovider"].as<std::string>() == "static"); |
122 |
| - REQUIRE(welcome_details["realm"].as<std::string>() == "realm1"); |
123 |
| - REQUIRE( |
124 |
| - welcome_details["authid"].as<std::string>() |
125 |
| - == "8a88e3dd7409f195fd52db2d3cba5d72ca6709bf1d94121bf3748801b40f6f5c"); |
126 |
| - REQUIRE(welcome_details["authrole"].as<std::string>() == "backend"); |
127 |
| - }); |
128 |
| - REQUIRE(true == joined_realm_with_success); |
129 |
| - REQUIRE(false == join_realm("unknown", wamp_test::Cryptosign(Botan::secure_vector<uint8_t>(32, 3)))); |
| 88 | +TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.auth.cryptosign") { |
| 89 | + bool joined_realm_with_success = join_realm( |
| 90 | + "3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29", |
| 91 | + wamp_test::Cryptosign(Botan::secure_vector<uint8_t>(32, 0)), |
| 92 | + [&](Transport &transport, Session &session) { |
| 93 | + auto welcome_details = session.welcome_details(); |
| 94 | + REQUIRE(welcome_details["authprovider"].as<std::string>() == "static"); |
| 95 | + REQUIRE(welcome_details["realm"].as<std::string>() == "realm1"); |
| 96 | + REQUIRE( |
| 97 | + welcome_details["authid"].as<std::string>() == |
| 98 | + "3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29"); |
| 99 | + REQUIRE(welcome_details["authrole"].as<std::string>() == "frontend"); |
| 100 | + }); |
| 101 | + REQUIRE(true == joined_realm_with_success); |
| 102 | + joined_realm_with_success = join_realm( |
| 103 | + "8a88e3dd7409f195fd52db2d3cba5d72ca6709bf1d94121bf3748801b40f6f5c", |
| 104 | + wamp_test::Cryptosign(Botan::secure_vector<uint8_t>(32, 1)), |
| 105 | + [&](Transport &transport, Session &session) { |
| 106 | + auto welcome_details = session.welcome_details(); |
| 107 | + REQUIRE(welcome_details["authprovider"].as<std::string>() == "static"); |
| 108 | + REQUIRE(welcome_details["realm"].as<std::string>() == "realm1"); |
| 109 | + REQUIRE( |
| 110 | + welcome_details["authid"].as<std::string>() == |
| 111 | + "8a88e3dd7409f195fd52db2d3cba5d72ca6709bf1d94121bf3748801b40f6f5c"); |
| 112 | + REQUIRE(welcome_details["authrole"].as<std::string>() == "backend"); |
| 113 | + }); |
| 114 | + REQUIRE(true == joined_realm_with_success); |
| 115 | + REQUIRE(false == |
| 116 | + join_realm("unknown", wamp_test::Cryptosign( |
| 117 | + Botan::secure_vector<uint8_t>(32, 3)))); |
130 | 118 | }
|
0 commit comments