Example #1
0
  def testSetScanConfigAuth_None(self):
    request = self.messages.WebsecurityscannerProjectsScanConfigsPatchRequest()
    args = self.FakeAuthArgs(auth_type='none')

    actual = auth.SetScanConfigAuth(None, args, request)

    self.assertEqual(request, actual)
Example #2
0
  def testSetScanConfigAuth_CustomAuthMissingUrl(self):
    request = self.messages.WebsecurityscannerProjectsScanConfigsPatchRequest()
    args = self.FakeAuthArgs(
        auth_type='custom', auth_user='******', auth_pass='******')

    with self.AssertRaisesToolExceptionRegexp(r'--auth-url'):
      auth.SetScanConfigAuth(None, args, request)
Example #3
0
  def testSetScanConfigAuth_CustomAuthMissingPassword(self):
    request = self.messages.WebsecurityscannerProjectsScanConfigsPatchRequest()
    args = self.FakeAuthArgs(
        auth_type='custom',
        auth_user='******',
        auth_url='http://example.com/login')

    with self.AssertRaisesToolExceptionRegexp(r'--auth-password'):
      auth.SetScanConfigAuth(None, args, request)
Example #4
0
  def testSetScanConfigAuth_GoogleAuth(self):
    request = self.messages.WebsecurityscannerProjectsScanConfigsPatchRequest()
    args = self.FakeAuthArgs(
        auth_type='google', auth_user='******', auth_pass='******')
    expected = self.messages.WebsecurityscannerProjectsScanConfigsPatchRequest(
        scanConfig=self.messages.ScanConfig(
            authentication=self.messages.Authentication(
                googleAccount=self.messages.GoogleAccount(
                    username='******',
                    password='******',
                ))))

    actual = auth.SetScanConfigAuth(None, args, request)

    self.assertEqual(actual, expected)
Example #5
0
  def testSetScanConfigAuth_CustomAuth(self):
    request = self.messages.WebsecurityscannerProjectsScanConfigsPatchRequest()
    args = self.FakeAuthArgs(
        auth_type='custom',
        auth_user='******',
        auth_pass='******',
        auth_url='http://example.com/login')
    expected = self.messages.WebsecurityscannerProjectsScanConfigsPatchRequest(
        scanConfig=self.messages.ScanConfig(
            authentication=self.messages.Authentication(
                customAccount=self.messages.CustomAccount(
                    username='******',
                    password='******',
                    loginUrl='http://example.com/login',
                ))))

    actual = auth.SetScanConfigAuth(None, args, request)

    self.assertEqual(actual, expected)
Example #6
0
  def testSetScanConfigAuth_GoogleAuthMissingPassword(self):
    request = self.messages.WebsecurityscannerProjectsScanConfigsPatchRequest()
    args = self.FakeAuthArgs(auth_type='google', auth_user='******')

    with self.AssertRaisesToolExceptionRegexp(r'--auth-password'):
      auth.SetScanConfigAuth(None, args, request)
Example #7
0
  def testSetScanConfigAuth_NoneAuthTypeWithOtherAuthFields(self):
    request = self.messages.WebsecurityscannerProjectsScanConfigsPatchRequest()
    args = self.FakeAuthArgs(auth_type='none', auth_pass='******')

    with self.AssertRaisesToolExceptionRegexp(r'--auth-type'):
      auth.SetScanConfigAuth(None, args, request)