Created
January 8, 2016 18:51
-
-
Save jdcasey/8e042ffe7600ccf129d0 to your computer and use it in GitHub Desktop.
example using jhttpc and causeway's koji client to talk to koji.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (C) 2015 Red Hat, Inc. (jdcasey@commonjava.org) | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* limitations under the License. | |
*/ | |
package org.jboss.pnc.causeway.koji; | |
import org.commonjava.util.jhttpc.HttpFactory; | |
import org.commonjava.util.jhttpc.auth.MemoryPasswordManager; | |
import org.commonjava.util.jhttpc.auth.PasswordManager; | |
import org.commonjava.util.jhttpc.auth.PasswordType; | |
import org.jboss.pnc.causeway.config.CausewayConfig; | |
import org.jboss.pnc.causeway.koji.model.KojiSessionInfo; | |
import org.junit.Before; | |
import org.junit.Ignore; | |
import org.junit.Test; | |
/** | |
* Created by jdcasey on 11/13/15. | |
*/ | |
public class DockerKojiClientTest | |
{ | |
private KojiClient client; | |
@Before | |
public void setup() | |
throws Exception | |
{ | |
String baseUrl = "https://172.17.1.115/kojihub"; | |
CausewayConfig config = new CausewayConfig(); | |
config.setKojiURL( baseUrl ); | |
config.setKojiClientKeyCertificateFile( "/opt/koji-clients/testuser/client.pem" ); | |
config.setKojiClientCertificatePassword( "mypassword" ); | |
config.setKojiServerCertificateFile( "/opt/koji-clients/testuser/serverca.crt" ); | |
config.setKojiTimeout(30); | |
config.configurationDone(); | |
PasswordManager passwords = new MemoryPasswordManager(); | |
passwords.bind( config.getKojiClientCertificatePassword(), CausewayConfig.KOJI_SITE_ID, PasswordType.KEY ); | |
HttpFactory httpFactory = new HttpFactory( passwords ); | |
KojiBindery bindery = new KojiBindery(); | |
client = new KojiClient( config, bindery, httpFactory ); | |
} | |
@Test | |
@Ignore | |
public void login_logout() | |
throws Exception | |
{ | |
KojiSessionInfo sessionInfo = client.login(); | |
client.logout( sessionInfo ); | |
System.out.println(sessionInfo); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment