adding aws credentials
This commit is contained in:
1 parent
31edd55b0a
commit
39b3f74068
5 files changed
+335
-53
No files matched your search
+78
@@ -261,6 +261,7 @@ mod tests {
|
||||
let cred = AwsCredential {
|
||||
access_key_id: "AKIAEXAMPLE".into(),
|
||||
secret_access_key: "EXAMPLESECRET".into(),
|
||||
is_default: false,
|
||||
};
|
||||
env.db().unwrap().save_aws_credential("work", &cred).unwrap();
|
||||
let window = open_app(&env, cx);
|
||||
@@ -276,4 +277,81 @@ mod tests {
|
||||
act(window, cx, |window, cx| window.within("credential-tabs").click(0usize, cx));
|
||||
assert!(is_visible(window, "work", cx));
|
||||
}
|
||||
|
||||
#[gpui_kit::test]
|
||||
fn test_add_aws_credential(cx: &mut TestAppContext) {
|
||||
let env = TestEnv::new().unwrap();
|
||||
env.db().unwrap();
|
||||
let window = open_app(&env, cx);
|
||||
fill(window, "passphrase", TEST_PASSPHRASE, cx);
|
||||
click(window, "submit", cx);
|
||||
click(window, "credentials", cx);
|
||||
|
||||
click(window, "aws-add", cx);
|
||||
fill(window, "aws-name", "work", cx);
|
||||
fill(window, "aws-key-id", "AKIAEXAMPLE", cx);
|
||||
fill(window, "aws-secret", "EXAMPLESECRET", cx);
|
||||
click(window, "aws-default", cx);
|
||||
click(window, "aws-save", cx);
|
||||
|
||||
assert_eq!(error_message(window, cx), None);
|
||||
assert!(is_visible(window, "work", cx));
|
||||
assert!(!is_visible(window, "aws-save", cx));
|
||||
|
||||
let saved = cx.read(|cx| {
|
||||
let AppSession::Unlocked(db) = cx.global::<AppSession>() else { panic!("locked") };
|
||||
db.load_aws_credential("work").unwrap()
|
||||
});
|
||||
assert_eq!(saved.access_key_id, "AKIAEXAMPLE");
|
||||
assert_eq!(saved.secret_access_key, "EXAMPLESECRET");
|
||||
assert!(saved.is_default);
|
||||
}
|
||||
|
||||
#[gpui_kit::test]
|
||||
fn test_add_aws_credential_missing_fields(cx: &mut TestAppContext) {
|
||||
let env = TestEnv::new().unwrap();
|
||||
env.db().unwrap();
|
||||
let window = open_app(&env, cx);
|
||||
fill(window, "passphrase", TEST_PASSPHRASE, cx);
|
||||
click(window, "submit", cx);
|
||||
click(window, "credentials", cx);
|
||||
|
||||
click(window, "aws-add", cx);
|
||||
fill(window, "aws-name", "work", cx);
|
||||
click(window, "aws-save", cx);
|
||||
|
||||
assert_eq!(error_message(window, cx).as_deref(), Some("All fields are required."));
|
||||
assert!(!is_visible(window, "work", cx));
|
||||
}
|
||||
|
||||
#[gpui_kit::test]
|
||||
fn test_add_aws_credential_duplicate_name(cx: &mut TestAppContext) {
|
||||
let env = TestEnv::new().unwrap();
|
||||
let cred = AwsCredential {
|
||||
access_key_id: "AKIAEXAMPLE".into(),
|
||||
secret_access_key: "EXAMPLESECRET".into(),
|
||||
is_default: false,
|
||||
};
|
||||
env.db().unwrap().save_aws_credential("work", &cred).unwrap();
|
||||
let window = open_app(&env, cx);
|
||||
fill(window, "passphrase", TEST_PASSPHRASE, cx);
|
||||
click(window, "submit", cx);
|
||||
click(window, "credentials", cx);
|
||||
|
||||
click(window, "aws-add", cx);
|
||||
fill(window, "aws-name", "work", cx);
|
||||
fill(window, "aws-key-id", "AKIAOTHER", cx);
|
||||
fill(window, "aws-secret", "OTHERSECRET", cx);
|
||||
click(window, "aws-save", cx);
|
||||
|
||||
assert_eq!(
|
||||
error_message(window, cx).as_deref(),
|
||||
Some("An AWS credential named \"work\" already exists."),
|
||||
);
|
||||
let saved = cx.read(|cx| {
|
||||
let AppSession::Unlocked(db) = cx.global::<AppSession>() else { panic!("locked") };
|
||||
db.load_aws_credential("work").unwrap()
|
||||
});
|
||||
assert_eq!(saved.access_key_id, "AKIAEXAMPLE");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user