Skip to content

Commit 77d10c5

Browse files
authored
Merge pull request #96 from anta5010/can-do-crypto
Merge origin/main into can-do-crypto
2 parents 6fbcbfa + 9bdf405 commit 77d10c5

File tree

7 files changed

+59
-33
lines changed

7 files changed

+59
-33
lines changed

.cargo/audit.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[advisories]
2-
ignore = ["RUSTSEC-2021-0073", # We do not use `prost_types::Timestamp` anywhere in our code.
3-
"RUSTSEC-2020-0036"] # We don't have control over the exact dependencies of `protoc-grpcio`; See https://github.com/mtp401/protoc-grpcio/issues/36
2+
ignore = []
43
informational_warnings = ["unmaintained"] # warn for categories of informational advisories
54
severity_threshold = "low" # CVSS severity ("none", "low", "medium", "high", "critical")
65

@@ -28,4 +27,4 @@ source = "all" # "all", "public" or "local"
2827

2928
[yanked]
3029
enabled = true # Warn for yanked crates in Cargo.lock
31-
update_index = true # Auto-update the crates.io index
30+
update_index = true # Auto-update the crates.io index

.github/workflows/ci.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ jobs:
77
name: Build and check formatting
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v1
11-
- name: Execute all tests
12-
run: ./tests/ci.sh
10+
- uses: actions/checkout@v2
11+
- name: Set up Python 3.7
12+
uses: actions/setup-python@v1
13+
with:
14+
python-version: 3.7
15+
- name: Download Parsec Mock, install dependencies and execute all tests
16+
run: |
17+
curl -s -N -L https://github.com/parallaxsecond/parsec-mock/archive/refs/tags/0.1.1.tar.gz | tar xz
18+
cd parsec-mock-0.1.1/
19+
python -m pip install --upgrade pip
20+
pip install -r requirements.txt
21+
cd ..
22+
./tests/ci.sh

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ derivative = "2.1.1"
1919
zeroize = "1.1.0"
2020
users = "0.10.0"
2121
url = "2.2.0"
22-
spiffe = { version = "0.1.1", optional = true }
22+
spiffe = { version = "0.2.0", optional = true }
2323

2424
[dev-dependencies]
2525
mockstream = "0.0.3"

