Skip to content

Commit

Permalink
Fix repeating same key variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuvindu committed Oct 13, 2023
1 parent 181d7f5 commit 35a7188
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 229 deletions.
24 changes: 24 additions & 0 deletions ballerina/modules/wssec/tests/test_utils.bal
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// specific language governing permissions and limitations
// under the License.
import ballerina/test;
import ballerina/crypto;

const USERNAME = "username";
const PASSWORD = "password";
Expand All @@ -29,6 +30,29 @@ const X509_PUBLIC_CERT_PATH_2 = "modules/wssec/tests/resources/x509_certificate_
const X509_KEY_STORE_PATH = "modules/wssec/tests/resources/x509_certificate.p12";
const X509_KEY_STORE_PATH_2 = "modules/wssec/tests/resources/x509_certificate_2.p12";

const crypto:KeyStore clientKeyStore = {
path: X509_KEY_STORE_PATH_2,
password: KEY_PASSWORD
};
crypto:PrivateKey clientPrivateKey = check crypto:decodeRsaPrivateKeyFromKeyStore(clientKeyStore, KEY_ALIAS,
KEY_PASSWORD);
crypto:PublicKey clientPublicKey = check crypto:decodeRsaPublicKeyFromTrustStore(clientKeyStore, KEY_ALIAS);

const crypto:KeyStore serverKeyStore = {
path: X509_KEY_STORE_PATH,
password: KEY_PASSWORD
};
crypto:PrivateKey serverPrivateKey = check crypto:decodeRsaPrivateKeyFromKeyStore(serverKeyStore, KEY_ALIAS,
KEY_PASSWORD);
crypto:PublicKey serverPublicKey = check crypto:decodeRsaPublicKeyFromTrustStore(serverKeyStore, KEY_ALIAS);

crypto:KeyStore keyStore = {
path: KEY_STORE_PATH,
password: KEY_PASSWORD
};
crypto:PrivateKey symmetricKey = check crypto:decodeRsaPrivateKeyFromKeyStore(keyStore, KEY_ALIAS, KEY_PASSWORD);
crypto:PublicKey publicKey = check crypto:decodeRsaPublicKeyFromTrustStore(keyStore, KEY_ALIAS);

function assertTimestampToken(string envelopeString) {
string:RegExp ts_token = re `<wsu:Timestamp wsu:Id=".*">`;
string:RegExp created = re `<wsu:Created>.*</wsu:Created>`;
Expand Down
Loading

0 comments on commit 35a7188

Please sign in to comment.