<commit_before>Feature: Basic Generate Functionality
	In order to generate a properly formatted plist mobileconfig
	As a CLI
	Some basic inputs are required

	Background:
		Given a file named "ca.crt" with:
			"""
			Contents of CA file
			With newlines
			And more newlines
			That should appear as one line
			"""
		And a file named "p12file.p12" with:
			"""
			p12file that should appear
			In base64 encoding as <data/>
			"""

	Scenario: I need help
		When I run `ovpnmcgen.rb help g`
		Then the output should contain "Usage:"

	Scenario: Missing 2 arguments
		When I run `ovpnmcgen.rb g`
		Then the output should contain "error: "
		And the output should contain "arguments"

	Scenario: Missing 1 argument
		When I run `ovpnmcgen.rb g cucumber`
		Then the output should contain "error: "
		And the output should contain "arguments"

	Scenario: Correct number of arguments but missing required flags
		When I run `ovpnmcgen.rb g cucumber aruba`
		Then the output should contain "error: "

	Scenario: Correct arguments but missing required flags, except the host flag.
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org cucumber aruba`
		And the output should not contain "error: Host"
		Then the output should contain "error: "

	Scenario: Correct arguments but missing required flags, except the host, cafile flag.
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org --cafile ca.crt cucumber aruba`
		And the output should not contain "error: Host"
		And the output should not contain "error: cafile"
		Then the output should contain "error: "

	Scenario: Correct arguments will all required flags, host, cafile, p12file.
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org --cafile ca.crt --p12file p12file.p12 cucumber aruba`
		And the output should not contain "error: Host"
		And the output should not contain "error: cafile"
		And the output should not contain "error: PKCS#12"
		Then the output should match:
			"""
			<\?xml version="1.0" encoding="UTF-8"\?>
			<!DOCTYPE plist PUBLIC "-\/\/Apple*\/\/DTD PLIST 1.0\/\/EN" "http:\/\/www.apple.com\/DTDs\/PropertyList-1.0.dtd">
			<plist version="1.0">
			"""
		And the output should match:
			"""
			<key>remote</key>
			\s*<string>aruba.cucumber.org 1194 udp</string>
			"""
		And the output should match:
			"""
			<key>ca</key>
			\s*<string>Contents of CA file\\nWith newlines\\nAnd more newlines\\nThat should appear as one line</string>
			"""
		And the output should match:
			"""
			<key>PayloadCertificateFileName</key>\s*
			\s*<string>cucumber-aruba.p12</string>
			\s*<key>PayloadContent</key>
			\s*<data>
			\s*cDEyZmlsZSB0aGF0IHNob3VsZCBhcHBlYXIKSW4gYmFzZTY0IGVuY29kaW5n
			\s*IGFzIDxkYXRhLz4=
			\s*</data>
			"""
		And the output should match:
			"""
			<key>OnDemandEnabled</key>
			\s*<integer>1</integer>
			"""

	Scenario: The p12pass flag is set.
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org --cafile ca.crt --p12file p12file.p12 --p12pass p12passphrase cucumber aruba`
		Then the output should match:
			"""
			<key>Password</key>
			\s*<string>p12passphrase</string>
			"""

	Scenario: The tafile flag is set.
		Given a file named "ta.key" with:
			"""
			Contents of TLS-Auth Key file
			With newlines
			And more newlines
			That should appear as one line
			"""
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org --cafile ca.crt --p12file p12file.p12 --tafile ta.key cucumber aruba`
		Then the output should match:
			"""
			<key>tls-auth</key>
			\s*<string>Contents of TLS-Auth Key file\\nWith newlines\\nAnd more newlines\\nThat should appear as one line</string>
			"""

	Scenario: The proto and port flags are set.
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org --cafile ca.crt --p12file p12file.p12 --proto tcp --port 1234 cucumber aruba`
		Then the output should match:
			"""
			<key>remote</key>
			\s*<string>aruba.cucumber.org 1234 tcp</string>
			"""

	Scenario: The no-vod flag is set.
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org --cafile ca.crt --p12file p12file.p12 --no-vod cucumber aruba`
		Then the output should match:
			"""
			<key>OnDemandEnabled</key>
			\s*<integer>0</integer>
			"""

	Scenario: The url-probe flag is set.
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org --cafile ca.crt --p12file p12file.p12 --url-probe 'https://url.to.probe/' cucumber aruba`
		Then the output should match:
			"""
			<key>URLStringProbe</key><commit_msg>Created tests for planned new features.<commit_after>Feature: Basic Generate Functionality
	In order to generate a properly formatted plist mobileconfig
	As a CLI
	Some basic inputs are required

	Background:
		Given a file named "ca.crt" with:
			"""
			Contents of CA file
			With newlines
			And more newlines
			That should appear as one line
			"""
		And a file named "p12file.p12" with:
			"""
			p12file that should appear
			In base64 encoding as <data/>
			"""
		And a file named "cert.crt" with:
			"""
			Contents of cert file
			With newlines
			And more newlines
			That should appear as one line
			"""
		And a file named "key.pem" with:
			"""
			Contents of key file
			With newlines
			And more newlines
			That should appear as one line
			"""

	Scenario: I need help
		When I run `ovpnmcgen.rb help g`
		Then the output should contain "Usage:"

	Scenario: Missing 2 arguments
		When I run `ovpnmcgen.rb g`
		Then the output should contain "error: "
		And the output should contain "arguments"

	Scenario: Missing 1 argument
		When I run `ovpnmcgen.rb g cucumber`
		Then the output should contain "error: "
		And the output should contain "arguments"

	Scenario: Correct number of arguments but missing required flags
		When I run `ovpnmcgen.rb g cucumber aruba`
		Then the output should contain "error: "

	Scenario: Correct arguments but missing required flags, except the host flag.
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org cucumber aruba`
		And the output should not contain "error: Host"
		Then the output should contain "error: "

	Scenario: Correct arguments but missing required flags, except the host, cafile flag.
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org --cafile ca.crt cucumber aruba`
		And the output should not contain "error: Host"
		And the output should not contain "error: cafile"
		Then the output should contain "error: "

	@v0.6.0
	Scenario: Correct arguments with all required flags, host, cafile, except (either p12file or (cert and key)).
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org --cafile ca.crt --p12file p12file.p12 cucumber aruba`
		And the output should not contain "error: Host"
		And the output should not contain "error: cafile"
		Then the output should contain "error: PKCS#12 or cert & key missing"

	Scenario: Correct arguments with all required flags, host, cafile, and p12file (no cert and key).
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org --cafile ca.crt --p12file p12file.p12 cucumber aruba`
		And the output should not contain "error: Host"
		And the output should not contain "error: cafile"
		And the output should not contain "error: PKCS#12"
		Then the output should match:
			"""
			<\?xml version="1.0" encoding="UTF-8"\?>
			<!DOCTYPE plist PUBLIC "-\/\/Apple*\/\/DTD PLIST 1.0\/\/EN" "http:\/\/www.apple.com\/DTDs\/PropertyList-1.0.dtd">
			<plist version="1.0">
			"""
		And the output should match:
			"""
			<key>remote</key>
			\s*<string>aruba.cucumber.org 1194 udp</string>
			"""
		And the output should match:
			"""
			<key>ca</key>
			\s*<string>Contents of CA file\\nWith newlines\\nAnd more newlines\\nThat should appear as one line</string>
			"""
		And the output should match:
			"""
			<key>PayloadCertificateFileName</key>\s*
			\s*<string>cucumber-aruba.p12</string>
			\s*<key>PayloadContent</key>
			\s*<data>
			\s*cDEyZmlsZSB0aGF0IHNob3VsZCBhcHBlYXIKSW4gYmFzZTY0IGVuY29kaW5n
			\s*IGFzIDxkYXRhLz4=
			\s*</data>
			"""
		And the output should match:
			"""
			<key>OnDemandEnabled</key>
			\s*<integer>1</integer>
			"""

	@OCv1.2 @v0.6.0
	Scenario: Correct arguments with all required flags, host, cafile, cert, and key (no p12file).
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org --cafile ca.crt --cert cert.crt --key key.pem cucumber aruba`
		And the output should not contain "error: Host"
		And the output should not contain "error: cafile"
		And the output should not contain "error: PKCS#12 or cert & key missing"
		Then the output should match:
			"""
			<\?xml version="1.0" encoding="UTF-8"\?>
			<!DOCTYPE plist PUBLIC "-\/\/Apple*\/\/DTD PLIST 1.0\/\/EN" "http:\/\/www.apple.com\/DTDs\/PropertyList-1.0.dtd">
			<plist version="1.0">
			"""
		And the output should match:
			"""
			<key>remote</key>
			\s*<string>aruba.cucumber.org 1194 udp</string>
			"""
		And the output should match:
			"""
			<key>ca</key>
			\s*<string>Contents of CA file\\nWith newlines\\nAnd more newlines\\nThat should appear as one line</string>
			"""
		And the output should match:
			"""
			<key>cert</key>
			\s*<string>Contents of cert file\\nWith newlines\\nAnd more newlines\\nThat should appear as one line</string>
			"""
		And the output should match:
			"""
			<key>key</key>
			\s*<string>Contents of key file\\nWith newlines\\nAnd more newlines\\nThat should appear as one line</string>
			"""
		And the output should match:
			"""
			<key>OnDemandEnabled</key>
			\s*<integer>1</integer>
			"""

	Scenario: The p12pass flag is set.
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org --cafile ca.crt --p12file p12file.p12 --p12pass p12passphrase cucumber aruba`
		Then the output should match:
			"""
			<key>Password</key>
			\s*<string>p12passphrase</string>
			"""

	Scenario: The tafile flag is set.
		Given a file named "ta.key" with:
			"""
			Contents of TLS-Auth Key file
			With newlines
			And more newlines
			That should appear as one line
			"""
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org --cafile ca.crt --p12file p12file.p12 --tafile ta.key cucumber aruba`
		Then the output should match:
			"""
			<key>tls-auth</key>
			\s*<string>Contents of TLS-Auth Key file\\nWith newlines\\nAnd more newlines\\nThat should appear as one line</string>
			"""

	Scenario: The proto and port flags are set.
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org --cafile ca.crt --p12file p12file.p12 --proto tcp --port 1234 cucumber aruba`
		Then the output should match:
			"""
			<key>remote</key>
			\s*<string>aruba.cucumber.org 1234 tcp</string>
			"""

	@OCv1.2 @v0.6.0
	Scenario: The no-vod flag is set.
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org --cafile ca.crt --p12file p12file.p12 --no-vod cucumber aruba`
		Then the output should match:
			"""
			<key>OnDemandEnabled</key>
			\s*<integer>0</integer>
			"""
		And the output should match:
			"""
			<key>vpn-on-demand</key>
			\s*<string>0</string>
			"""

	Scenario: The no-vod flag is not set.
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org --cafile ca.crt --p12file p12file.p12 cucumber aruba`
		Then the output should match:
			"""
			<key>OnDemandEnabled</key>
			\s*<integer>1</integer>
			"""
		And the output should not match:
			"""
			<key>vpn-on-demand</key>
			\s*<string>0</string>
			"""

	@OCv1.2 @v0.6.0
	Scenario: The 1.2 flag is set.
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org --cafile ca.crt --p12file p12file.p12 --1.2 cucumber aruba`
		Then the output should match:
			"""
			<key>VPNSubType</key>
			\s*<string>net.openvpn.connect.app</string>
			"""

	@OCv1.2 @v0.6.0
	Scenario: The 1.2 flag is not set.
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org --cafile ca.crt --p12file p12file.p12 cucumber aruba`
		Then the output should match:
			"""
			<key>VPNSubType</key>
			\s*<string>net.openvpn.OpenVPN-Connect.vpnplugin</string>
			"""

	Scenario: The url-probe flag is set.
		When I run `ovpnmcgen.rb g --host aruba.cucumber.org --cafile ca.crt --p12file p12file.p12 --url-probe 'https://url.to.probe/' cucumber aruba`
		Then the output should match:
			"""
			<key>URLStringProbe</key>
{'fraction_non_alphanumeric': 0.12170503837170504, 'fraction_numerical': 0.02185518852185519, 'mean_word_length': 3.208143208143208, 'pattern_counts': {'":': 0, '<': 130, '<?xml version=': 3, '>': 130, 'https://': 2, 'lorem ipsum': 0, 'www.': 3, 'xml': 3}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1651965', 'n_tokens_mistral': 4873, 'n_tokens_neox': 4240, 'n_words': 1368}