Skip to content

Commit cecd603

Browse files
committed
dev_admin_creds
1 parent 841d622 commit cecd603

2 files changed

Lines changed: 30 additions & 9 deletions

File tree

tasks/test_api/src/parser/oci.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,26 @@ pub struct TaskOci {
5858
}
5959

6060
impl TaskOci {
61-
/// Create a `TaskOci` configured for smoke tests with the given API URL
61+
/// Create a `TaskOci` configured for smoke tests with the given API URL and default credentials
6262
pub fn for_test(api_url: &str, admin: bool) -> Self {
6363
let (username, password) = if admin {
64-
(TEST_ADMIN_USERNAME, TEST_ADMIN_API_TOKEN)
64+
(
65+
TEST_ADMIN_USERNAME.to_owned(),
66+
TEST_ADMIN_API_TOKEN.to_owned(),
67+
)
6568
} else {
66-
(TEST_USERNAME, TEST_API_TOKEN)
69+
(TEST_USERNAME.to_owned(), TEST_API_TOKEN.to_owned())
6770
};
71+
Self::for_test_with_credentials(api_url, admin, username, password)
72+
}
73+
74+
/// Create a `TaskOci` configured for smoke tests with custom credentials
75+
pub fn for_test_with_credentials(
76+
api_url: &str,
77+
admin: bool,
78+
username: String,
79+
password: String,
80+
) -> Self {
6881
Self {
6982
api_url: api_url.to_owned(),
7083
namespace: "namespace".to_owned(),
@@ -75,8 +88,8 @@ impl TaskOci {
7588
output_dir: "./oci-conformance-results".to_owned(),
7689
spec_dir: "./distribution-spec".to_owned(),
7790
admin,
78-
username: username.to_owned(),
79-
password: password.to_owned(),
91+
username,
92+
password,
8093
}
8194
}
8295
}

tasks/test_api/src/task/test/smoke_test.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ use bencher_json::{
1313

1414
use crate::{
1515
API_VERSION,
16-
parser::{TaskExamples, TaskOci, TaskSeedTest, TaskSmokeTest, TaskTestEnvironment},
16+
parser::{
17+
TEST_ADMIN_USERNAME, TaskExamples, TaskOci, TaskSeedTest, TaskSmokeTest,
18+
TaskTestEnvironment,
19+
},
1720
task::{
1821
oci::Oci,
1922
test::{examples::Examples, seed_test::SeedTest},
@@ -196,14 +199,19 @@ fn test(api_url: &Url, mock_setup: MockSetup) -> anyhow::Result<()> {
196199
MockSetup::BencherCloud { admin_token, token } => {
197200
let task = TaskSeedTest {
198201
url: Some(api_url.clone()),
199-
admin_token: Some(admin_token),
202+
admin_token: Some(admin_token.clone()),
200203
token: Some(token),
201204
is_bencher_cloud: true,
202205
};
203206
SeedTest::try_from(task)?.exec()?;
204207

205-
// Run OCI conformance tests
206-
let oci = Oci::try_from(TaskOci::for_test(api_url.as_ref(), true))?;
208+
// Run OCI conformance tests with Bencher Cloud dev credentials
209+
let oci = Oci::try_from(TaskOci::for_test_with_credentials(
210+
api_url.as_ref(),
211+
false,
212+
TEST_ADMIN_USERNAME.to_owned(),
213+
admin_token.to_string(),
214+
))?;
207215
oci.exec()?;
208216

209217
Ok(())

0 commit comments

Comments
 (0)