-
Notifications
You must be signed in to change notification settings - Fork 37
feat(ov_api): add and delete ownership voucher in onboarding server #299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0c03c6c
feat(ov_api): working model
say-paul 047a734
test(new): test added for add and delete ovs
say-paul 6d38b02
fix(test): test cases for ov_managemnt
say-paul eea4d95
fix(ucase): removed ucase from content-type
say-paul b6f38e7
feat(ov-mgnt):update ov to onboarding server
say-paul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,79 @@ | ||
mod common; | ||
use anyhow::{bail, Context, Result}; | ||
use common::{Binary, TestContext}; | ||
|
||
#[tokio::test] | ||
async fn test_ov_management() -> Result<()> { | ||
let mut ctx = TestContext::new().context("Error building test context")?; | ||
// start server | ||
let owner_onboarding_server = ctx | ||
.start_test_server( | ||
Binary::OwnerOnboardingServer, | ||
|cfg| { | ||
Ok(cfg.prepare_config_file(None, |cfg| { | ||
cfg.insert("serviceinfo_api_server_port", &8083); | ||
Ok(()) | ||
})?) | ||
}, | ||
|_| Ok(()), | ||
) | ||
.context("Error creating owner server")?; | ||
ctx.wait_until_servers_ready() | ||
.await | ||
.context("Error waiting for servers to start")?; | ||
|
||
//sending request | ||
let client = reqwest::Client::new(); | ||
|
||
let add_ov = client | ||
.post(format!( | ||
"http://localhost:{}/management/v1/ownership_voucher", //DevSkim: ignore DS137138 | ||
owner_onboarding_server.server_port().unwrap() | ||
)) | ||
.header("Authorization", "Bearer TestAdminToken") | ||
.header("X-Number-Of-Vouchers", "1") | ||
.header("content-type", "application/x-pem-file") | ||
.body("THIS IS A INVALID BODY") | ||
.send() | ||
.await?; | ||
let mut failed = Vec::new(); | ||
if add_ov.status() != 400 { | ||
failed.push(TestCase { | ||
action: "Add OV", | ||
error: format!("expected 400 got {}", add_ov.status()), | ||
}) | ||
} | ||
|
||
let ov_list: [&str; 1] = ["89cb17fd-95e7-4de8-a36a-686926a7f88f"]; | ||
let delete_ov = client | ||
.post(format!( | ||
"http://localhost:{}/management/v1/ownership_voucher/delete", | ||
owner_onboarding_server.server_port().unwrap() | ||
)) | ||
.json(&ov_list) | ||
.send() | ||
.await?; | ||
if delete_ov.status() != 400 { | ||
failed.push(TestCase { | ||
action: "Delete OV", | ||
error: format!("expected 400 got {}", delete_ov.status()), | ||
}) | ||
} | ||
|
||
if failed.is_empty() { | ||
Ok(()) | ||
} else { | ||
for failed_case in failed { | ||
eprintln!("Failed test: {:?}", failed_case); | ||
} | ||
bail!("Some tests failed"); | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
struct TestCase { | ||
#[allow(dead_code)] | ||
action: &'static str, | ||
#[allow(dead_code)] | ||
error: String, | ||
} |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / devskim
Insecure URL