aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2011-09-11 18:39:27 +0200
committersimonbrandhof <simon.brandhof@gmail.com>2011-09-11 18:39:27 +0200
commit0d57ce7853c35d7b6c502bd4b1c3284dafc41371 (patch)
tree049eba39c22f35a6deb5e9eca06dacc980ae3ca2
parent77b9a13434344be895a495fcf0eabe77edf10baf (diff)
downloadsonarqube-0d57ce7853c35d7b6c502bd4b1c3284dafc41371.tar.gz
sonarqube-0d57ce7853c35d7b6c502bd4b1c3284dafc41371.zip
SONAR-2603 provide a dedicated page to generate server id
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties15
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/ServerMetadata.java4
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java6
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/platform/Server.java2
-rw-r--r--sonar-server/src/main/java/org/sonar/server/platform/Platform.java2
-rw-r--r--sonar-server/src/main/java/org/sonar/server/platform/ServerIdGenerator.java (renamed from sonar-server/src/main/java/org/sonar/server/platform/ServerKeyGenerator.java)26
-rw-r--r--sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java6
-rw-r--r--sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java11
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/server_id_configuration_controller.rb (renamed from sonar-server/src/main/webapp/WEB-INF/app/controllers/server_key_configuration_controller.rb)37
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/server_id_configuration/index.html.erb60
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/server_key_configuration/index.html.erb58
-rw-r--r--sonar-server/src/test/java/org/sonar/server/platform/ServerIdGeneratorTest.java (renamed from sonar-server/src/test/java/org/sonar/server/platform/ServerKeyGeneratorTest.java)34
-rw-r--r--sonar-server/src/test/java/org/sonar/server/platform/ServerImplTest.java8
-rw-r--r--sonar-server/src/test/java/org/sonar/server/platform/ServerLifecycleNotifierTest.java2
-rw-r--r--sonar-server/src/test/java/org/sonar/server/startup/ServerMetadataPersisterTest.java2
-rw-r--r--sonar-server/src/test/resources/org/sonar/server/platform/ServerImplTest/shouldLoadServerIdFromDatabase.xml (renamed from sonar-server/src/test/resources/org/sonar/server/platform/ServerImplTest/shouldLoadServerKeyFromDatabase.xml)2
17 files changed, 144 insertions, 133 deletions
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
index 3d9927c5a69..148bcf9b14c 100644
--- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
+++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
@@ -434,7 +434,7 @@ property.category.differentialViews=Differential Views
property.category.codeCoverage=Code Coverage
property.category.duplications=Duplications
property.category.localization=Localization
-property.category.server_key=Server Key
+property.category.server_id=Server ID
#------------------------------------------------------------------------------
@@ -766,9 +766,16 @@ email_configuration.test.email_was_sent_to_x=Email was sent to {0}
# SERVER KEY CONFIGURATION
#
#------------------------------------------------------------------------------
-server_key_configuration.page=Server Key
-server_key_configuration.generate_button=Generate Key
-server_key_configuration.generating_button=Generating Key...
+server_id_configuration.page=Server ID
+server_id_configuration.generate_button=Generate ID
+server_id_configuration.generating_button=Generating ID...
+server_id_configuration.bad_key=The ID is not valid anymore. Please check the organisation and the IP address.
+server_id_configuration.information=The Server ID is a unique identifier of this Sonar instance. It is used for example to obtain a license key for the SonarSource's commercial plugins. Two fields have to be provided to generate the ID : organisation name and one of the IP addresses of the machine that hosts this server.
+server_id_configuration.organisation.title=Organisation
+server_id_configuration.organisation.desc=Name of the organisation
+server_id_configuration.ip.title=Fixed IP Address
+server_id_configuration.ip.desc=A server ID is linked to the IP address of the hosting machine that runs Sonar. If the server IP address was to changed, the server ID will have to be regenerated. The valid addresses are :
+server_id_configuration.generation_error=Organisation and/or IP address are not valid.
#------------------------------------------------------------------------------
diff --git a/sonar-batch/src/main/java/org/sonar/batch/ServerMetadata.java b/sonar-batch/src/main/java/org/sonar/batch/ServerMetadata.java
index 6415c9e01e1..97dae9df62f 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/ServerMetadata.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/ServerMetadata.java
@@ -63,7 +63,7 @@ public class ServerMetadata extends Server {
}
@Override
- public String getKey() {
- return conf.getString(CoreProperties.SERVER_KEY);
+ public String getPermanentServerId() {
+ return conf.getString(CoreProperties.PERMANENT_SERVER_ID);
}
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
index df3a8584548..958e01870d3 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
@@ -240,15 +240,15 @@ public interface CoreProperties {
/**
* @since 2.11
*/
- String ORGANIZATION = "sonar.organization";
+ String ORGANISATION = "sonar.organisation";
/**
* @since 2.11
*/
- String SERVER_KEY = "sonar.server_key";
+ String PERMANENT_SERVER_ID = "sonar.server_id";
/**
* @since 2.11
*/
- String SERVER_KEY_IP_ADDRESS = "sonar.server_key.ip_address";
+ String SERVER_ID_IP_ADDRESS = "sonar.server_id.ip_address";
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/platform/Server.java b/sonar-plugin-api/src/main/java/org/sonar/api/platform/Server.java
index f5043073dbb..195671febe5 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/platform/Server.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/platform/Server.java
@@ -44,5 +44,5 @@ public abstract class Server implements BatchComponent, ServerComponent {
/**
* @since 2.10
*/
- public abstract String getKey();
+ public abstract String getPermanentServerId();
}
diff --git a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java
index 7eb85ce851a..c733a991588 100644
--- a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java
+++ b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java
@@ -144,7 +144,7 @@ public final class Platform {
coreContainer.as(Characteristics.CACHE).addComponent(UpdateCenterClient.class);
coreContainer.as(Characteristics.CACHE).addComponent(UpdateCenterMatrixFactory.class);
coreContainer.as(Characteristics.CACHE).addComponent(PluginDownloader.class);
- coreContainer.as(Characteristics.CACHE).addComponent(ServerKeyGenerator.class);
+ coreContainer.as(Characteristics.CACHE).addComponent(ServerIdGenerator.class);
coreContainer.as(Characteristics.CACHE).addComponent(ServerImpl.class);
coreContainer.as(Characteristics.NO_CACHE).addComponent(FilterExecutor.class);
coreContainer.as(Characteristics.NO_CACHE).addAdapter(new DatabaseSessionProvider());
diff --git a/sonar-server/src/main/java/org/sonar/server/platform/ServerKeyGenerator.java b/sonar-server/src/main/java/org/sonar/server/platform/ServerIdGenerator.java
index 0a29e0eb876..3577effe7e6 100644
--- a/sonar-server/src/main/java/org/sonar/server/platform/ServerKeyGenerator.java
+++ b/sonar-server/src/main/java/org/sonar/server/platform/ServerIdGenerator.java
@@ -35,7 +35,7 @@ import java.util.List;
/**
* @since 2.11
*/
-public class ServerKeyGenerator {
+public class ServerIdGenerator {
/**
* Increment this version each time the algorithm is changed. Do not exceed 9.
@@ -46,23 +46,23 @@ public class ServerKeyGenerator {
private final boolean acceptPrivateAddress;
- public ServerKeyGenerator() {
+ public ServerIdGenerator() {
this(false);
}
- ServerKeyGenerator(boolean acceptPrivateAddress) {
+ ServerIdGenerator(boolean acceptPrivateAddress) {
this.acceptPrivateAddress = acceptPrivateAddress;
}
- public String generate(String organization, String ipAddress) {
- String key = null;
- if (StringUtils.isNotBlank(organization) && StringUtils.isNotBlank(ipAddress)) {
+ public String generate(String organisation, String ipAddress) {
+ String id = null;
+ if (StringUtils.isNotBlank(organisation) && StringUtils.isNotBlank(ipAddress)) {
InetAddress inetAddress = toValidAddress(ipAddress);
if (inetAddress != null) {
- key = toKey(organization, inetAddress);
+ id = toId(organisation, inetAddress);
}
}
- return key;
+ return id;
}
boolean isFixed(InetAddress address) {
@@ -72,13 +72,13 @@ public class ServerKeyGenerator {
return acceptPrivateAddress || (!address.isLoopbackAddress() && !address.isLinkLocalAddress());
}
- String toKey(String organization, InetAddress address) {
- String key = new StringBuilder().append(organization).append("-").append(address.getHostAddress()).toString();
+ String toId(String organisation, InetAddress address) {
+ String id = new StringBuilder().append(organisation).append("-").append(address.getHostAddress()).toString();
try {
- return VERSION + DigestUtils.shaHex(key.getBytes("UTF-8")).substring(0, CHECKSUM_SIZE);
+ return VERSION + DigestUtils.shaHex(id.getBytes("UTF-8")).substring(0, CHECKSUM_SIZE);
} catch (UnsupportedEncodingException e) {
- throw new IllegalArgumentException("Organization is not UTF-8 encoded: " + organization, e);
+ throw new IllegalArgumentException("Organisation is not UTF-8 encoded: " + organisation, e);
}
}
@@ -112,7 +112,7 @@ public class ServerKeyGenerator {
}
}
} catch (SocketException e) {
- LoggerFactory.getLogger(ServerKeyGenerator.class).error("Fail to browse network interfaces", e);
+ LoggerFactory.getLogger(ServerIdGenerator.class).error("Fail to browse network interfaces", e);
}
return result;
}
diff --git a/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java b/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java
index f030202c85d..abd659627fc 100644
--- a/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java
+++ b/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java
@@ -66,10 +66,10 @@ public final class ServerImpl extends Server {
}
}
- public String getKey() {
+ public String getPermanentServerId() {
DatabaseSession session = dbSessionFactory.getSession();
- Property serverKey = session.getSingleResult(Property.class, "key", CoreProperties.SERVER_KEY);
- return (serverKey!= null ? serverKey.getValue() : null);
+ Property serverId = session.getSingleResult(Property.class, "key", CoreProperties.PERMANENT_SERVER_ID);
+ return (serverId!= null ? serverId.getValue() : null);
}
public String getId() {
diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
index 297f1b23413..bb8d0d3b99b 100644
--- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
+++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
@@ -44,7 +44,7 @@ import org.sonar.server.filters.FilterExecutor;
import org.sonar.server.filters.FilterResult;
import org.sonar.server.notifications.reviews.ReviewsNotificationManager;
import org.sonar.server.platform.Platform;
-import org.sonar.server.platform.ServerKeyGenerator;
+import org.sonar.server.platform.ServerIdGenerator;
import org.sonar.server.plugins.*;
import org.sonar.server.rules.ProfilesConsole;
import org.sonar.server.rules.RulesConsole;
@@ -52,7 +52,6 @@ import org.sonar.updatecenter.common.Version;
import java.net.InetAddress;
import java.sql.Connection;
-import java.sql.SQLException;
import java.util.Collection;
import java.util.List;
import java.util.Set;
@@ -276,12 +275,12 @@ public final class JRubyFacade {
return getContainer().getComponent(Configuration.class).getString(key, null);
}
- public List<InetAddress> getValidInetAddressesForServerKey() {
- return getContainer().getComponent(ServerKeyGenerator.class).getAvailableAddresses();
+ public List<InetAddress> getValidInetAddressesForServerId() {
+ return getContainer().getComponent(ServerIdGenerator.class).getAvailableAddresses();
}
- public String generateServerKey(String organization, String ipAddress) {
- return getContainer().getComponent(ServerKeyGenerator.class).generate(organization, ipAddress);
+ public String generateServerId(String organisation, String ipAddress) {
+ return getContainer().getComponent(ServerIdGenerator.class).generate(organisation, ipAddress);
}
public Connection getConnection() {
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/server_key_configuration_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/server_id_configuration_controller.rb
index 8e2e59fd3e1..9f77056ad06 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/server_key_configuration_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/server_id_configuration_controller.rb
@@ -17,37 +17,42 @@
# License along with Sonar; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
#
-class ServerKeyConfigurationController < ApplicationController
+class ServerIdConfigurationController < ApplicationController
SECTION=Navigation::SECTION_CONFIGURATION
- PROPERTY_SERVER_KEY = 'sonar.server_key'
- PROPERTY_IP_ADDRESS = 'sonar.server_key.ip_address'
- PROPERTY_ORGANIZATION = 'sonar.organization'
+ PROPERTY_SERVER_ID = 'sonar.server_id'
+ PROPERTY_IP_ADDRESS = 'sonar.server_id.ip_address'
+ PROPERTY_ORGANISATION = 'sonar.organisation'
before_filter :admin_required
- verify :method => :post, :only => [:save], :redirect_to => {:action => :index}
+ verify :method => :post, :only => [:generate], :redirect_to => {:action => :index}
def index
- @server_key = Property.value(PROPERTY_SERVER_KEY)
- @organization = Property.value(PROPERTY_ORGANIZATION)
+ @server_id = Property.value(PROPERTY_SERVER_ID)
+ @organisation = Property.value(PROPERTY_ORGANISATION)
@address = Property.value(PROPERTY_IP_ADDRESS)
- @valid_addresses = java_facade.getValidInetAddressesForServerKey()
+ @valid_addresses = java_facade.getValidInetAddressesForServerId()
+ @bad_id = false
+ if @server_id.present?
+ id = java_facade.generateServerId(@organisation, @address)
+ @bad_id = (@server_id != id)
+ end
params[:layout]='false'
end
- def save
- organization = params[:organization]
- Property.set(PROPERTY_ORGANIZATION, organization)
+ def generate
+ organisation = params[:organisation]
+ Property.set(PROPERTY_ORGANISATION, organisation)
ip_address=params[:address]
Property.set(PROPERTY_IP_ADDRESS, ip_address)
- key = java_facade.generate_server_key(organization, ip_address)
- if key
- Property.set(PROPERTY_SERVER_KEY, key)
+ id = java_facade.generateServerId(organisation, ip_address)
+ if id
+ Property.set(PROPERTY_SERVER_ID, id)
else
- Property.clear(PROPERTY_SERVER_KEY)
- flash[:error] = 'Please set valid organization and IP address'
+ Property.clear(PROPERTY_SERVER_ID)
+ flash[:error] = Api::Utils.message('server_id_configuration.generation_error')
end
redirect_to :action => 'index'
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb
index 8a052d24953..d3d27285c9e 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb
@@ -21,7 +21,7 @@ class SettingsController < ApplicationController
SECTION=Navigation::SECTION_CONFIGURATION
- SPECIAL_CATEGORIES=['email', 'server_key']
+ SPECIAL_CATEGORIES=['email', 'server_id']
verify :method => :post, :only => ['update'], :redirect_to => {:action => :index}
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/server_id_configuration/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/server_id_configuration/index.html.erb
new file mode 100644
index 00000000000..b5c39c8ac28
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/server_id_configuration/index.html.erb
@@ -0,0 +1,60 @@
+<h3 class="marginbottom10"><%= message('server_id_configuration.page') -%></h3>
+
+<% if @server_id %>
+ <p>
+ <big><b><span class="<%= @bad_id ? 'error' : 'notice' -%>"><%= @server_id -%></span></b></big>
+ <% if @bad_id %>
+ <span class="error"><%= message('server_id_configuration.bad_id') -%></span>
+ <% end %>
+ </p>
+ <br/>
+<% end %>
+
+<p>
+ <%= message('server_id_configuration.information') -%>
+</p>
+
+<% form_tag :action => 'generate' do %>
+ <table class="data marginbottom10">
+ <thead>
+ <tr>
+ <th></th>
+ </tr>
+ </thead>
+ <tfoot>
+ <tr>
+ <td colspan="3">
+ <%= submit_tag message('server_id_configuration.generate_button'), :disable_with => message('server_id_configuration.generating_button') %>
+ </td>
+ </tr>
+ </tfoot>
+ <tbody>
+ <tr class="even">
+ <td style="padding: 10px">
+ <h3><%= message('server_id_configuration.organisation.title') -%></h3>
+
+ <p class="marginbottom10"><%= message('server_id_configuration.organisation.desc') -%></p>
+
+ <p>
+ <input type="text" name="organisation" value="<%= @organisation -%>"/>
+ </p>
+ </td>
+ </tr>
+ <tr class="odd">
+ <td style="padding: 10px">
+ <h3><%= message('server_id_configuration.ip.title') -%></h3>
+
+ <p class="marginbottom10"><%= message('server_id_configuration.ip.desc') -%></p>
+ <ul class="marginbottom10 bullet">
+ <% @valid_addresses.each_with_index do |ip_address, index| %>
+ <li><span class="address_<%= index -%>"><%= ip_address.getHostAddress() -%></span></li>
+ <% end %>
+ </ul>
+ <p>
+ <input type="text" name="address" value="<%= @address -%>"/>
+ </p>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+<% end %> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/server_key_configuration/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/server_key_configuration/index.html.erb
deleted file mode 100644
index cf7db6f87c5..00000000000
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/server_key_configuration/index.html.erb
+++ /dev/null
@@ -1,58 +0,0 @@
-<h3 class="marginbottom10"><%= message('server_key_configuration.page') -%></h3>
-
-<% if @server_key %>
- <p>Server Key: <span class="notice"><b><%= @server_key -%></b></span></p>
-<% else %>
-<% end %>
-<p>
- Speech sur l'utilité de la clé....
-</p>
-
-<% form_tag :action => :save do %>
- <table class="data marginbottom10">
- <thead>
- <tr>
- <th></th>
- </tr>
- </thead>
- <tfoot>
- <% if @server_key %>
- <tr>
- <td colspan="3">
- <span class="warning">Changing configuration can disable your SonarSource commercial licenses. You'll have to renew them.</span>
- </td>
- </tr>
- <% end %>
- <tr>
- <td colspan="3">
- <%= submit_tag message('server_key_configuration.generate_button'), :disable_with => message('server_key_configuration.generating_button') %>
- </td>
- </tr>
- </tfoot>
- <tbody>
- <tr class="even">
- <td style="padding: 10px">
- <h3>Organization</h3>
- <p class="marginbottom10">The organization is ....</p>
- <p>
- <input type="text" name="organization" value="<%= @organization -%>"/>
- </p>
- </td>
- </tr>
- <tr class="odd">
- <td style="padding: 10px">
- <h3>Fixed IP Address</h3>
- <p class="marginbottom10">The IP address is .... Choose one of the following:</p>
- <ul class="marginbottom10 bullet">
- <% @valid_addresses.each_with_index do |ip_address, index| %>
- <li><span class="address_<%= index -%>"><%= ip_address.getHostAddress() -%></span></li>
- <% end %>
- </ul>
- <p>
- <input type="text" name="address" value="<%= @address -%>"/>
- </p>
- </td>
- </tr>
- </tbody>
- </table>
-<% end %> \ No newline at end of file
diff --git a/sonar-server/src/test/java/org/sonar/server/platform/ServerKeyGeneratorTest.java b/sonar-server/src/test/java/org/sonar/server/platform/ServerIdGeneratorTest.java
index f23abdc18c9..73677bec163 100644
--- a/sonar-server/src/test/java/org/sonar/server/platform/ServerKeyGeneratorTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/platform/ServerIdGeneratorTest.java
@@ -30,7 +30,7 @@ import java.net.UnknownHostException;
import static org.hamcrest.text.StringStartsWith.startsWith;
import static org.junit.Assert.assertThat;
-public class ServerKeyGeneratorTest {
+public class ServerIdGeneratorTest {
private static InetAddress localhost;
@@ -40,31 +40,31 @@ public class ServerKeyGeneratorTest {
}
@Test
- public void keyShouldHaveTenCharacters() {
- String key = new ServerKeyGenerator().toKey("SonarSource", localhost);
- assertThat(key.length(), Is.is(10)); // first character is version + 9 characters for checksum
- assertThat(StringUtils.isBlank(key), Is.is(false));
+ public void idShouldHaveTenCharacters() {
+ String id = new ServerIdGenerator().toId("SonarSource", localhost);
+ assertThat(id.length(), Is.is(10)); // first character is version + 9 characters for checksum
+ assertThat(StringUtils.isBlank(id), Is.is(false));
}
@Test
- public void keyShouldStartWithVersion() {
- String key = new ServerKeyGenerator().toKey("SonarSource", localhost);
- assertThat(key, startsWith(ServerKeyGenerator.VERSION));
+ public void idShouldStartWithVersion() {
+ String id = new ServerIdGenerator().toId("SonarSource", localhost);
+ assertThat(id, startsWith(ServerIdGenerator.VERSION));
}
@Test
public void loopbackAddressesShouldNotBeAccepted() throws UnknownHostException {
- assertThat(new ServerKeyGenerator().isFixed(InetAddress.getByName("127.0.0.1")), Is.is(false));
+ assertThat(new ServerIdGenerator().isFixed(InetAddress.getByName("127.0.0.1")), Is.is(false));
}
@Test
public void publicAddressesNotBeAccepted() throws UnknownHostException {
- assertThat(new ServerKeyGenerator().isFixed(InetAddress.getByName("sonarsource.com")), Is.is(true));
+ assertThat(new ServerIdGenerator().isFixed(InetAddress.getByName("sonarsource.com")), Is.is(true));
}
@Test
- public void keyShouldBeUniquePerOrganization() {
- ServerKeyGenerator generator = new ServerKeyGenerator(true);
+ public void idShouldBeUniquePerOrganisation() {
+ ServerIdGenerator generator = new ServerIdGenerator(true);
String k1 = generator.generate("Corp One", "127.0.0.1");
String k2 = generator.generate("Corp Two", "127.0.0.1");
@@ -72,11 +72,11 @@ public class ServerKeyGeneratorTest {
}
@Test
- public void keyShouldBeReproducible() {
- ServerKeyGenerator generator = new ServerKeyGenerator(true);
- String k1 = generator.generate("SonarSource", "127.0.0.1");
- String k2 = generator.generate("SonarSource", "127.0.0.1");
- assertThat(StringUtils.equals(k1, k2), Is.is(true));
+ public void idShouldBeReproducible() {
+ ServerIdGenerator generator = new ServerIdGenerator(true);
+ String i1 = generator.generate("SonarSource", "127.0.0.1");
+ String i2 = generator.generate("SonarSource", "127.0.0.1");
+ assertThat(StringUtils.equals(i1, i2), Is.is(true));
}
}
diff --git a/sonar-server/src/test/java/org/sonar/server/platform/ServerImplTest.java b/sonar-server/src/test/java/org/sonar/server/platform/ServerImplTest.java
index 835d53de9b8..145970608c5 100644
--- a/sonar-server/src/test/java/org/sonar/server/platform/ServerImplTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/platform/ServerImplTest.java
@@ -27,8 +27,6 @@ import java.io.IOException;
import java.util.Date;
import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
public class ServerImplTest extends AbstractDbUnitTestCase {
@@ -68,12 +66,12 @@ public class ServerImplTest extends AbstractDbUnitTestCase {
}
@Test
- public void shouldLoadServerKeyFromDatabase() {
- setupData("shouldLoadServerKeyFromDatabase");
+ public void shouldLoadServerIdFromDatabase() {
+ setupData("shouldLoadServerIdFromDatabase");
ServerImpl server = new ServerImpl(getSessionFactory(), new Date());
server.start();
- assertThat(server.getKey(), Is.is("abcde"));
+ assertThat(server.getPermanentServerId(), Is.is("abcde"));
}
}
diff --git a/sonar-server/src/test/java/org/sonar/server/platform/ServerLifecycleNotifierTest.java b/sonar-server/src/test/java/org/sonar/server/platform/ServerLifecycleNotifierTest.java
index 851164b38de..efa3a4adae1 100644
--- a/sonar-server/src/test/java/org/sonar/server/platform/ServerLifecycleNotifierTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/platform/ServerLifecycleNotifierTest.java
@@ -100,7 +100,7 @@ class FakeServer extends Server {
return null;
}
- public String getKey() {
+ public String getPermanentServerId() {
return null;
}
}
diff --git a/sonar-server/src/test/java/org/sonar/server/startup/ServerMetadataPersisterTest.java b/sonar-server/src/test/java/org/sonar/server/startup/ServerMetadataPersisterTest.java
index 51b0cf38baf..4a22f851b6d 100644
--- a/sonar-server/src/test/java/org/sonar/server/startup/ServerMetadataPersisterTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/startup/ServerMetadataPersisterTest.java
@@ -79,7 +79,7 @@ public class ServerMetadataPersisterTest extends AbstractDbUnitTestCase {
private Server newServer() throws ParseException {
Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse("2010-05-18 17:59");
Server server = mock(Server.class);
- when(server.getKey()).thenReturn("1abcdef");
+ when(server.getPermanentServerId()).thenReturn("1abcdef");
when(server.getId()).thenReturn("123");
when(server.getVersion()).thenReturn("2.2");
when(server.getStartedAt()).thenReturn(date);
diff --git a/sonar-server/src/test/resources/org/sonar/server/platform/ServerImplTest/shouldLoadServerKeyFromDatabase.xml b/sonar-server/src/test/resources/org/sonar/server/platform/ServerImplTest/shouldLoadServerIdFromDatabase.xml
index 0ca33b1e732..6e0919bd266 100644
--- a/sonar-server/src/test/resources/org/sonar/server/platform/ServerImplTest/shouldLoadServerKeyFromDatabase.xml
+++ b/sonar-server/src/test/resources/org/sonar/server/platform/ServerImplTest/shouldLoadServerIdFromDatabase.xml
@@ -1,6 +1,6 @@
<dataset>
- <properties id="1" prop_key="sonar.server_key" text_value="abcde" resource_id="[null]" user_id="[null]"/>
+ <properties id="1" prop_key="sonar.server_id" text_value="abcde" resource_id="[null]" user_id="[null]"/>
<properties id="2" prop_key="sonar.core.serverBaseURL" text_value="http://192.168.0.1" resource_id="[null]" user_id="[null]"/>
</dataset> \ No newline at end of file