jetbrains.buildServer.serverSide.auth.Permission Java Examples

The following examples show how to use jetbrains.buildServer.serverSide.auth.Permission. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DownloadSymbolsControllerTest.java    From teamcity-symbol-server with Apache License 2.0 6 votes vote down vote up
@Test(dataProvider = "Booleans")
public void request_pdb_guid_case_insensitive(boolean lowercaseSignature) throws Exception{
  myFixture.getServerSettings().setPerProjectPermissionsEnabled(true);
  SUser user = myFixture.getUserModel().getGuestUser();
  user.addRole(RoleScope.projectScope(myProject.getProjectId()), getProjectDevRole());
  assertTrue(user.isPermissionGrantedForProject(myProject.getProjectId(), Permission.VIEW_BUILD_RUNTIME_DATA));

  final String fileSignatureUpper = "8EF4E863187C45E78F4632152CC82FEB";
  final String fileSignature = lowercaseSignature ? fileSignatureUpper.toLowerCase() : fileSignatureUpper;
  final String guid = "8EF4E863187C45E78F4632152CC82FE";
  final String fileName = "secur32.pdb";
  final String filePath = "foo/secur32.pdb";
  final byte[] fileContent = new byte[]{(byte) (lowercaseSignature ? 1 : 0)};

  RunningBuildEx build = startBuild();
  build.publishArtifact(filePath, fileContent);
  finishBuild(build, false);

  myBuildMetadataStorage.addEntry(build.getBuildId(), guid.toLowerCase(), fileName, filePath);
  myRequest.setRequestURI("mock", String.format("/app/symbols/%s/%s/%s", fileName, fileSignature, fileName));

  doGet();

  assertEquals(-1, myResponse.getStatus());
  assertTrue("Returned data did not match set pdb data", Arrays.equals(fileContent, myResponse.getReturnedBytes()));
}
 
Example #2
Source File: DownloadSymbolsControllerTest.java    From teamcity-symbol-server with Apache License 2.0 5 votes vote down vote up
@Test
public void request_pdb_simple() throws Throwable {
  myFixture.getServerSettings().setPerProjectPermissionsEnabled(true);
  SUser user = myFixture.getUserModel().getGuestUser();
  user.addRole(RoleScope.projectScope(myProject.getProjectId()), getProjectDevRole());
  assertTrue(user.isPermissionGrantedForProject(myProject.getProjectId(), Permission.VIEW_BUILD_RUNTIME_DATA));

  myRequest.setRequestURI("mock", getRegisterPdbUrl("8EF4E863187C45E78F4632152CC82FEB", "secur32.pdb", "secur32.pdb"));

  doGet();

  assertEquals(HttpStatus.SC_NOT_FOUND, myResponse.getStatus());
  assertEquals("Symbol file not found", myResponse.getStatusText());
}
 
Example #3
Source File: DownloadSymbolsControllerTest.java    From teamcity-symbol-server with Apache License 2.0 5 votes vote down vote up
@Test
public void request_file_with_plus_sign() throws Exception{
  myFixture.getServerSettings().setPerProjectPermissionsEnabled(true);

  SUser user = myFixture.getUserModel().getGuestUser();
  user.addRole(RoleScope.projectScope(myProject.getProjectId()), getProjectDevRole());
  assertTrue(user.isPermissionGrantedForProject(myProject.getProjectId(), Permission.VIEW_BUILD_RUNTIME_DATA));

  final File artDirectory = createTempDir();
  final String fileName = "file++.pdb";
  File file = new File(artDirectory, fileName);
  assertTrue(file.createNewFile());
  FileUtil.writeFile(file, "text", "UTF-8");

  myBuildType.setArtifactPaths(artDirectory.getAbsolutePath());
  RunningBuildEx build = startBuild();
  build.publishArtifact(fileName, file);
  finishBuild(build, false);

  final String fileSignature = "8EF4E863187C45E78F4632152CC82FEB";
  final String guid = "8EF4E863187C45E78F4632152CC82FE";

  myBuildMetadataStorage.addEntry(build.getBuildId(), guid.toLowerCase(), fileName, fileName);
  myRequest.setRequestURI("mock", String.format("/app/symbols/%s/%s/%s", fileName, fileSignature, fileName));

  doGet();

  assertEquals(-1, myResponse.getStatus());
  assertEquals("text", myResponse.getReturnedContent());

  myRequest.setRequestURI("mock", String.format("/app/symbols/%s/%s/%s", "file%2b%2b.pdb", fileSignature, fileName));

  doGet();

  assertEquals(-1, myResponse.getStatus());
  assertEquals("text", myResponse.getReturnedContent());
}
 
Example #4
Source File: TelegramSettingsPage.java    From teamcity-telegram-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isAvailable(@NotNull HttpServletRequest request) {
  return super.isAvailable(request) &&
      checkHasGlobalPermission(request, Permission.CHANGE_SERVER_SETTINGS);
}
 
Example #5
Source File: SymbolServerSettingsTab.java    From teamcity-symbol-server with Apache License 2.0 4 votes vote down vote up
private boolean hasAccess() {
  return AuthUtil.hasGlobalPermission(mySecurityContext.getAuthorityHolder(), Permission.CHANGE_SERVER_SETTINGS);
}
 
Example #6
Source File: SlackAdminPage.java    From TCSlackNotifierPlugin with MIT License 4 votes vote down vote up
@Override
public boolean isAvailable(HttpServletRequest request) {
    return super.isAvailable(request) && checkHasGlobalPermission(request, Permission.CHANGE_SERVER_SETTINGS);
}
 
Example #7
Source File: SlackNotifierAdminPage.java    From tcSlackBuildNotifier with MIT License 4 votes vote down vote up
@Override
public boolean isAvailable(@NotNull HttpServletRequest request) {
    return super.isAvailable(request) && checkHasGlobalPermission(request, Permission.CHANGE_SERVER_SETTINGS);
}