Skip to content

Commit c649687

Browse files
authored
Introduce integration_test_credentials crate to make credentials reusable (#993)
1 parent 06885a8 commit c649687

File tree

10 files changed

+83
-67
lines changed

10 files changed

+83
-67
lines changed

Cargo.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[workspace]
22
members = [
3+
"integration_test_credentials",
34
"wp_api",
45
"wp_api_integration_tests",
56
"wp_api_integration_tests_backend",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "integration_test_credentials"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[build-dependencies]
7+
serde_json = { workspace = true }
File renamed without changes.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// A `TestCredentials::instance()` function will be generated by this
2+
include!(concat!(env!("OUT_DIR"), "/generated_test_credentials.rs"));
3+
4+
#[derive(Debug, Default)]
5+
pub struct TestCredentials {
6+
pub site_url: &'static str,
7+
pub admin_username: &'static str,
8+
pub admin_password: &'static str,
9+
pub admin_password_uuid: &'static str,
10+
pub subscriber_username: &'static str,
11+
pub subscriber_password: &'static str,
12+
pub subscriber_password_uuid: &'static str,
13+
pub author_username: &'static str,
14+
pub author_password: &'static str,
15+
pub password_protected_post_id: i64,
16+
pub password_protected_post_password: &'static str,
17+
pub password_protected_post_title: &'static str,
18+
pub password_protected_comment_id: i64,
19+
pub password_protected_comment_author: &'static str,
20+
pub trashed_post_id: i64,
21+
pub first_post_date_gmt: &'static str,
22+
pub wordpress_core_version: &'static str,
23+
pub integration_test_custom_template_id: &'static str,
24+
pub revisioned_post_id: i64,
25+
pub revision_id_for_revisioned_post_id: i64,
26+
pub autosaved_post_id: i64,
27+
pub autosave_id_for_autosaved_post_id: i64,
28+
pub password_protected_page_id: i64,
29+
pub password_protected_page_password: &'static str,
30+
pub password_protected_page_title: &'static str,
31+
pub trashed_page_id: i64,
32+
pub first_page_id: i64,
33+
pub revisioned_page_id: i64,
34+
pub revision_id_for_revisioned_page_id: i64,
35+
pub autosaved_page_id: i64,
36+
pub autosave_id_for_autosaved_page_id: i64,
37+
pub primary_menu_location: &'static str,
38+
pub footer_menu_location: &'static str,
39+
pub nav_menu_item_id: i64,
40+
pub autosave_id_for_nav_menu_item_id: i64,
41+
pub navigation_id: i64,
42+
pub revision_id_for_navigation_id: i64,
43+
pub autosaved_navigation_id: i64,
44+
pub autosave_id_for_autosaved_navigation_id: i64,
45+
}
46+
47+
impl TestCredentials {
48+
pub fn date_format() -> &'static str {
49+
"%Y-%m-%d %H:%M:%S"
50+
}
51+
}
52+
53+
#[derive(Debug, Default)]
54+
pub struct WpComTestCredentials {
55+
pub bearer_token: &'static str,
56+
pub site_id: u64,
57+
pub wp_com_subscriber_user_id: i64,
58+
pub email_subscriber_subscription_id: u64,
59+
pub comment_id: i64,
60+
}

wp_api_integration_tests/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ async-trait = { workspace = true }
1313
clap = { workspace = true, features = ["derive"] }
1414
futures = { workspace = true }
1515
http = { workspace = true }
16+
integration_test_credentials = { path = "../integration_test_credentials" }
1617
reqwest = { workspace = true, features = [ "multipart", "json", "stream", "gzip", "brotli", "zstd", "deflate" ] }
1718
rstest = { workspace = true }
1819
rstest_reuse = { workspace = true }

wp_api_integration_tests/src/lib.rs

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -7,67 +7,6 @@ use wp_api::{
77
pub mod mock;
88
pub mod prelude;
99

10-
// A `TestCredentials::instance()` function will be generated by this
11-
include!(concat!(env!("OUT_DIR"), "/generated_test_credentials.rs"));
12-
13-
#[derive(Debug, Default)]
14-
pub struct TestCredentials {
15-
pub site_url: &'static str,
16-
pub admin_username: &'static str,
17-
pub admin_password: &'static str,
18-
pub admin_password_uuid: &'static str,
19-
pub subscriber_username: &'static str,
20-
pub subscriber_password: &'static str,
21-
pub subscriber_password_uuid: &'static str,
22-
pub author_username: &'static str,
23-
pub author_password: &'static str,
24-
pub password_protected_post_id: i64,
25-
pub password_protected_post_password: &'static str,
26-
pub password_protected_post_title: &'static str,
27-
pub password_protected_comment_id: i64,
28-
pub password_protected_comment_author: &'static str,
29-
pub trashed_post_id: i64,
30-
pub first_post_date_gmt: &'static str,
31-
pub wordpress_core_version: &'static str,
32-
pub integration_test_custom_template_id: &'static str,
33-
pub revisioned_post_id: i64,
34-
pub revision_id_for_revisioned_post_id: i64,
35-
pub autosaved_post_id: i64,
36-
pub autosave_id_for_autosaved_post_id: i64,
37-
pub password_protected_page_id: i64,
38-
pub password_protected_page_password: &'static str,
39-
pub password_protected_page_title: &'static str,
40-
pub trashed_page_id: i64,
41-
pub first_page_id: i64,
42-
pub revisioned_page_id: i64,
43-
pub revision_id_for_revisioned_page_id: i64,
44-
pub autosaved_page_id: i64,
45-
pub autosave_id_for_autosaved_page_id: i64,
46-
pub primary_menu_location: &'static str,
47-
pub footer_menu_location: &'static str,
48-
pub nav_menu_item_id: i64,
49-
pub autosave_id_for_nav_menu_item_id: i64,
50-
pub navigation_id: i64,
51-
pub revision_id_for_navigation_id: i64,
52-
pub autosaved_navigation_id: i64,
53-
pub autosave_id_for_autosaved_navigation_id: i64,
54-
}
55-
56-
impl TestCredentials {
57-
pub fn date_format() -> &'static str {
58-
"%Y-%m-%d %H:%M:%S"
59-
}
60-
}
61-
62-
#[derive(Debug, Default)]
63-
pub struct WpComTestCredentials {
64-
pub bearer_token: &'static str,
65-
pub site_id: u64,
66-
pub wp_com_subscriber_user_id: i64,
67-
pub email_subscriber_subscription_id: u64,
68-
pub comment_id: i64,
69-
}
70-
7110
pub mod backend;
7211

7312
// The first user is also the current user

wp_api_integration_tests/src/prelude.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ pub use crate::{
66
POST_ID_555, POST_ID_DRAFT, POST_ID_INVALID, POST_ID_NAV_MENUS_PARAM,
77
POST_TEMPLATE_SINGLE_WITH_SIDEBAR, SECOND_COMMENT_ID, SECOND_USER_EMAIL, SECOND_USER_ID,
88
SECOND_USER_SLUG, TAG_ID_100, TEMPLATE_TWENTY_TWENTY_FOUR_SINGLE, TERM_ID_INVALID,
9-
THEME_TWENTY_TWENTY_FIVE, THEME_TWENTY_TWENTY_FOUR, THEME_TWENTY_TWENTY_THREE, TestCredentials,
10-
USER_ID_INVALID, WP_ORG_PLUGIN_SLUG_CLASSIC_WIDGETS, api_client, api_client_as_author,
11-
api_client_as_subscriber, api_client_with_auth_provider,
9+
THEME_TWENTY_TWENTY_FIVE, THEME_TWENTY_TWENTY_FOUR, THEME_TWENTY_TWENTY_THREE, USER_ID_INVALID,
10+
WP_ORG_PLUGIN_SLUG_CLASSIC_WIDGETS, api_client, api_client_as_author, api_client_as_subscriber,
11+
api_client_with_auth_provider,
1212
backend::{Backend, RestoreServer},
1313
mock::{MockExecutor, response_helpers},
1414
test_site_api_url_resolver, test_site_url, unwrapped_wp_gmt_date_time,
1515
};
1616
pub use async_trait::async_trait;
1717
pub use http::{HeaderMap, HeaderValue};
18+
pub use integration_test_credentials::{TestCredentials, WpComTestCredentials};
1819
pub use rstest::*;
1920
pub use rstest_reuse::{self, apply, template};
2021
pub use serial_test::{parallel, serial};

wp_api_integration_tests/tests/test_wp_com_comments_immut.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use wp_api::{
22
comments::{CommentId, CommentRetrieveParams},
33
wp_com::endpoint::extensions::comments::WpComCommentExtensionProvider,
44
};
5-
6-
use wp_api_integration_tests::{WpComTestCredentials, api_client_backed_by_wp_com, prelude::*};
5+
use wp_api_integration_tests::{api_client_backed_by_wp_com, prelude::*};
76

87
#[tokio::test]
98
#[parallel]

wp_api_integration_tests/tests/test_wp_com_subscribers_immut.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use wp_api::wp_com::{
55
ListSubscribersSortField, SubscribersListParams, SubscriptionId,
66
},
77
};
8-
use wp_api_integration_tests::{WpComTestCredentials, prelude::*, wp_com_client};
8+
use wp_api_integration_tests::{prelude::*, wp_com_client};
99

1010
#[tokio::test]
1111
#[apply(list_cases)]

0 commit comments

Comments
 (0)