aboutsummaryrefslogtreecommitdiffstats
path: root/sdc-distribution-client/src/test/java/org/onap/sdc/utils/TestConfigurationSSLProtocol.java
blob: 466bed94845cbf6d793eae580f822ac6a5c71be7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*-
 * ============LICENSE_START=======================================================
 * sdc-distribution-client
 * ================================================================================
 * Copyright (C) 2023 Nordix Foundation. All rights reserved.
 * ================================================================================
 * 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.
 * ============LICENSE_END=========================================================
 */

package org.onap.sdc.utils;

import java.util.ArrayList;
import java.util.List;

import lombok.Getter;
import lombok.Setter;
import org.onap.sdc.api.consumer.IConfiguration;

@Getter
@Setter
public class TestConfigurationSSLProtocol implements IConfiguration {

	private String user;
	private String password;
	private int httpProxyPort;
	private String sdcAddress;
	private String consumerID;
	private int httpsProxyPort;
	private String keyStorePath;
	private String httpProxyHost;
	private String consumerGroup;
	private String httpsProxyHost;
	private Boolean useSystemProxy;
	private String environmentName;
	private String keyStorePassword;
	private Boolean useHttpsWithSDC;
	private String sdcStatusTopicName;
	private boolean activateServerTLSAuth;
	private String sdcNotificationTopicName;
	private final String kafkaSaslMechanism;
	private boolean isFilterInEmptyResources;
	private final String kafkaSaslJaasConfig;
	private List<String> relevantArtifactTypes;
	private final int kafkaConsumerSessionTimeout;
	private final int kafkaConsumerMaxPollInterval;
	private final String kafkaSecurityProtocolConfig;
	private int pollingTimeout = DistributionClientConstants.POLLING_TIMEOUT_SEC;
	private int pollingInterval = DistributionClientConstants.MIN_POLLING_INTERVAL_SEC;

	public TestConfigurationSSLProtocol() {
		this.user = "mso-user";
		this.pollingTimeout = 20;
		this.httpProxyPort = 8080;
		this.pollingInterval = 20;
		this.password = "password";
		this.useHttpsWithSDC = true;
		this.httpProxyHost = "proxy";
		this.environmentName = "PROD";
		this.consumerID = "mso-123456";
		this.consumerGroup = "mso-group";
		this.activateServerTLSAuth = true;
		this.kafkaSaslMechanism = "PLAIN";
		this.sdcAddress = "localhost:8443";
		this.keyStorePassword = "Aa123456";
		this.isFilterInEmptyResources = false;
		this.kafkaConsumerSessionTimeout = 50;
		this.kafkaConsumerMaxPollInterval = 600;
		this.keyStorePath = "etc/sdc-client.jks";
		this.kafkaSecurityProtocolConfig = "SSL";
		this.setSdcStatusTopicName("SDC-STATUS-TOPIC");
		this.relevantArtifactTypes = new ArrayList<>();
		this.setSdcNotificationTopicName("SDC-NOTIF-TOPIC");
		this.relevantArtifactTypes.add(ArtifactTypeEnum.HEAT.name());
		this.kafkaSaslJaasConfig = "org.apache.kafka.common.security.scram.ScramLoginModule required username=admin password=admin-secret;";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((sdcAddress == null) ? 0 : sdcAddress.hashCode());
		result = prime * result + ((consumerID == null) ? 0 : consumerID.hashCode());
		result = prime * result + ((consumerGroup == null) ? 0 : consumerGroup.hashCode());
		result = prime * result + ((environmentName == null) ? 0 : environmentName.hashCode());
		result = prime * result + ((password == null) ? 0 : password.hashCode());
		result = prime * result + pollingInterval;
		result = prime * result + pollingTimeout;
		result = prime * result + ((relevantArtifactTypes == null) ? 0 : relevantArtifactTypes.hashCode());
		result = prime * result + ((user == null) ? 0 : user.hashCode());
		return result;
	}

	@Override
	public boolean activateServerTLSAuth() {

		return activateServerTLSAuth;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		TestConfigurationSSLProtocol other = (TestConfigurationSSLProtocol) obj;
		if (sdcAddress == null) {
			if (other.sdcAddress != null)
				return false;
		} else if (!sdcAddress.equals(other.sdcAddress))
			return false;
		if (consumerID == null) {
			if (other.consumerID != null)
				return false;
		} else if (!consumerID.equals(other.consumerID))
			return false;
		if (consumerGroup == null) {
			if (other.consumerGroup != null)
				return false;
		} else if (!consumerGroup.equals(other.consumerGroup))
			return false;
		if (environmentName == null) {
			if (other.environmentName != null)
				return false;
		} else if (!environmentName.equals(other.environmentName))
			return false;
		if (password == null) {
			if (other.password != null)
				return false;
		} else if (!password.equals(other.password))
			return false;
		if (pollingInterval != other.pollingInterval)
			return false;
		if (pollingTimeout != other.pollingTimeout)
			return false;
		if (relevantArtifactTypes == null) {
			if (other.relevantArtifactTypes != null)
				return false;
		} else if (!relevantArtifactTypes.equals(other.relevantArtifactTypes))
			return false;
		if (user == null) {
			if (other.user != null)
				return false;
		} else if (!user.equals(other.user))
			return false;
		if (keyStorePath == null) {
			if (other.keyStorePath != null)
				return false;
		} else if (!keyStorePath.equals(other.keyStorePath))
			return false;
		if (keyStorePassword == null) {
			return other.keyStorePassword == null;
		} else
			return keyStorePassword.equals(other.keyStorePassword);
	}

	@Override
	public String toString() {
		return "TestConfiguration [sdcAddress=" + sdcAddress + ", user=" + user + ", password=" + password
				+ ", pollingInterval=" + pollingInterval + ", pollingTimeout=" + pollingTimeout
				+ ", relevantArtifactTypes=" + relevantArtifactTypes + ", consumerGroup=" + consumerGroup
				+ ", environmentName=" + environmentName + ", consumerID=" + consumerID + "]";
	}
}