src/core/basic_client.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,16 @@ impl BasicClient {
117117
///#
118118
///# fn main() -> Result<(), Box<dyn Error>> {
119119
///use parsec_client::BasicClient;
120-
///let client = BasicClient::new_naked();
120+
///let client = BasicClient::new_naked()?;
121121
///let (major, minor) = client.ping()?;
122122
///# Ok(())}
123123
/// ```
124-
pub fn new_naked() -> Self {
125-
BasicClient {
126-
op_client: Default::default(),
124+
pub fn new_naked() -> Result<Self> {
125+
Ok(BasicClient {
126+
op_client: OperationClient::new()?,
127127
auth_data: Authentication::None,
128128
implicit_provider: ProviderId::Core,
129-
}
129+
})
130130
}
131131

132132
/// Query the service for the list of authenticators provided and use the first one as default
@@ -151,7 +151,7 @@ impl BasicClient {
151151
///# fn main() -> Result<(), Box<dyn Error>> {
152152
///use parsec_client::BasicClient;
153153
///use parsec_client::core::interface::requests::ProviderId;
154-
///let mut client = BasicClient::new_naked();
154+
///let mut client = BasicClient::new_naked()?;
155155
///// Set the default authenticator but choose a specific provider.
156156
///client.set_implicit_provider(ProviderId::Pkcs11);
157157
///client.set_default_auth(Some("main_client".to_string()))?;
@@ -210,7 +210,7 @@ impl BasicClient {
210210
///# fn main() -> Result<(), Box<dyn Error>> {
211211
///use parsec_client::BasicClient;
212212
///use parsec_client::auth::Authentication;
213-
///let mut client = BasicClient::new_naked();
213+
///let mut client = BasicClient::new_naked()?;
214214
///client.set_auth_data(Authentication::UnixPeerCredentials);
215215
///assert_eq!(Authentication::UnixPeerCredentials, client.auth_data());
216216
///# Ok(())}
@@ -234,7 +234,7 @@ impl BasicClient {
234234
///# fn main() -> Result<(), Box<dyn Error>> {
235235
///use parsec_client::BasicClient;
236236
///use parsec_client::auth::Authentication;
237-
///let mut client = BasicClient::new_naked();
237+
///let mut client = BasicClient::new_naked()?;
238238
///// Use the default provider but use a specific authentication.
239239
///client.set_default_provider()?;
240240
///client.set_auth_data(Authentication::UnixPeerCredentials);
@@ -269,7 +269,7 @@ impl BasicClient {
269269
///# fn main() -> Result<(), Box<dyn Error>> {
270270
///use parsec_client::BasicClient;
271271
///use parsec_client::core::interface::requests::ProviderId;
272-
///let mut client = BasicClient::new_naked();
272+
///let mut client = BasicClient::new_naked()?;
273273
///client.set_implicit_provider(ProviderId::Pkcs11);
274274
///assert_eq!(ProviderId::Pkcs11, client.implicit_provider());
275275
///# Ok(())}
@@ -328,7 +328,7 @@ impl BasicClient {
328328
///# fn main() -> Result<(), Box<dyn Error>> {
329329
///use parsec_client::BasicClient;
330330
///
331-
///let mut client: BasicClient = BasicClient::new_naked();
331+
///let mut client: BasicClient = BasicClient::new_naked()?;
332332
///let providers = client.list_providers()?;
333333
///// Set the second most prioritary provider
334334
///client.set_implicit_provider(providers[1].id);
@@ -1316,3 +1316,13 @@ impl BasicClient {
13161316
}
13171317
}
13181318
}
1319+
1320+
impl Default for BasicClient {
1321+
fn default() -> Self {
1322+
BasicClient {
1323+
op_client: Default::default(),
1324+
auth_data: Authentication::None,
1325+
implicit_provider: ProviderId::Core,
1326+
}
1327+
}
1328+
}

src/core/testing/core_tests.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,6 @@ fn get_operation_from_req_bytes(bytes: Vec<u8>) -> NativeOperation {
5656
.unwrap()
5757
}
5858

59-
#[test]
60-
fn ping_test() {
61-
let mut client: TestBasicClient = Default::default();
62-
client.set_mock_read(&get_response_bytes_from_result(NativeResult::Ping(
63-
operations::ping::Result {
64-
wire_protocol_version_maj: 1,
65-
wire_protocol_version_min: 0,
66-
},
67-
)));
68-
// Check request:
69-
// Ping request is empty so no checking to be done
70-
71-
// Check response:
72-
assert_eq!(client.ping().expect("Ping failed"), (1, 0));
73-
}
74-
7559
#[test]
7660
fn list_provider_test() {
7761
let mut client: TestBasicClient = Default::default();

tests/ci.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ if cargo clippy -h; then
2727
cargo clippy --all-targets -- -D clippy::all -D clippy::cargo
2828
fi
2929

30+
######################
31+
# Start Mock Service #
32+
######################
33+
CURRENT_PATH=$(pwd)
34+
cd parsec-mock-0.1.1
35+
python parsec_mock/parsec_mock.py --parsec-socket $CURRENT_PATH/parsec_mock.sock &
36+
while [[ ! -S $CURRENT_PATH/parsec_mock.sock ]]; do
37+
sleep 5
38+
done
39+
cd ..
40+
export PARSEC_SERVICE_ENDPOINT="unix://$CURRENT_PATH/parsec_mock.sock"
41+
3042
#############
3143
# Run tests #
3244
#############

tests/mock_service.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2021 Contributors to the Parsec project.
2+
// SPDX-License-Identifier: Apache-2.0
3+
use parsec_client::BasicClient;
4+
5+
#[test]
6+
fn ping_noauth() {
7+
let client = BasicClient::new_naked().unwrap();
8+
9+
// ping_noauth request
10+
assert_eq!(client.ping().expect("Ping failed"), (1, 0));
11+
}

0 commit comments

Comments
 (0)