forked from locka99/opcua
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some tests for a few core services against the .NET server, and a better system for running tests. Also fixes a pretty subtle bug in the chunker that would produce too large chunks. This code really could use some work, since I believe the data chunk size is constant for symmetric messages in a given channel, but it's fine.
- Loading branch information
Showing
18 changed files
with
699 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
use std::sync::Arc; | ||
|
||
use opcua::{ | ||
client::{IdentityToken, Session}, | ||
crypto::SecurityPolicy, | ||
types::{ | ||
AttributeId, MessageSecurityMode, ReadValueId, ServerState, TimestampsToReturn, VariableId, | ||
}, | ||
}; | ||
|
||
use crate::{client::ClientTestState, tests::client::with_session, Runner}; | ||
|
||
async fn test_connect_inner(session: Arc<Session>, _ctx: &mut ClientTestState) { | ||
let read = session | ||
.read( | ||
&[ReadValueId { | ||
node_id: VariableId::Server_ServerStatus_State.into(), | ||
attribute_id: AttributeId::Value as u32, | ||
..Default::default() | ||
}], | ||
TimestampsToReturn::Both, | ||
0.0, | ||
) | ||
.await | ||
.unwrap(); | ||
assert_eq!( | ||
read[0].value.clone().unwrap().try_cast_to::<i32>().unwrap(), | ||
ServerState::Running as i32 | ||
); | ||
} | ||
|
||
async fn test_connect( | ||
policy: SecurityPolicy, | ||
mode: MessageSecurityMode, | ||
ctx: &mut ClientTestState, | ||
) { | ||
with_session( | ||
test_connect_inner, | ||
policy, | ||
mode, | ||
IdentityToken::UserName("test".to_owned(), "pass".to_owned()), | ||
ctx, | ||
) | ||
.await; | ||
} | ||
|
||
pub async fn run_connect_tests(runner: &Runner, ctx: &mut ClientTestState) { | ||
for (policy, mode) in [ | ||
(SecurityPolicy::None, MessageSecurityMode::None), | ||
(SecurityPolicy::Basic256Sha256, MessageSecurityMode::Sign), | ||
( | ||
SecurityPolicy::Basic256Sha256, | ||
MessageSecurityMode::SignAndEncrypt, | ||
), | ||
( | ||
SecurityPolicy::Aes128Sha256RsaOaep, | ||
MessageSecurityMode::Sign, | ||
), | ||
( | ||
SecurityPolicy::Aes128Sha256RsaOaep, | ||
MessageSecurityMode::SignAndEncrypt, | ||
), | ||
( | ||
SecurityPolicy::Aes256Sha256RsaPss, | ||
MessageSecurityMode::Sign, | ||
), | ||
( | ||
SecurityPolicy::Aes256Sha256RsaPss, | ||
MessageSecurityMode::SignAndEncrypt, | ||
), | ||
// The .NET SDK is hard to use with these, since its configuration around minimum | ||
// required nonce length is really weird. | ||
/*(SecurityPolicy::Basic128Rsa15, MessageSecurityMode::Sign), | ||
( | ||
SecurityPolicy::Basic128Rsa15, | ||
MessageSecurityMode::SignAndEncrypt, | ||
), */ | ||
(SecurityPolicy::Basic256, MessageSecurityMode::Sign), | ||
( | ||
SecurityPolicy::Basic256, | ||
MessageSecurityMode::SignAndEncrypt, | ||
), | ||
] { | ||
runner | ||
.run_test( | ||
&format!("Connect {policy}:{mode}"), | ||
test_connect(policy, mode, ctx), | ||
) | ||
.await; | ||
} | ||
} |
Oops, something went wrong.