
com.peachapisecurity.tg.junit4.examples.PeachFlaskRestTarget Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tg-junit4 Show documentation
Show all versions of tg-junit4 Show documentation
Peach API Security JUnit4 Integration
The newest version!
/*
* Copyright 2017 Peach Tech
* 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.
*/
/*
* Example of a junit4 setup that runs unit tests through
* Peach API Security.
*
* This JUnit test suite is intended to be run from one of
* the CI runnders. It expects the CI runner to start
* a proxy instance and set the following environmental
* variables:
*
* PEACH_API
* PEACH_PROXY
* PEACH_SESSIONID
*
*/
package com.peachapisecurity.tg.junit4.examples;
import com.peachapisecurity.api.PeachApiSecurity;
import com.peachapisecurity.tg.junit4.JUnit4PeachSuiteRunner;
import com.peachapisecurity.tg.junit4.JUnit4PeachSuiteRunner.PeachSuiteClasses;
import java.net.URI;
import org.apache.http.HttpHost;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
@RunWith(com.peachapisecurity.tg.junit4.JUnit4PeachSuiteRunner.class)
@PeachSuiteClasses({TestUsers.class, TestUser.class})
public class PeachFlaskRestTarget {
@BeforeClass
public static void setProxy()
{
// Setup proxy options for our HTTP library
// This code will vary depending on the HTTP library
// in use.
PeachApiSecurity peach = new PeachApiSecurity();
TestUser.Proxy = new HttpHost(peach.getProxyHost(), peach.getProxyPort());
}
@AfterClass
public static void removeProxy()
{
// Remove any proxy options for our HTTP library
// This code will vary depending on the HTTP library
// in use.
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy