com.huawei.openstack4j.api.loadbalance.ELBCertV1Tests Maven / Gradle / Ivy
The newest version!
/*******************************************************************************
* Copyright 2017 HuaWei Tld
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*******************************************************************************/
package com.huawei.openstack4j.api.loadbalance;
import static org.testng.Assert.assertTrue;
import java.io.IOException;
import org.testng.annotations.Test;
import com.huawei.openstack4j.api.AbstractTest;
import com.huawei.openstack4j.model.common.ActionResponse;
import com.huawei.openstack4j.model.loadbalance.Certificate;
import com.huawei.openstack4j.openstack.loadbalance.domain.ELBCertificate;
import com.huawei.openstack4j.openstack.loadbalance.domain.ELBCertificateUpdate;
import com.huawei.openstack4j.openstack.loadbalance.domain.ELBCertificate.Certificates;
@Test(suiteName = "ELBLoadBalancer/CertV1")
public class ELBCertV1Tests extends AbstractTest {
private static final String JSON_CERT_CREATE = "/loadbalance/elb_cert_create.json";
private static final String JSON_CERTS = "/loadbalance/elb_certs.json";
private static final String JSON_CERT_UPDATE = "/loadbalance/elb_cert_update.json";
public void testCreateCert() throws IOException {
respondWith(JSON_CERT_CREATE);
Certificate cert = ELBCertificate.builder().name("SDK-test-cert").description("desc")
.certificate(
"-----BEGIN CERTIFICATE-----\nMIIDXTCCAkWgAwIBAgIJANoPUy2NktS6MA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV\nBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX\naWRnaXRzIFB0eSBMdGQwHhcNMTYwNjIyMDMyOTU5WhcNMTkwNjIyMDMyOTU5WjBF\nMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEh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vAKAxPVXTbWDFLzWygYiWRQNy9fxrB\n9F7lYYqtY5VagdVHhnYUZOvtoFoeZFA6ZeAph9elGCtM3Lq3PD2i/mmncsQibTUn\nHSiKDWzuk8UtWIjEpHze5BkCgYEAifD9eG+bzqTnn1qU2pIl2nQTLXj0r97v84Tu\niqF4zAT5DYMtFeGBBI1qLJxVh7342CH2CI4ZhxmJ+L68sAcQH8rDcnGui1DBPlIv\nDl3kW3280bJfW1lUvPRh8NfZ9dsO1HF1n75nveVwg/OWyR7zmWIRPPRrqAeua45H\nox5z/CECgYBqwlEBjue8oOkVVu/lKi6fo6jr+0u25K9dp9azHYwE0KNHX0MwRALw\nWbPgcjge23sfhbeqVvHo0JYBdRsk/OBuW73/9Sb5E+6auDoubCjC0cAIvs23MPju\nsMvKak4mQkI19foRXBydB/DDkK26iei/l0xoygrw50v2HErsQ7JcHw==\n-----END RSA PRIVATE KEY-----")
.build();
Certificate create = osv3().loadBalancer().certs().create(cert);
assertTrue("60884e005ce546b1b580bf259cd37016".equals(create.getId()));
}
public void testDeleteCert() {
respondWith(204);
String certificateId = "60884e005ce546b1b580bf259cd37016";
ActionResponse resp = osv3().loadBalancer().certs().delete(certificateId);
assertTrue(resp.isSuccess(), resp.getFault());
}
public void testUpdateCert() throws IOException {
respondWith(JSON_CERTS);
respondWith(JSON_CERT_UPDATE);
Certificates certs = osv3().loadBalancer().certs().list();
assertTrue(certs != null && Integer.valueOf(certs.getInstanceNum()) == 1, "No cert for update");
Certificate cert = certs.getCertificates().get(0);
String after = new StringBuilder(cert.getDescription()).reverse().toString();
ELBCertificateUpdate update = ELBCertificateUpdate.fromCertificate(cert).toBuilder().description(after).build();
Certificate afterUpdate = osv3().loadBalancer().certs().update(cert.getId(), update);
assertTrue(after.equals(afterUpdate.getDescription()));
}
@Override
protected Service service() {
return Service.LOAD_BALANCER;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy