Skip to content

Commit

Permalink
Building and passing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
locka99 committed Apr 12, 2022
1 parent b798a4f commit 1bcef6a
Show file tree
Hide file tree
Showing 62 changed files with 169 additions and 166 deletions.
95 changes: 51 additions & 44 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"
log = "0.4"
chrono = "0.4"

[dev-dependencies.opcua-rs]
[dev-dependencies.opcua]
path = "../lib"
version = "0.10.0" # OPCUARustVersion
features = ["all"]
21 changes: 11 additions & 10 deletions integration/src/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ use std::{
use chrono::Utc;
use log::*;

use crate::client::prelude::*;
use crate::console_logging;
use crate::core::{self, runtime_components};
use crate::server::{
self, builder::ServerBuilder, callbacks, config::ServerEndpoint, prelude::*,
session::SessionManager,
use opcua::{
client::prelude::*,
runtime_components,
server::{
builder::ServerBuilder, callbacks, config::ServerEndpoint, prelude::*,
session::SessionManager,
},
};

use crate::*;
Expand Down Expand Up @@ -45,7 +46,7 @@ fn next_port_offset() -> u16 {

pub fn hostname() -> String {
// To avoid certificate trouble, use the computer's own name for the endpoint
let mut names = opcua_crypto::X509Data::computer_hostnames();
let mut names = opcua::crypto::X509Data::computer_hostnames();
if names.is_empty() {
"localhost".to_string()
} else {
Expand Down Expand Up @@ -105,7 +106,7 @@ pub fn new_server(port: u16) -> Server {

// Create user tokens - anonymous and a sample user
let user_token_ids = vec![
opcua_server::prelude::ANONYMOUS_USER_TOKEN_ID,
opcua::server::prelude::ANONYMOUS_USER_TOKEN_ID,
sample_user_id,
x509_user_id,
];
Expand Down Expand Up @@ -380,7 +381,7 @@ pub fn perform_test<CT, ST>(
CT: FnOnce(mpsc::Receiver<ClientCommand>, Client) + Send + 'static,
ST: FnOnce(mpsc::Receiver<ServerCommand>, Server) + Send + 'static,
{
opcua_console_logging::init();
opcua::console_logging::init();

// Spawn the CLIENT thread
let (client_thread, tx_client_command, rx_client_response) = {
Expand Down Expand Up @@ -682,7 +683,7 @@ pub fn connect_with_get_endpoints(port: u16) {

pub fn connect_with_invalid_token(
port: u16,
mut client_endpoint: EndpointDescription,
client_endpoint: EndpointDescription,
identity_token: IdentityToken,
) {
connect_with_client_test(
Expand Down
9 changes: 4 additions & 5 deletions integration/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ use std::{
use chrono::Utc;
use log::*;

use crate::client::prelude::*;
use crate::console_logging;
use crate::server::{self, prelude::*};
use opcua::client::prelude::*;
use opcua::server::prelude::*;

use crate::harness::*;

Expand Down Expand Up @@ -123,7 +122,7 @@ fn endpoint_aes256sha256rsapss_sign_encrypt(port: u16) -> EndpointDescription {
#[test]
#[ignore]
fn server_abort() {
opcua_console_logging::init();
opcua::console_logging::init();

let server = Arc::new(RwLock::new(new_server(0)));
let server2 = server.clone();
Expand Down Expand Up @@ -180,7 +179,7 @@ fn hello_timeout() {
let client_test = move |_rx_client_command: mpsc::Receiver<ClientCommand>, _client: Client| {
// Client will open a socket, and sit there waiting for the socket to close, which should happen in under the timeout_wait_duration
let timeout_wait_duration = std::time::Duration::from_secs(
opcua_server::constants::DEFAULT_HELLO_TIMEOUT_SECONDS as u64 + 3,
opcua::server::constants::DEFAULT_HELLO_TIMEOUT_SECONDS as u64 + 3,
);

let host = crate::harness::hostname();
Expand Down
9 changes: 5 additions & 4 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "opcua-rs"
name = "opcua"
version = "0.10.0" # OPCUARustVersion
description = "OPC UA client API"
authors = ["Adam Lock <[email protected]>"]
Expand All @@ -20,7 +20,7 @@ appveyor = { repository = "locka99/opcua" }

[features]
default = ["server", "client"]
all = ["server", "client", "console-logging"]
all = ["server", "client", "console-logging", "http"]
server = ["generated-address-space", "discovery-server-registration"]
client = []
console-logging = ["env_logger"]
Expand Down Expand Up @@ -62,7 +62,7 @@ libc = "0.2"
foreign-types = "0.3"

[dependencies.env_logger]
env_logger = "0.5"
version = "0.5"
optional = true

[dependencies.actix-web]
Expand All @@ -71,4 +71,5 @@ optional = true

[dev-dependencies]
tempdir = "0.3"
serde_json = "1.0"
serde_json = "1.0"
rustc-serialize = "0.3.24"
2 changes: 1 addition & 1 deletion lib/src/client/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::core::config::Config;
/// # Example
///
/// ```no_run
/// use crate::client::prelude::*;
/// use opcua::client::prelude::*;
///
/// fn main() {
/// let builder = ClientBuilder::new()
Expand Down
2 changes: 1 addition & 1 deletion lib/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
//!
//! ```no_run
//! use std::sync::{Arc, RwLock};
//! use crate::client::prelude::*;
//! use opcua::client::prelude::*;
//!
//! fn main() {
//! let mut client = ClientBuilder::new()
Expand Down
2 changes: 1 addition & 1 deletion lib/src/client/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::core::config::Config;
use crate::crypto::SecurityPolicy;
use crate::types::*;

use crate::{
use crate::client::{
builder::ClientBuilder,
config::{ClientConfig, ClientEndpoint, ClientUserToken, ANONYMOUS_USER_TOKEN_ID},
};
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/src/core/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ path = "../../types"
path = "../../crypto"

[dependencies.opcua-console-logging]
path = "../../console-logging"
path = "../../console_logging"

# Prevent this from interfering with workspaces
[workspace]
Expand Down
2 changes: 1 addition & 1 deletion lib/src/core/fuzz/fuzz_targets/fuzz_comms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn decode(buf: &mut BytesMut, codec: &mut TcpCodec) -> Result<Option<Message
}

fuzz_target!(|data: &[u8]| {
opcua_console_logging::init();
crate::console_logging::init();
// With some random data, just try and deserialize it
let decoding_options = DecodingOptions::default();
let abort = Arc::new(RwLock::new(false));
Expand Down
4 changes: 2 additions & 2 deletions lib/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ lazy_static! {
#[macro_export]
macro_rules! runtime_components {
() => {{
use crate::core::RUNTIME;
use $crate::core::RUNTIME;
RUNTIME.components()
}};
}
Expand Down Expand Up @@ -91,7 +91,7 @@ pub mod debug {
}

#[cfg(test)]
mod tests;
pub mod tests;

pub mod comms;
pub mod config;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/core/tests/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::io::{Cursor, Write};
use crate::crypto::{x509::X509, SecurityPolicy};
use crate::types::DecodingOptions;

use crate::{
use crate::core::{
comms::{chunker::*, message_chunk::*, secure_channel::*, tcp_types::MIN_CHUNK_SIZE},
supported_message::SupportedMessage,
tests::*,
Expand Down Expand Up @@ -475,7 +475,7 @@ fn security_policy_symmetric_encrypt_decrypt() {
fn asymmetric_decrypt_and_verify_sample_chunk() {
let _ = Test::setup();

use crate::tests::chunk::serialize::hex::FromHex;
use serialize::hex::FromHex;

let their_cert_data = include_bytes!("test_data/their_cert.der");
let their_cert = X509::from_der(&their_cert_data[..]).unwrap();
Expand Down
Loading

0 comments on commit 1bcef6a

Please sign in to comment.