Skip to content

Commit

Permalink
add support to teamcity 2017
Browse files Browse the repository at this point in the history
  • Loading branch information
tidezyc authored and pwielgolaski committed Sep 3, 2017
1 parent 14a7a64 commit fe2412b
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ Login at your Teamcity host.

= Development

Plugin can be build and deployed by `gradle deployPlugin`
Plugin can be build and deployed by `gradle deployToTeamcity`

Teamcity instance for testing can be setup by `docker-compose up`
37 changes: 20 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.5'
classpath 'pl.allegro.tech.build:axion-release-plugin:1.4.1'
classpath 'com.github.rodm:gradle-teamcity-plugin:0.8.1'
classpath 'com.github.rodm:gradle-teamcity-plugin:1.0'
}
}

Expand All @@ -31,7 +31,7 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8

ext {
teamcityVersion = '10.0.2'
teamcityVersion = '2017.1'
teamcityDir = "$rootDir/servers/TeamCity-${teamcityVersion}"
teamcityDataDir = "$rootDir/data/"
teamcityJavaHome = System.properties['java.home']
Expand All @@ -51,24 +51,27 @@ dependencies {

teamcity {
version = teamcityVersion

descriptor {
name = project.name
displayName = project.name
version = project.version
vendorName = 'wielgolaski.me'
description = 'oAuth2 authentication plugin'
downloadUrl = 'https://github.com/pwielgolaski/teamcity-oauth/'
email = 'pwielgolaski@gmail.com'
server {
descriptor {
name = project.name
displayName = project.name
version = project.version
vendorName = 'wielgolaski.me'
description = 'oAuth2 authentication plugin'
downloadUrl = 'https://github.com/pwielgolaski/teamcity-oauth/'
email = 'pwielgolaski@gmail.com'
}
}
environments {
teamcity {
version = teamcityVersion
homeDir = file(teamcityDir)
dataDir = file(teamcityDataDir)
javaHome = file(teamcityJavaHome)
}
}

homeDir = file(teamcityDir)
dataDir = file(teamcityDataDir)
javaHome = file(teamcityJavaHome)
}

deployPlugin.dependsOn assemble

bintray {
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package jetbrains.buildServer.auth.oauth;

import jetbrains.buildServer.serverSide.ServerSettings;
import jetbrains.buildServer.serverSide.SBuildServer;
import jetbrains.buildServer.serverSide.auth.AuthModule;
import jetbrains.buildServer.serverSide.auth.LoginConfiguration;
import org.jetbrains.annotations.NotNull;
Expand All @@ -13,18 +13,18 @@
public class AuthenticationSchemeProperties {

private final ConfigPresets presets;
private final ServerSettings serverSettings;
private final SBuildServer sBuildServer;
private final LoginConfiguration loginConfiguration;

public AuthenticationSchemeProperties(@NotNull final ServerSettings serverSettings, @NotNull final LoginConfiguration loginConfiguration) {
this.serverSettings = serverSettings;
public AuthenticationSchemeProperties(@NotNull final SBuildServer sBuildServer, @NotNull final LoginConfiguration loginConfiguration) {
this.sBuildServer = sBuildServer;
this.loginConfiguration = loginConfiguration;
this.presets = new ConfigPresets();
}

@Nullable
public String getRootUrl() {
return serverSettings.getRootUrl();
return sBuildServer.getRootUrl();
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package jetbrains.buildServer.auth.oauth;

import com.google.common.base.Strings;
import com.intellij.openapi.util.text.StringUtil;
import jetbrains.buildServer.controllers.interceptors.auth.HttpAuthenticationResult;
import jetbrains.buildServer.controllers.interceptors.auth.HttpAuthenticationSchemeAdapter;
import jetbrains.buildServer.controllers.interceptors.auth.util.HttpAuthUtil;
Expand Down Expand Up @@ -70,7 +70,7 @@ public HttpAuthenticationResult processAuthenticationRequest(@NotNull HttpServle
String code = request.getParameter(CODE);
String state = request.getParameter(STATE);

if (Strings.isNullOrEmpty(code) || Strings.isNullOrEmpty(state))
if (StringUtil.isEmpty(code) || StringUtil.isEmpty(state))
return HttpAuthenticationResult.notApplicable();

LOG.debug(String.format("oAuth response with code '%s' & state '%s'", code, state));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package jetbrains.buildServer.auth.oauth;

import jetbrains.buildServer.controllers.AuthorizationInterceptor;
import jetbrains.buildServer.serverSide.ServerSettings;
import jetbrains.buildServer.serverSide.SBuildServer;
import jetbrains.buildServer.serverSide.auth.LoginConfiguration;
import jetbrains.buildServer.users.UserModel;
import jetbrains.buildServer.web.openapi.PagePlaces;
Expand All @@ -14,8 +14,8 @@
public class PluginConfiguration {

@Bean
public AuthenticationSchemeProperties authenticationSchemeProperties(ServerSettings serverSettings, LoginConfiguration loginConfiguration) {
return new AuthenticationSchemeProperties(serverSettings, loginConfiguration);
public AuthenticationSchemeProperties authenticationSchemeProperties(SBuildServer sBuildServer, LoginConfiguration loginConfiguration) {
return new AuthenticationSchemeProperties(sBuildServer, loginConfiguration);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package jetbrains.buildServer.auth.oauth

import jetbrains.buildServer.serverSide.ServerSettings
import jetbrains.buildServer.serverSide.SBuildServer
import jetbrains.buildServer.serverSide.auth.AuthModule
import jetbrains.buildServer.serverSide.auth.LoginConfiguration
import spock.lang.Specification
Expand All @@ -18,10 +18,10 @@ class AuthenticationSchemePropertiesTest extends Specification {
getConfiguredAuthModules(_) >> [authModule]
isGuestLoginAllowed() >> true
}
ServerSettings serverSettings = Mock() {
SBuildServer sBuildServer = Mock() {
getRootUrl() >> 'rooturl'
}
schemeProperties = new AuthenticationSchemeProperties(serverSettings, loginConfiguration)
schemeProperties = new AuthenticationSchemeProperties(sBuildServer, loginConfiguration)
}

def "configuration read root url"() {
Expand Down

0 comments on commit fe2412b

Please sign in to comment.