<commit_before>import org.jfrog.artifactory.client.model.builder.impl.RepositoryBuildersImpl
import spock.lang.Specification
import org.jfrog.artifactory.client.model.repository.settings.impl.YumRepositorySettingsImpl

import java.security.MessageDigest

import static org.jfrog.artifactory.client.ArtifactoryClient.create
import static org.jfrog.artifactory.client.model.impl.RemoteRepoChecksumPolicyTypeImpl.pass_thru

class YumValidRemoteTest extends Specification {
    def 'check valid yum remote test'() {
        setup:
        def baseurl = 'http://localhost:8088/artifactory'
        def artifactory = create(baseurl, 'admin', 'password')

        def builder = artifactory.repositories().builders()
        
        def local = builder.localRepositoryBuilder().key('yum-local')
        .repositorySettings(new YumRepositorySettingsImpl()).build()
        artifactory.repositories().create(0, local)

        def remote = builder.remoteRepositoryBuilder().key('yum-remote')
        remote.repositorySettings(new YumRepositorySettingsImpl())
        remote.url('http://localhost:8088/artifactory/yum-local')
        remote.username('admin').password('password')
        artifactory.repositories().create(0, remote.build())

        def auth = "Basic ${'admin:password'.bytes.encodeBase64()}"
        def conn = new URL("${baseurl}/api/repositories/yum-remote").openConnection()
        conn.requestMethod = 'POST'
        conn.doOutput = true
        conn.setRequestProperty('Authorization', auth)
        conn.setRequestProperty('Content-Type', 'application/json')
        def textFile = "{\"remoteRepoChecksumPolicyType\":\"pass-thru\"}"
        conn.outputStream.write(textFile.bytes)
        assert conn.responseCode == 200
        conn.disconnect()
        
        def localrepo = artifactory.repository('yum-local')
        def remoterepo = artifactory.repository('yum-remote')
        def remoterepocache = artifactory.repository('yum-remote-cache')

        when:
        // upload some yum repo files
        def repomd = new File('./src/test/groovy/YumValidRemoteTest/test1/repomd.xml')
        def primary = new File('./src/test/groovy/YumValidRemoteTest/test1/primary.xml.gz')
        def flists = new File('./src/test/groovy/YumValidRemoteTest/test1/filelists.xml.gz')
        def other = new File('./src/test/groovy/YumValidRemoteTest/test1/other.xml.gz')
        localrepo.folder('repodata').create()
        localrepo.upload('repodata/repomd.xml', repomd).doUpload()
        localrepo.upload('repodata/primary.xml.gz', primary).doUpload()
        localrepo.upload('repodata/filelists.xml.gz', flists).doUpload()
        localrepo.upload('repodata/other.xml.gz', other).doUpload()
        // download the repomd file from the remote
        def filedata = []
        def mdstream = remoterepo.download('repodata/repomd.xml').doDownload()<commit_msg>Wait for remote repo indexing<commit_after>import org.jfrog.artifactory.client.model.builder.impl.RepositoryBuildersImpl
import spock.lang.Specification
import org.jfrog.artifactory.client.model.repository.settings.impl.YumRepositorySettingsImpl

import java.security.MessageDigest

import static org.jfrog.artifactory.client.ArtifactoryClient.create
import static org.jfrog.artifactory.client.model.impl.RemoteRepoChecksumPolicyTypeImpl.pass_thru

class YumValidRemoteTest extends Specification {
    def 'check valid yum remote test'() {
        setup:
        def baseurl = 'http://localhost:8088/artifactory'
        def artifactory = create(baseurl, 'admin', 'password')

        def builder = artifactory.repositories().builders()

        def local = builder.localRepositoryBuilder().key('yum-local')
        .repositorySettings(new YumRepositorySettingsImpl()).build()
        artifactory.repositories().create(0, local)

        def remote = builder.remoteRepositoryBuilder().key('yum-remote')
        remote.repositorySettings(new YumRepositorySettingsImpl())
        remote.url('http://localhost:8088/artifactory/yum-local')
        remote.username('admin').password('password')
        artifactory.repositories().create(0, remote.build())

        def auth = "Basic ${'<PASSWORD>:password'.bytes.encodeBase64()}"
        def conn = new URL("${baseurl}/api/repositories/yum-remote").openConnection()
        conn.requestMethod = 'POST'
        conn.doOutput = true
        conn.setRequestProperty('Authorization', auth)
        conn.setRequestProperty('Content-Type', 'application/json')
        def textFile = "{\"remoteRepoChecksumPolicyType\":\"pass-thru\"}"
        conn.outputStream.write(textFile.bytes)
        assert conn.responseCode == 200
        conn.disconnect()

        def localrepo = artifactory.repository('yum-local')
        def remoterepo = artifactory.repository('yum-remote')
        def remoterepocache = artifactory.repository('yum-remote-cache')

        when:
        // upload some yum repo files
        def repomd = new File('./src/test/groovy/YumValidRemoteTest/test1/repomd.xml')
        def primary = new File('./src/test/groovy/YumValidRemoteTest/test1/primary.xml.gz')
        def flists = new File('./src/test/groovy/YumValidRemoteTest/test1/filelists.xml.gz')
        def other = new File('./src/test/groovy/YumValidRemoteTest/test1/other.xml.gz')
        localrepo.folder('repodata').create()
        localrepo.upload('repodata/repomd.xml', repomd).doUpload()
        localrepo.upload('repodata/primary.xml.gz', primary).doUpload()
        localrepo.upload('repodata/filelists.xml.gz', flists).doUpload()
        localrepo.upload('repodata/other.xml.gz', other).doUpload()

        // Wait for indexing
        sleep(5000l)

        // download the repomd file from the remote
        def filedata = []
        def mdstream = remoterepo.download('repodata/repomd.xml').doDownload()
{'fraction_non_alphanumeric': 0.12648630018955712, 'fraction_numerical': 0.007237635705669481, 'mean_word_length': 3.450920245398773, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 18}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '9646', 'n_tokens_mistral': 1731, 'n_tokens_neox': 1687, 'n_words': 263}