### Question:
SystemApiController implements SystemApi { @Override @PreAuthorize("hasAuthority('VIEW_INTERNAL_TLS_CERT')") public ResponseEntity<CertificateDetails> getSystemCertificate() { X509Certificate x509Certificate = internalTlsCertificateService.getInternalTlsCertificate(); CertificateDetails certificate = certificateDetailsConverter.convert(x509Certificate); return new ResponseEntity<>(certificate, HttpStatus.OK); } @Autowired  SystemApiController(InternalTlsCertificateService internalTlsCertificateService,
            CertificateDetailsConverter certificateDetailsConverter, SystemService systemService,
            TimestampingServiceConverter timestampingServiceConverter, AnchorConverter anchorConverter,
            VersionService versionService, VersionConverter versionConverter, CsrFilenameCreator csrFilenameCreator,
            AuditDataHelper auditDataHelper); @Override @PreAuthorize("hasAuthority('EXPORT_INTERNAL_TLS_CERT')") ResponseEntity<Resource> downloadSystemCertificate(); @Override @PreAuthorize("hasAuthority('VIEW_INTERNAL_TLS_CERT')") ResponseEntity<CertificateDetails> getSystemCertificate(); @Override @PreAuthorize("hasAuthority('VIEW_VERSION')") ResponseEntity<Version> systemVersion(); @Override @PreAuthorize("hasAuthority('GENERATE_INTERNAL_TLS_KEY_CERT')") @AuditEventMethod(event = GENERATE_INTERNAL_TLS_KEY_CERT) ResponseEntity<Void> generateSystemTlsKeyAndCertificate(); @Override @PreAuthorize("hasAuthority('VIEW_TSPS')") ResponseEntity<List<TimestampingService>> getConfiguredTimestampingServices(); @Override @PreAuthorize("hasAuthority('ADD_TSP')") @AuditEventMethod(event = ADD_TSP) ResponseEntity<TimestampingService> addConfiguredTimestampingService(
            TimestampingService timestampingServiceToAdd); @Override @PreAuthorize("hasAuthority('DELETE_TSP')") @AuditEventMethod(event = DELETE_TSP) ResponseEntity<Void> deleteConfiguredTimestampingService(TimestampingService timestampingService); @Override @PreAuthorize("hasAuthority('GENERATE_INTERNAL_TLS_CSR')") @AuditEventMethod(event = GENERATE_INTERNAL_TLS_CSR) ResponseEntity<Resource> generateSystemCertificateRequest(DistinguishedName distinguishedName); @Override @PreAuthorize("hasAuthority('IMPORT_INTERNAL_TLS_CERT')") @AuditEventMethod(event = IMPORT_INTERNAL_TLS_CERT) ResponseEntity<CertificateDetails> importSystemCertificate(Resource certificateResource); @Override @PreAuthorize("hasAuthority('VIEW_ANCHOR')") ResponseEntity<Anchor> getAnchor(); @Override @PreAuthorize("hasAuthority('DOWNLOAD_ANCHOR')") ResponseEntity<Resource> downloadAnchor(); @Override @PreAuthorize("hasAuthority('UPLOAD_ANCHOR')") @AuditEventMethod(event = UPLOAD_ANCHOR) ResponseEntity<Void> replaceAnchor(Resource anchorResource); @Override @PreAuthorize("hasAuthority('UPLOAD_ANCHOR')") ResponseEntity<Anchor> previewAnchor(Boolean verifyInstance, Resource anchorResource); @Override @PreAuthorize("hasAuthority('INIT_CONFIG')") @AuditEventMethod(event = INIT_ANCHOR) ResponseEntity<Void> uploadInitialAnchor(Resource anchorResource); static final String INTERNAL_KEY_CERT_INTERRUPTED; static final String ANCHOR_FILE_NOT_FOUND; }### Answer:
@Test(expected = AccessDeniedException.class) @WithMockUser(authorities = { "VIEW_PROXY_INTERNAL_CERT" }) public void getSystemCertificateWrongPermission() { systemApiController.getSystemCertificate(); }
@Test @WithMockUser(authorities = { "VIEW_INTERNAL_TLS_CERT" }) public void getSystemCertificateWithViewInternalSslCertPermission() throws Exception { getSystemCertificate(); }