Package com.eviware.soapui.impl.rest

Examples of com.eviware.soapui.impl.rest.OAuth2Profile


        OAuth2ProfileContainer profileContainer = request.getResource().getService().getProject()
                .getOAuth2ProfileContainer();

        if (O_AUTH_2_0.toString().equals(request.getAuthType())) {
            OAuth2Profile profile = profileContainer.getProfileByName(((AbstractHttpRequest) request).getSelectedAuthProfile());
            if (profile == null || StringUtils.isNullOrEmpty(profile.getAccessToken())) {
                return;
            }
            OAuth2ClientFacade oAuth2Client = getOAuth2ClientFacade();

            if (accessTokenIsExpired(profile)) {
                if (profile.shouldReloadAccessTokenAutomatically()) {
                    reloadAccessToken(profile, oAuth2Client);
                } else {
                    profile.setAccessTokenStatus(OAuth2Profile.AccessTokenStatus.EXPIRED);
                }
            }
            oAuth2Client.applyAccessToken(profile, httpMethod, request.getRequestContent());
        }
    }
View Full Code Here


    @Test
    public void basicOAuthConfigIsProjectSpecific() throws Exception {
        WsdlProject retrievedProject = new WsdlProject(projectFileName);

        assertThat(retrievedProject.getOAuth2ProfileContainer().getOAuth2ProfileList().size(), is(1));
        OAuth2Profile savedOAuth2Profile = retrievedProject.getOAuth2ProfileContainer().getOAuth2ProfileList().get(0);

        assertOAuth2ProfileFields(savedOAuth2Profile);

    }
View Full Code Here

    @Test
    public void basicOAuthConfigIsSaved() throws Exception {
        WsdlProject retrievedProject = new WsdlProject(projectFileName);

        assertThat(retrievedProject.getOAuth2ProfileContainer().getOAuth2ProfileList().size(), is(1));
        OAuth2Profile savedOAuth2Profile = retrievedProject.getOAuth2ProfileContainer().getOAuth2ProfileList().get(0);

        assertOAuth2ProfileFields(savedOAuth2Profile);
    }
View Full Code Here

    }

  /* Helpers */

    private OAuth2Profile createProfileWith(List<String> scripts) throws SoapUIException {
        OAuth2Profile profile = makeOAuth2Profile();
        profile.setAutomationJavaScripts(scripts);
        return profile;
    }
View Full Code Here

        assertThat(serverRadioButton, is(selected()));
    }

    @Test
    public void manualRadioButtonIsSelectedWhenManualIsSelectedInProfile() throws Exception {
        OAuth2Profile profile = OAuth2TestUtils.getOAuthProfileWithDefaultValues();
        profile.setUseManualAccessTokenExpirationTime(true);
        initializeChooserFromProfile(profile);

        JRadioButton manualRadioButton = walker.findComponent(ExpirationTimeChooser.MANUAL_EXPIRATION_RADIO_NAME, JRadioButton.class);
        assertThat(manualRadioButton, is(selected()));
    }
View Full Code Here

        assertThat(walker.findComponent(ExpirationTimeChooser.TIME_UNIT_COMBO_NAME, JComboBox.class), is(enabled()));
    }

    @Test
    public void populatesTimeTextFieldFromProfile() throws Exception {
        OAuth2Profile profile = OAuth2TestUtils.getOAuthProfileWithDefaultValues();
        profile.setManualAccessTokenExpirationTime("90");
        initializeChooserFromProfile(profile);

        JTextField timeField = walker.findComponent(ExpirationTimeChooser.TIME_FIELD_NAME, JTextField.class);
        assertThat(timeField.getText(), is("90"));
    }
View Full Code Here

                OAuth2ProfileContainerConfig.Factory.newInstance());
    }

    public static OAuth2Profile makeOAuth2Profile() throws SoapUIException {
        OAuth2ProfileConfig configuration = OAuth2ProfileConfig.Factory.newInstance();
        return new OAuth2Profile(makeOAuth2ProfileContainer(), configuration);
    }
View Full Code Here

    public static final String OAUTH_2_OOB_URN = "urn:ietf:wg:oauth:2.0:oob";

    public static OAuth2Profile getOAuthProfileWithDefaultValues() throws SoapUIException {
        OAuth2ProfileConfig configuration = OAuth2ProfileConfig.Factory.newInstance();
        OAuth2Profile profile = new OAuth2Profile(ModelItemFactory.makeOAuth2ProfileContainer(), configuration);
        profile.setName("OAuth 2 -Profile");
        profile.setAuthorizationURI("http://localhost:8080/authorize");
        profile.setAccessTokenURI("http://localhost:8080/accesstoken");
        profile.setRedirectURI("http://localhost:8080/redirect");
        profile.setClientID("ClientId");
        profile.setClientSecret("ClientSecret");
        profile.setScope("ReadOnly");
        return profile;
    }
View Full Code Here

        return profile;
    }

    public static OAuth2Profile getOAuth2ProfileWithOnlyAccessToken() throws SoapUIException {
        OAuth2ProfileConfig configuration = OAuth2ProfileConfig.Factory.newInstance();
        OAuth2Profile profileWithOnlyAccessToken = new OAuth2Profile(ModelItemFactory.makeOAuth2ProfileContainer(),
                configuration);
        profileWithOnlyAccessToken.setAccessToken(ACCESS_TOKEN);

        return profileWithOnlyAccessToken;
    }
View Full Code Here

        return profileWithOnlyAccessToken;
    }

    public static OAuth2Profile getOAuthProfileWithRefreshToken() throws SoapUIException {
        OAuth2Profile profile = getOAuthProfileWithDefaultValues();
        profile.setRefreshToken("REFRESH#TOKEN");

        return profile;
    }
View Full Code Here

TOP

Related Classes of com.eviware.soapui.impl.rest.OAuth2Profile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.