Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(openstack): Fix openstack unit tests #3402

Merged
merged 1 commit into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class OpenstackIdentityV3ProviderSpec extends Specification {
mockClient = Mock(OSClient.OSClientV3) {
getToken() >> { Mock(Token) }
}
//IOSClientBuilder.V3.metaClass.authenticate = { mockClient }
provider = Spy(OpenstackIdentityV3Provider, constructorArgs:[credentials]) {
buildClient() >> { mockClient }
getClient() >> { mockClient }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ package com.netflix.spinnaker.clouddriver.openstack.security
import com.netflix.spinnaker.clouddriver.consul.config.ConsulConfig
import com.netflix.spinnaker.clouddriver.openstack.client.OpenstackClientProvider
import com.netflix.spinnaker.clouddriver.openstack.client.OpenstackIdentityV3Provider
import com.netflix.spinnaker.clouddriver.openstack.config.OpenstackConfigurationProperties
import com.netflix.spinnaker.clouddriver.openstack.client.OpenstackProviderFactory
import com.netflix.spinnaker.clouddriver.openstack.config.OpenstackConfigurationProperties.LbaasConfig
import com.netflix.spinnaker.clouddriver.openstack.config.OpenstackConfigurationProperties.StackConfig
import org.openstack4j.api.OSClient
import org.openstack4j.api.client.IOSClientBuilder
import org.openstack4j.model.identity.v3.Token
import org.openstack4j.openstack.compute.domain.ext.ExtAvailabilityZone
import spock.lang.Specification
Expand All @@ -41,7 +40,8 @@ class OpenstackNamedAccountCredentialsSpec extends Specification {
setup:
// Mock out the authenticate call within Openstack4J
OSClient.OSClientV3 mockClient = Mock(OSClient.OSClientV3)
IOSClientBuilder.V3.metaClass.authenticate = { mockClient }
def openStackIdentityProvider = GroovySpy(OpenstackIdentityV3Provider, global: true)
openStackIdentityProvider.buildClient() >> mockClient

when:
def credentials = new OpenstackNamedAccountCredentials("name", "test", "main", "user", "pw", "project", "domain", "endpoint", [], false, "", new LbaasConfig(pollTimeout: 60, pollInterval: 5),new StackConfig(pollTimeout: 60, pollInterval: 5), new ConsulConfig(), null)
Expand All @@ -62,7 +62,9 @@ class OpenstackNamedAccountCredentialsSpec extends Specification {
def "Builder populates region-to-zone map: #description"() {
setup:
OpenstackClientProvider mockProvider = Mock(OpenstackClientProvider)
OpenstackCredentials.metaClass.getProvider = { mockProvider }
GroovyMock(OpenstackProviderFactory, global: true) {
OpenstackProviderFactory.createProvider(_) >> mockProvider
}

when:
def builder = new OpenstackNamedAccountCredentials.Builder()
Expand Down